-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchange.html
364 lines (305 loc) · 9.54 KB
/
change.html
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
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Edit Delivery Information</title>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>
<body onload="load();">
<div class="main-content" id="change-wrapper">
<div id="changePage">
<div id="change2Title"> <h3>Please Complete The Information Below</h3> </div>
<div id="fixPhone"> <center><i>(Phone number is invalid)</i></center><br/> <br/> </div>
<form action="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/910190858844300" id="googleform" method="post" name="googleForm" target="_top">
<input name="_charset_" type="hidden" value="utf-8"/>
</form>
<div id="change2">
<form id='changeForm2' method='post' onsubmit="return false;">
Delivery Address (or type 'pickup'): <br/>
<textarea name='address' rows='3' cols='36'>
</textarea><br /> <br/>
Phone Number: <input name='phone' type='text' /><br/><br/>
</form>
</div>
<input class='styled-button' id='donebutton' type="button" value="Done" onclick="disabled=true;update('change2');"><br/>
</div>
</div>
<div id="hiddenCreditDiv" style="display: none">
<input type="checkbox" id="creditcard" value="yes"> Pay with credit card<br>
</div>
<div id="hiddenform" style="display: none">
<form id='orderForm' method='post' action='confirmation.php'>
<input type="text" id='orderString' name='orderString' rows='3' cols='40'> </textarea>
<input type="checkbox" id="ordercredit" value="yes">
</form>
</div>
</body>
<script type='text/javascript'>
var wenzelCounts2;
var wenzelArr2;
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
function eraseCookie(name) {
createCookie(name,"",-1);
}
function loadCookies() {
if(readCookie("address")) {
document.getElementById("changeForm2").address.value = readCookie("address");
if(document.getElementById("changeForm2").address.value.replace(/^\s+|\s+$/g, '') == "") {
document.getElementById("changeForm2").address.value = "";
}
}
else {
document.getElementById("changeForm2").address.value = "";
}
if(readCookie("phone")) {
document.getElementById("changeForm2").phone.value = readCookie("phone");
}
//alert("Cookies loaded\n" + readCookie("phone") + "\n address: " + readCookie("address"));
}
function saveCookies() {
createCookie('address',
document.getElementById("changeForm2").address.value.replace(new RegExp( "\\n", "g" ), ","),
10000);
createCookie("phone",
document.getElementById("changeForm2").phone.value,
10000);
//alert("Cookies saved\n" + readCookie("phone") + "\n address: " + readCookie("address")
// + document.getElementById("changeForm").address.value +
//"\n" + document.getElementById("changeForm").phone.value);
}
function show(id){
document.getElementById(id).style.display = "block";
}
function hide(id){
document.getElementById(id).style.display = "none";
}
function getRadioValue(radioObj) {
if(!radioObj)
return "";
var radioLength = radioObj.length;
if(radioLength == undefined)
if(radioObj.checked)
return radioObj.value;
else
return "";
for(var i = 0; i < radioLength; i++) {
if(radioObj[i].checked) {
return radioObj[i].value;
}
}
return "";
}
function validatePhone(phone) {
if(phone == "") {
return true;
}
var returnVal = true;
var stripped = phone.replace(/[\(\)\.\-\ ]/g, '');
if (isNaN(stripped)) {
returnVal = false;
} else if (!((stripped.length == 10) || (stripped.length == 7))) {
returnVal = false;
}
return returnVal;
}
function load() {
if(readCookie("redirectchange")) {
document.location.href = "/";
}
else {
createCookie("redirectchange", 1, 1);
}
var closed = 0;
var now = new Date();
var weekDay = now.getDay();
if(weekDay == 0) { //Sunday
if(now.getHours() > 2 && now.getHours() < 14) {
closed = 1;
}
else if(now.getHours() == 2 && now.getMinutes() > 55) {
closed = 1;
}
else if(now.getHours() == 14 && now.getMinutes() < 30) {
closed = 1;
}
}
if(weekDay < 6 && weekDay > 0) { //Monday, Tuesday, Wednesday, Thursday
if(now.getHours() > 2 && now.getHours() < 14) {
closed = 1;
}
else if(now.getHours() == 2 && now.getMinutes() > 55) {
closed = 1;
}
else if(now.getHours() == 14 && now.getMinutes() < 30) {
closed = 1;
}
}
if(weekDay > 5) {
if(now.getHours() > 3 && now.getHours() < 14) {
closed = 1;
}
else if(now.getHours() == 3 && now.getMinutes() > 55) {
closed = 1;
}
else if(now.getHours() == 14 && now.getMinutes() < 30) {
closed = 1;
}
}
closed = 0;
if(closed == 1) {
document.getElementById("donebutton").disabled = true;
document.location.href = "/closed.html";
}
//alert("loading....");
createCookie("changeset",1,1)
loadCookies();
if(readCookie("curOrder")) {
var orderStr = readCookie("curOrder");
wenzelArr2 = orderStr.split('{');
//alert("Reading Current Order:\n" + orderStr);
}
else {
//this would be a problem. Eventually fix to warn user to turn on cookies
//alert("couldn't read");
wenzelArr2 = new Array();
}
if(readCookie("curCount")) {
var countStr = readCookie("curCount");
wenzelCounts2 = countStr.split('a');
}
else {
//this would be a snafu problem
wenzelCounts2 = new Array();
}
if(readCookie("curCredit")) {
document.getElementById("creditcard").checked = true;
} else {
document.getElementById("creditcard").checked = false;
}
//displays the 'your phone number is messed up' message if your phone number is messed up
hide("fixPhone");
if(!(validatePhone(document.getElementById("changeForm2").phone.value))) {
show("fixPhone");
}
}
function update(x)
{
if(x=="change2") {
purchaseWenzel();
}
}
function confirmOrder() {
//regular, non credit check out
if(true) {//!document.getElementById("creditcard").checked) {
var totalSubs = 0;
var confStr = "<b>Your delivery address is:</b><br/> " + document.getElementById("changeForm2").address.value
+ "<br/><br/>" + "<b>Your telephone number is:</b><br/> " + document.getElementById("changeForm2").phone.value
+ "<br/><br/>" + "<b>You ordered:</b><br/>";
//For the email to be send to Alpha Delta
var adStr = "To be delivered to: " + document.getElementById("changeForm2").address.value
+ "* Telephone number: " + document.getElementById("changeForm2").phone.value;
if(document.getElementById("creditcard").checked) {
adStr = adStr + "*Payment method: Credit/Debit*";
}
else {
adStr = adStr + "*Payment method: Cash*";
}
adStr = adStr + "*Order Consists of:*";
var cost = 0;
for(var i = 0; i < wenzelArr2.length; i++) {
var count = wenzelCounts2[i];
totalSubs += count;
if(count > 0) {
confStr = confStr + count + " " + wenzelArr2[i] + "<br/>";
adStr = adStr + count + " " + wenzelArr2[i] + "*";
var curCost = 8.75;
if(wenzelArr2[i].indexOf("blue cheese") != -1) {
curCost += 0.5;
}
if (wenzelArr2[i].indexOf("ranch") != -1) {
curCost = curCost + 0.5;
}
if (wenzelArr2[i].indexOf("bacon") != -1) {
curCost = curCost + 1.0;
}
if (wenzelArr2[i].indexOf("fries") != -1) {
curCost = curCost + 2.0;
}
cost = cost + count*curCost;
}
}
//cost = cost.toFixed(2);
confStr = confStr + "<br/><b>Your approximate total is: </b>$"
+ cost + "<br/>";
wenzel2 = new Array();
wenzelCounts2 = new Array();
update.counter = 0;
createCookie("confString", confStr, 1);
//createCookie("adString", adStr, 1);
eraseCookie("changeset");
document.getElementById("orderString").value = adStr;
if(!document.getElementById("creditcard").checked) {
document.getElementById("donebutton").disabled = false;
document.getElementById("ordercredit").checked = false;
document.getElementById("orderForm").submit();
}
}
/////////////////////////////
//GOOGLE CHECK OUT
if(document.getElementById("creditcard").checked) {
//we need to set up the right variables on the google submit form
//var form = document.getElementById("googleform");
var form = document.getElementById("orderForm");
document.getElementById("donebutton").disabled = false;
document.getElementById("ordercredit").checked = true;
createCookie("ordercredit", 1, 1);
form.submit();
}
}
function purchaseWenzel() {
var totalSubs = 0;
for(var i = 0; i < wenzelCounts2.length; i++) {
totalSubs = totalSubs + wenzelCounts2[i];
}
if(totalSubs == 0) {
alert("There are no wenzels in your order yet. Try returning to the home page and clicking the 'Add' button.");
document.getElementById("donebutton").disabled = false;
return(0);
}
else{
//alert(totalSubs);
}
saveCookies();
if(!(validatePhone(document.getElementById("changeForm2").phone.value))
|| document.getElementById("changeForm2").phone.value.replace(/^\s+|\s+$/g, '') == ""
|| document.getElementById("changeForm2").address.value.replace(/^\s+|\s+$/g, '') == "") {
hide("fixPhone");
if(!(validatePhone(document.getElementById("changeForm2").phone.value))) {
show("fixPhone");
}
show("change2Title");
show("change2");
document.getElementById("donebutton").disabled = false;
}
else {
confirmOrder();
}
}
</script>
</html>