-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm.html
More file actions
394 lines (332 loc) · 10.3 KB
/
Copy pathForm.html
File metadata and controls
394 lines (332 loc) · 10.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<link href="https://fonts.googleapis.com/css?family=Bitter" rel="stylesheet">
<style>
/* .main-header {
position: fixed;
} */
body {
color: #676767;
font-size: 12px;
font-family: 'open sans';
background-color: #fbfbfb;
}
fieldset {
border: 0;
}
.form-container {
margin: 0px 100px 100px 100px;
}
.form-label {
margin: 20px;
}
div#output {
margin-top: 20px;
}
nav .container {
background-color: white;
}
.navbar-default .navbar-nav>li>a {
font-size: 16px;
color: black
}
.navbar-default .navbar-brand {
font-size: 20px;
color: black;
}
header.main-header {
margin-bottom: 90px;
}
/* .navbar-default{
background-color: green!important;
} */
.header {
width:100%;
height: 100px;
}
.header {
line-height: 1.1;
font-weight: bold;
text-align: center;
width: 60%; /* 70% of the parent*/
margin:10px auto;
}
.header h1 {
font-size: 5em;
}
#output {
font-size: 20px;
padding: 20px 30px;
}
input {
padding: 5px;
margin-left: 30px;
}
input[type="button"] {
border-radius: 5px;
color: #9f1719;
background: #f0f0f0;
box-shadow: 2px 2px #888888;
font-weight: bolder;
font-size: 20px;
margin-top: 20px;
padding: 8px 25px;
}
h2 {
text-align: center;
}
ol li {
font-size: 18px;
}
p {
font-size: 20px;
line-height: 27px;
font-weight: 500;
}
#position {
font-size: 18px;
}
label {
font-size: 18px;
}
.links{
text-align: center
}
.links p a{
font-size: 16px;
font-size: 22px;
line-height: 1.6;
text-decoration: underline;
}
.links p {
padding:25px;
}
.links p:last-child {
padding-bottom: 60px;
}
.navbar-default .navbar-nav>li>a:focus {
background-color: black;
color: white;
}
.navbar-default .navbar-nav>li>a:hover {
color:gray;
}
.navbar-brand {
padding: 18px 15px;
}
.navbar-nav>li>a {
margin-top: 10px;
margin-bottom: 10px;
line-height: 20px;
padding: 10px;
}
.page-content ul li:last-child {
font-size: 17px;
}
.page-content a {
color: black;
text-decoration: underline;
cursor: pointer;
}
.page-content a:hover {
color: rgba(0,95,255,1);
text-decoration: underline;
cursor: pointer;
}
.page-content{
margin-bottom: 60px;
}
.navbar-default {
border-color: white!important;
-webkit-box-shadow: inset 0 1px 0 white, 0 1px 5px white;
box-shadow: inset 0 1px 0 white, 0 1px 5px white;
}
#support_question_wrapper{
margin-left: 30px;
}
@media only screen and (max-width : 500px) {
/* Styles */
.form-container {
margin: 10px;
}
#support_question_wrapper {
margin-left: 10px;
}
}
</style>
</head>
<body>
<div class="form-container" style="display: none;">
<form id="uploaderForm">
<div>
<p id="form-header"></p>
<div class="form-label">
<label>Name: *</label>
</div>
<input type="text" name="applicantName" id="applicantName"
placeholder="Your Name">
<div class="form-label">
<label>Email: *</label>
</div>
<input type="text" name="applicantEmail" id="applicantEmail"
placeholder="Your Email">
<div class="form-label">
<label>Phone Number: *</label>
</div>
<input type="text" name="applicantPhone" id="applicantPhone"
placeholder="Your Phone Number">
<div class="form-label">
<label>Did someone recommend that you apply? If so, please list below:</label>
</div>
<input type="text" name="applicantRec" id="applicantRec"
placeholder="Your Answer">
<div>
<div class="form-label">
<label>What level of staff position they are interested in? *</label>
</div>
<fieldset id="position">
<input type="checkbox" value="Early-Career" name="position">Early-Career<br>
<input type="checkbox" value="Mid-Career" name="position">Mid-Career<br>
<input type="checkbox" value="Subject Matter Expert" name="position">Subject Matter Expert<br>
<input type="checkbox" value="Communications" name="position">Communications<br>
</fieldset>
<p id="resume"></p><input type="file" name="files[1]" id="filesToUpload"multiple>
<p id="support_docs"></p>
<div id="support_question_wrapper">
<p id="why"></p>
<p id="law"></p>
</div>
<input type="file" name="files[2]" id="filesToUpload2"multiple>
</div>
<input type="button" value="Submit" onclick="uploadFiles()">
</div>
</form>
<div id="output"></div>
</div>
<script>
//gets text from tipe.io to update page content
google.script.run.withSuccessHandler (function (result) {
document.getElementById('form-header').innerHTML = result.applyHeader
document.getElementById('resume').innerHTML = result.resumePrompt
document.getElementById('support_docs').innerHTML = result.docsPrompt
document.getElementById('why').innerHTML = result.whyPrompt
document.getElementById('law').innerHTML = result.lawPrompt
document.getElementsByClassName('form-container')[0].style.display="block"
})
.withFailureHandler (function (error) {
console.log('on error handler ',error);
})
.getText();
var rootFolderId = google_root_folder_id;
var numUploads = {};
numUploads.done = 0;
numUploads.total = 0;
// Upload the files into a folder in drive
// This is set to send them all to one folder (specificed in the .gs file)
function uploadFiles(files) {
var firstFile = document.getElementById('filesToUpload').files;
var secondFile = document.getElementById('filesToUpload2').files;
var length = firstFile.length + secondFile.length;
var allFiles = {
0: firstFile[0],
1: secondFile[0],
length: length
}
var applicantName = document.getElementById('applicantName').value;
if (!applicantName) {
window.alert('Missing applicant name');
}
var applicantEmail = document.getElementById('applicantEmail').value;
if (!applicantEmail) {
window.alert('Missing applicant email');
}
var applicantPhone = document.getElementById('applicantPhone').value;
if (!applicantPhone) {
window.alert('Missing applicant phone number');
}
var applicantRec = document.getElementById('applicantRec').value;
if (!applicantRec) {
applicantRec = 'No'
}
function getPositions() {
var positions = document.forms[0];
var positionsTxt = "";
for (var i = 0; i < positions.length; i++) {
if (positions[i].checked) {
positionsTxt = positionsTxt + positions[i].value + " ";
}
}
if(positionsTxt === ""){
window.alert('Missing applicant position');
}
return positionsTxt;
}
var applicantPosition = getPositions()
var folderName = applicantName + ' ' + applicantEmail;
if (allFiles.length < 2) {
window.alert('Please upload all required files');
} else {
numUploads.total = allFiles.length;
google.script.run.withSuccessHandler(function(r) {
// send files after the folder is created...
for (var i = 0; i < allFiles.length; i++) {
// Send each file at a time
uploadFile(allFiles[i], r.folderId);
}
google.script.run.addFile(r.folderId, applicantEmail, applicantPhone, applicantRec, applicantPosition)
}).createFolder(rootFolderId, folderName);
}
}
function uploadFile(file, folderId) {
var reader = new FileReader();
reader.onload = function(e) {
var content = reader.result;
document.getElementById('output').innerHTML = 'uploading '
+ file.name + '...';
//window.alert('uploading ' + file.name + '...');
google.script.run.withSuccessHandler(onFileUploaded)
.uploadFile(content, file.name, folderId)
}
reader.readAsDataURL(file);
}
function clearForm(){
document.getElementById('applicantName').value = ''
document.getElementById('applicantEmail').value = ''
document.getElementById('applicantPhone').value = ''
document.getElementById('applicantRec').value = ''
document.getElementById('filesToUpload').value = ''
document.getElementById('filesToUpload2').value = ''
var positions = document.forms[0];
for (var i = 0; i < positions.length; i++) {
if (positions[i].checked) {
positions[i].checked = false
}
}
}
function onFileUploaded(r) {
numUploads.done++;
document.getElementById('output').innerHTML = 'uploaded '
+ r.fileName + ' (' + numUploads.done + '/'
+ numUploads.total + ' files).';
if (numUploads.done == numUploads.total) {
numUploads.done = 0;
/*var applicantEmail = document.getElementById('applicantEmail').value;*/
var applicantEmail = 'me'
google.script.run.withSuccessHandler(function(result){
let documentsSent = 'All of the '+ numUploads.total + ' files are uploaded, '
if(result.emailSend){
documentsSent += result.emailSend
} else {
documentsSent += result.error
}
document.getElementById('output').innerHTML = documentsSent;
clearForm();
})
.emailConfirmation(applicantEmail)
}
}
</script>
</body>
</html>