Skip to content

Commit 203900d

Browse files
Updated to work with new server code
Sends search parameters instead of raw form data so server can access data as an object instead of an array.
1 parent 11c0e1c commit 203900d

File tree

1 file changed

+44
-28
lines changed

1 file changed

+44
-28
lines changed

script.js

Lines changed: 44 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var spinner = $('#loader');
2-
const scriptURLC ='https://script.google.com/macros/s/AKfycbwOfIsJmBwuIP4LF633tpTgrR7GJD9M8b4NN0EZ7fmSueHKXXcr0gMgeCnNzW7n7GFv/exec';
3-
// const scriptURLC ='turd';
2+
const scriptURLC ='https://script.google.com/macros/s/AKfycbwq6MUkaz551Y9Tu3q_5-q3HZR9hybTmZk_rpVfBoRZ-l6JOgf53HB7Ic3DwH2g8JLx/exec';
43
const serverlessForm = document.forms['serverless-form'];
54
var timerOn = false;
65
var bgAnimate = false;
@@ -92,19 +91,6 @@ function runTimer(){
9291
timerOn = false;
9392
bgAnimate = true;
9493

95-
// var flashRed = setInterval(function(){
96-
//
97-
// if (bgAnimate == false){
98-
// clearInterval(flashRed);
99-
// return;
100-
// }
101-
//
102-
// $("body").animate({"background-color": "rgb(235, 0, 0)"}, 400)
103-
// .delay(400)
104-
// .animate({"background-color": "black"}, 400);
105-
//
106-
// }, 1600);
107-
10894
$("body").css({"animation-name":"doneFlash", "animation-duration":"1.6s", "animation-iteration-count":"infinite"})
10995

11096
}
@@ -136,7 +122,9 @@ $("#order-id").change(function(){
136122

137123
})
138124

125+
//Get Order Notes
139126
$('#order-id').change(function(){
127+
console.log("Getting Order Notes");
140128
$('#order-notes').html("Retrieving Order Notes");
141129
$('#last-name').val("");
142130
$('#last-name').attr("placeholder", "Retrieving Customer Name");
@@ -148,18 +136,36 @@ $('#tape-num').change(function(){
148136
getOrderDetails($('#order-id').val(), $('#tape-num').val());
149137
})
150138

139+
//-----------------------------------------------------------------
140+
//~~~~~~~~~~~~~~~~~~~~~~~~~Form Submission~~~~~~~~~~~~~~~~~~~~~~~~~
141+
//-----------------------------------------------------------------
142+
143+
var orderID;
144+
var lastName;
145+
var tapeNum;
146+
var initials;
147+
var qcNotes;
148+
var needsReview;
149+
var notesOnly;
150+
var billingNotes;
151+
152+
function getFormDetails(){
153+
154+
orderID = $('#order-id').val();
155+
lastName = $('#last-name').val();
156+
tapeNum = $('#tape-num').val();
157+
initials = $('#initials').val();
158+
qcNotes = $('#qc-notes').val();
159+
needsReview = $('#needs-review').is(":checked");
160+
notesOnly = $('#notes-only').is(":checked");
161+
billingNotes = $('#billing-notes').val();
151162

152-
153-
163+
}
154164

155165
serverlessForm.addEventListener('submit', e => {
156166
e.preventDefault();
157167

158-
var orderID = $('#order-id').val();
159-
var lastName = $('#last-name').val();
160-
var tapeNum = $('#tape-num').val();
161-
var qcNotes = $('#qc-notes').val();
162-
var billingNotes = $('#billing-notes').val();
168+
getFormDetails();
163169

164170
Swal.fire({
165171
title: 'Ready to Log Tape <br/>' + orderID + '_' + lastName + '_ ' + tapeNum + '?',
@@ -182,18 +188,28 @@ function logTape(e){
182188

183189
spinner.show();
184190

185-
var orderID = $('#order-id').val();
186-
var tapeNum = $('#tape-num').val();
187-
var qcNotes = $('#qc-notes').val();
188-
var billingNotes = $('#billing-notes').val();
191+
getFormDetails();
192+
193+
var params = new URLSearchParams({
194+
orderID: orderID,
195+
lastName: lastName,
196+
tapeNum: tapeNum,
197+
initials: initials,
198+
qcNotes: qcNotes,
199+
needsReview: needsReview,
200+
notesOnly: notesOnly,
201+
billingNotes: billingNotes,
202+
orderCategory: "video",
203+
getOrderDetails: false
204+
});
189205

190206
console.log(orderID);
191207

192208
var tapeProgress = "";
193209

194210
fetch(scriptURLC, {
195211
method: 'POST',
196-
body: new FormData(serverlessForm)
212+
body: params
197213
})
198214
.then(res => {
199215

@@ -264,7 +280,7 @@ function logTape(e){
264280

265281
function getOrderDetails(orderID, tapeNum){
266282

267-
const params = new URLSearchParams({
283+
var params = new URLSearchParams({
268284
orderID: orderID,
269285
tapeNum: tapeNum,
270286
getOrderDetails: true

0 commit comments

Comments
 (0)