-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathform.html
More file actions
192 lines (189 loc) · 9.95 KB
/
Copy pathform.html
File metadata and controls
192 lines (189 loc) · 9.95 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
<!DOCTYPE html>
<html>
<head>
<base target="_top">
<!--Import Google Icon Font-->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<!-- Compiled and minified CSS -->
<link type="text/css" rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/css/materialize.min.css">
<style type="text/css">
.picker__holder{z-index:9999}
.ctrlq-description {font-size:90%}
body{background-color:#cde5d5}.picker{position:static}form label,form p{font-size:120%}.signature{border:2px dashed #ccc;background-color:#fafafa;margin-bottom:20px}
.disclaimer{color:#646464;margin:16px 0 32px;padding:0 16px;text-align:center;font:400 12px Roboto,Helvetica,Arial,sans-serif}.disclaimer a{color:#0c9b56}#credit{display:none}
.ctrlqHeaderMast{height:278px;background-image:linear-gradient(to top, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.3) 65%, rgba(0, 0, 0, 0.4) 100%), url(https://lh3.googleusercontent.com/8TC2TY1ZrIAxKT_BrzClXtP3us2Hg5B5f-nVWXJIkzGoW_aVGf6ae_OyvhOb6FysisJBoZiekA=w1200)}.ctrlqFormContent{color:rgba(0,0,0,.87);padding:20px 35px}.ctrlqFormContentWrapper{display:-webkit-box;display:-moz-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-box-orient:vertical;box-orient:vertical;-webkit-flex-direction:column;flex-direction:column}.ctrlqAccent{background-color:#08a275;height:8px}.ctrlqCenteredContent{margin:auto;width:600px}.ctrlqFormCard{background-color:#fff;margin-bottom:48px;-webkit-box-shadow:0 1px 4px 0 rgba(0,0,0,.37);box-shadow:0 1px 4px 0 rgba(0,0,0,.37);word-wrap:break-word}.ctrlqFormCard:first-of-type{margin-top:-100px}.ctrlqHeaderTitle{-webkit-box-sizing:border-box;box-sizing:border-box;font-size:34px;line-height:135%;max-width:100%;min-width:0;margin-bottom:22px}div#recaptcha_error,div#signature_error,div.error{position:relative;left:0;font-size:.9rem;color:#FF4081}@media (max-width:660px){.ctrlqHeaderMast{height:122px}.ctrlqFormCard:first-of-type{margin-top:-50px}.ctrlqCenteredContent{width:90%}}div.error{top:-1rem;-webkit-transform:translateY(0);-ms-transform:translateY(0);-o-transform:translateY(0);transform:translateY(0)}div#recaptcha_error,div#signature_error{top:.5rem;-webkit-transform:translateY(0);-ms-transform:translateY(0);-o-transform:translateY(0);transform:translateY(0)}</style><style>.picker-dialog-frame{width:100%;height:100%;border:0;overflow:hidden}.picker-dialog-bg{position:absolute;top:0;left:0;background-color:#fff;z-index:1000}.picker-dialog{position:absolute;top:0;left:0;background-color:#fff;border:1px solid #acacac;width:auto;padding:0;z-index:1001;overflow:auto;-moz-box-shadow:rgba(0,0,0,.2) 0 4px 16px;-webkit-box-shadow:rgba(0,0,0,.2) 0 4px 16px;box-shadow:rgba(0,0,0,.2) 0 4px 16px}.picker-dialog-content{font-size:0;padding:0}.picker-dialog-title,.picker-dialog-buttons{display:none}
</style>
</head>
<body>
<form id="uploaderForm">
<div class="ctrlqFormContentWrapper">
<div class="ctrlqHeaderMast"></div>
<div class="ctrlqCenteredContent">
<div class="ctrlqFormCard">
<div class="ctrlqAccent"></div>
<div class="ctrlqFormContent">
<form id="appForm">
<div class="row"><div class="input-field col s12">
<h4>File Upload Form</h4>
<p><span class="ctrlq-description">Please complete the form below and upload your resume and certificates.</span></p>
</div></div>
<div class="row">
<div class="input-field col s12">
<input id="applicantName" class="validate" placeholder="Full Name" name="applicantName" type="text" value="" required="required" aria-required="true" data-error="Please enter your full name." >
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input id="applicantEmail" class="validate" placeholder="Email Address" name="applicantEmail" type="email" value="" required="required" aria-required="true" >
<label for="applicantEmail" data-error="Please enter a valid email address."></label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<p>Resume</p>
<p style="font-size:90%">*Allowed file types are .pdf, .doc, .docx. Maximum file size of 3mb.</p>
<input id="filesToUpload" name="filesToUpload" type="file" onchange="return validateFile()" placeholder="Select a file from your computer" required multiple>
</div>
</div>
<div class="row">
<div class="input-field col m6 s6">
<input id="btnSubmit" class="waves-effect waves-light btn-large btnSubmit" style="background-color:#0c9b56" type="button" value="Submit" onclick="uploadFiles()">
</div>
</div>
<div class="row" class="input-field col m6 s6">
<div id="output" class="input-field col m12 s6" style="color:#0c9b56"></div>
</div>
</form>
<div class="row message" style="display:none">
<div id="progressNew" class="input-field col s12">
<h4 id="returnStatus"></h4>
<p id="returnMessage"></p>
</div>
</div>
</div>
</div>
<div class="disclaimer">
<p>This form was created for <a href="https://titahomecare.com" target="_blank">Tita Homecare</a>.</p>
<p>Please contact <a href="mailto:titahomecare@gmail.com" target="_blank">Tita Homecare</a> for any questions/concerns regarding this form.</p>
</div>
</div>
</div>
</form>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.7/js/materialize.min.js"></script>
<script>
var rootFolderId = 'GoogleDriveFolder';
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() {
var allFiles = document.getElementById('filesToUpload').files;
var applicantName = document.getElementById('applicantName').value;
if (!applicantName) {
window.alert('Please enter your full name.');
return;
}
var applicantEmail = document.getElementById('applicantEmail').value;
if (!applicantEmail) {
window.alert('Please enter your email address.');
return;
}
var folderName = applicantName + ' ' + applicantEmail;
if (allFiles.length == 0) {
window.alert('No file selected!');
return;
} 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);
}
}).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 onFileUploaded(r) {
numUploads.done++;
document.getElementById('output').innerHTML = 'Uploaded '
+ r.fileName + ' (' + numUploads.done + '/'
+ numUploads.total + ' files).';
if (numUploads.done == numUploads.total) {
document.getElementById('output').innerHTML = 'Upload Successful. You may now go back and continue your application form.';
var btnSubmit = document.getElementById('btnSubmit');
btnSubmit.style.display = "none";
numUploads.done = 0;
}
}
function validateFile() {
if (!fileExtValidation()) {
// if wrong file extension, return immediately
return false;
}
// continue with file size validation
fileSizeValidation();
}
function fileExtValidation() {
var _validFileExtensions = [".pdf", ".doc", ".docx"];
var fileInput = document.getElementById('filesToUpload');
var arrInputs = fileInput.files;
for (var i = 0; i < arrInputs.length; i++) {
var sFileName = arrInputs[i].name;
if (sFileName.length > 0) {
var blnValid = false;
for (var j = 0; j < _validFileExtensions.length; j++) {
var sCurExtension = _validFileExtensions[j];
if (sFileName.substr(sFileName.length - sCurExtension.length, sCurExtension.length).toLowerCase() == sCurExtension.toLowerCase()) {
blnValid = true;
break;
}
}
if (!blnValid) {
alert("The specified file '" + sFileName + "' could not be uploaded. Only the following filetypes are accepted: " + _validFileExtensions.join(", "));
fileInput.value = '';
return false;
}
}
}
return true;
}
function fileSizeValidation() {
var fileInput = document.getElementById('filesToUpload');
var allFiles = fileInput.files;
for (var i = 0; i < allFiles.length; i++) {
// Validate filesize
if(allFiles[i].size > 3145728){
alert("The specified file '" + allFiles[i].name + "' could not be uploaded. The file is " + formatBytes(allFiles[i].size) + " exceeding the maximum file size of 3 MB.");
fileInput.value = '';
return false;
}
else {
return true;
}
};
}
function formatBytes(bytes,decimals) {
if(bytes == 0) return '0 Bytes';
var k = 1024,
dm = decimals || 2,
sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
}
</script>
</body>
</html>