-
Notifications
You must be signed in to change notification settings - Fork 0
/
clientcancel_backup_nojquery_brokendisplay.html
333 lines (311 loc) · 17.7 KB
/
clientcancel_backup_nojquery_brokendisplay.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
<!-- <script src="jquery-1.4.1.min.js" type="text/javascript"></script>-->
<!-- remove above import if not testing locally - seems to be merged into main js import on clickfunnel pages -->
<!--This is just a differently formatted version that doesnt blow its top without JQuery, though the display doesnt work to update so-->
<!--DONT USE THIS ONE-->
<style type="text/css" media="screen">
.done {
display: none;
text-decoration: line-through;
/* background: #3f3f41; */
}
.formdiv {
margin: 0 auto;
width: 320px;
}
.formlabel {
display: block;
text-align: center;
font-size: 25px;
color: rgb(0, 117, 178);
margin-top: 5px;
margin-bottom: 5px;
}
.forminput {
display: block;
width: 100%;
margin-top: 5px;
margin-bottom: 15px;
/* text-align: center; */
}
.fieldresponse {
width: 100%;
text-align: center;
min-height: 36px;
margin-top: 5px;
margin-bottom: 10px;
font-size: larger;
font-size: 30px;
color: maroon;
}
.fieldresponseerror {
width: 100%;
text-align: left;
min-height: 36px;
margin-top: 5px;
margin-bottom: 10px;
font-size: larger;
font-size: 22px;
color: maroon;
}
.formbtn {
color: #fff !important;
text-transform: uppercase;
/* background: #38464b; */
background: #c03d15;
padding: 20px;
border-radius: 50px;
display: inline-block;
border: none;
transition: all 0.4s ease 0s;
font-size: large;
}
.formbtn:not(.no-hover):hover {
text-shadow: 0px 0px 6px rgba(255, 255, 255, 1);
-webkit-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
-moz-box-shadow: 0px 5px 40px -10px rgba(0,0,0,0.57);
transition: all 0.4s ease 0s;
}
.formbtn:focus {
outline: none;
box-shadow: none;
}
.forminfo {
font-size: larger;
color: black;
text-align: center;
margin-bottom: 5px;
min-height: 50px;
}
.formresult {
width: 100%;
text-align: center;
min-height: 50px;
font-size: large;
color: red;
margin-bottom: 5px;
}
</style>
<script>
function addAsRestParam(url, name, value) {
if (url.indexOf("?") == -1){
return url + "?" + name + "=" + encodeURIComponent(value);
}else{
return url + "&" + name + "=" + encodeURIComponent(value);
}
}
</script>
<script type="text/javascript">
$("#btnCancel").live("click", function () {
if (document.getElementById('btnCancel').classList.contains('no-hover')){
return;
}
$("#fieldresponse").html = '';
$("#info").html = '';
$("#fieldresponse").html = '<b style="font-size: 22; color: black;">Working...</b>';
document.getElementById('btnCancel').classList.add('no-hover');
// var url = 'http://127.0.0.1:5000/cbapi/requestcancel';
// var url = 'https://3.22.1.101:5001/cbapi/requestcancel';
// var url = 'http://3.22.1.101:5000/cbapi/requestcancel';
var url = 'https://cbapi.jb3innovations.com:5001/cbapi/requestcancel';
var email = $("#email").val();
var lastName = $("#lastName").val();
var zip = $("#zip").val();
if (!email || !lastName || !zip){
$("#fieldresponse").html = '<b style="font-size: 22;">Please fill all form fields.</b>';
$("#fieldresponse").addClass('fieldresponseerror');
document.getElementById('btnCancel').classList.remove('no-hover');
if (!email){
$("#lblEmail").html = '<b style="color:red;">Email</b>';
}else{
$("#lblEmail").html = '<b>Email</b>';
}
if (!zip){
$("#lblZip").html = '<b style="color:red;">Zip</b>';
}else{
$("#lblZip").html = '<b>Zip</b>';
}
if (!lastName){
$("#lblLastName").html = '<b style="color:red;">Last Name</b>';
}else{
$("#lblLastName").html = '<b>Last Name</b>';
}
}
else{
$("#fieldresponse").removeClass('fieldresponseerror');
$("#lblEmail").html = '<b>Email</b>';
$("#lblZip").html = '<b>Zip</b>';
$("#lblLastName").html = '<b>Last Name</b>';
url = addAsRestParam(url, "email", $("#email").val())
url = addAsRestParam(url, "lastName", $("#lastName").val())
url = addAsRestParam(url, "zip", $("#zip").val())
$.ajax({
type: "GET",
contentType: "text/plain",
url: url,
// data: '{"email": "' + $("#email").val() + ',' + '"zip": "' + $("#zip").val() + ',' + '"lastName": "' + $("#lastName").val() + '"}',
// data: '{}',
processData: false,
dataType: "json",
headers: {'Content-Type': 'text/plain',
'crossDomain' : 'true',
'Connection': 'keep-alive',
'User-Agent': '*/*',
'Connection': '*/*',
"Access-Control-Allow-Origin": '*',
},
success: function (response) {
if (response != null){
// var result = eval(response.d);
switch (eval(response.d)) {
case 'OK':
$("#fieldresponse").html = '<b style="color:green; font-weight:bold; ">Subscription Cancelled</b>';
$("#info").html = '<b style="color:green; font-weight:bold; ">You will receive a confirmation email within the next 24 hours.</b>';
document.getElementById('btnCancel').classList.toggle('done');
document.getElementById('btnCancel').classList.add('no-hover');
document.getElementById('lastName').setAttribute('disabled', true);
document.getElementById('email').setAttribute('disabled', true);
document.getElementById('zip').setAttribute('disabled', true);
window.location.replace("https://www.soloprehab.com/pfc-cancellation-month-discount-subscription1611884031416");
break;
case 'OK MORE':
$("#fieldresponse").html = '<b style="color:green; font-weight:bold; ">Subscription Cancelled*</b>';
$("#info").html = '<b style="color:green; font-weight:bold; ">*Please note that additional active subscriptions were found for the email provided.<br>You may submit this form again to cancel them.</b>';
document.getElementById('btnCancel').classList.add('no-hover');
window.location.replace("https://www.soloprehab.com/pfc-cancellation-month-discount-subscription1611884031416");
break;
case 'ALREADY CANCL':
$("#fieldresponse").html = '<b style="color:green; font-weight:bold; ">Subscription Cancelled*</b>';
$("#info").html = '<b style="color:green; font-weight:bold; ">Cancellation was already completed. Please wait 24 hours and check for a confirmation email.</b>';
document.getElementById('btnCancel').classList.toggle('done');
document.getElementById('btnCancel').classList.add('no-hover');
document.getElementById('lastName').setAttribute('disabled', true);
document.getElementById('email').setAttribute('disabled', true);
document.getElementById('zip').setAttribute('disabled', true);
break;
case 'FAIL':
// $("#result").html = '<b style="color:red;">Error</b>');
$("#fieldresponse").html = '<b style="color:red; font-weight:bold; ">Cancellation Failure</b>';
$("#info").html = '<b style="color:red; font-weight:bold; ">An unknown error occured. <br>Double-check above fields or contact support.</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
break;
case 'REJECT':
$("#fieldresponse").html = '<b style="color:red; font-weight:bold; ">Cancellation Failure</b>';
$("#info").html = '<b style="color:red; font-weight:bold; ">You have submitted too many cancellation attempts. Please try again in 24 hours.</b>';
document.getElementById('btnCancel').classList.toggle('done');
document.getElementById('btnCancel').classList.add('no-hover');
document.getElementById('lastName').setAttribute('disabled', true);
document.getElementById('email').setAttribute('disabled', true);
document.getElementById('zip').setAttribute('disabled', true);
break;
case 'NOT FOUND':
// $("#result").html = '<b style="color:red;">Error</b>');
$("#fieldresponse").html = '<b style="color:red; font-weight:bold; ">No Subscription Found</b>';
$("#info").html = '<b style="color:red; font-weight:bold;">Please double-check above fields and try again, or contact support.</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
break;
default:
// $("#result").html = '<b style="color:red;">Error</b>');
$("#fieldresponse").html = '<b style="color:red;">Error: No Response</b> ';
$("#info").html = '<b style="color:red; font-weight:bold; ">The cancellation service is not responding. Reload the page, try again later, or contact support.</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
break;
}
}else{
$("#fieldresponse").html = '<b style="color:red;">Error</b>';
$("#info").html = '<b style="color:red;">' + (a.responseText == "" ? "Error: Unknown, Contact Support" : a.responseText) + '</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
// $("#info").html = '<b style="color:red;">Error: No Response, Contact Support</b>');
}
// var html = "";
// $.each(customers, function () {
// html += "<span>Name: " + this.Name + " Id: " + this.Id + "</span><br />";
// });color:darkred;
// $("#result").attr.apply("color: green;")
// $("#result").addClass("style", "green")
},
error: function (a, b, c) {
if (a != null){
switch (a.responseText) {
case 'OK':
$("#fieldresponse").html = '<b style="color:green; font-weight:bold; ">Subscription Cancelled</b>';
$("#info").html = '<b style="color:green; font-weight:bold; ">You will receive a confirmation email within the next 24 hours.</b>';
document.getElementById('btnCancel').classList.toggle('done');
document.getElementById('btnCancel').classList.add('no-hover');
document.getElementById('lastName').setAttribute('disabled', true);
document.getElementById('email').setAttribute('disabled', true);
document.getElementById('zip').setAttribute('disabled', true);
window.location.replace("https://www.soloprehab.com/pfc-cancellation-month-discount-subscription1611884031416");
break;
case 'OK MORE':
$("#fieldresponse").html = '<b style="color:green; font-weight:bold; ">Subscription Cancelled*</b>';
$("#info").html = '<b style="color:green; font-weight:bold; ">*Please note that additional active subscriptions were found for the email provided.<br>You may submit this form again to cancel them.</b>';
document.getElementById('btnCancel').classList.add('no-hover');
window.location.replace("https://www.soloprehab.com/pfc-cancellation-month-discount-subscription1611884031416");
break;
case 'ALREADY CANCL':
$("#fieldresponse").html = '<b style="color:green; font-weight:bold; ">Subscription Cancelled*</b>';
$("#info").html = '<b style="color:green; font-weight:bold; ">Cancellation was already completed. Please wait 24 hours and check for a confirmation email.</b>';
document.getElementById('btnCancel').classList.toggle('done');
document.getElementById('btnCancel').classList.add('no-hover');
document.getElementById('lastName').setAttribute('disabled', true);
document.getElementById('email').setAttribute('disabled', true);
document.getElementById('zip').setAttribute('disabled', true);
break;
case 'FAIL':
// $("#result").html = '<b style="color:red;">Error</b>');
$("#fieldresponse").html = '<b style="color:red; font-weight:bold; ">Cancellation Failure</b>';
$("#info").html = '<b style="color:red; font-weight:bold; ">An unknown error occured. <br>Double-check above fields or contact support.</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
break;
case 'REJECT':
$("#fieldresponse").html = '<b style="color:red; font-weight:bold; ">Cancellation Failure</b>';
$("#info").html = '<b style="color:red; font-weight:bold; ">You have submitted too many cancellation attempts. Please try again in 24 hours.</b>';
document.getElementById('btnCancel').classList.toggle('done');
document.getElementById('btnCancel').classList.add('no-hover');
document.getElementById('lastName').setAttribute('disabled', true);
document.getElementById('email').setAttribute('disabled', true);
document.getElementById('zip').setAttribute('disabled', true);
break;
case 'NOT FOUND':
// $("#result").html = '<b style="color:red;">Error</b>');
$("#fieldresponse").html = '<b style="color:red; font-weight:bold; ">No Subscription Found</b>';
$("#info").html = '<b style="color:red; font-weight:bold;">Please double-check above fields and try again, or contact support.</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
break;
default:
// $("#result").html = '<b style="color:red;">Error</b>');
$("#fieldresponse").html = '<b style="color:red;">Error: No Response</b> ';
$("#info").html = '<b style="color:red; font-weight:bold; ">The cancellation service is not responding. Reload the page, try again later, or contact support.</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
break;
}
}else{
$("#fieldresponse").html = '<b style="color:red;">Error</b>';
$("#info").html = '<b style="color:red;">' + (a.responseText == "" ? "Error: Unknown, Contact Support" : a.responseText) + '</b>';
document.getElementById('btnCancel').classList.remove('no-hover');
}
// alert(a.responseText);
}
});
}
});
</script>
<div class="formdiv">
<form id="formCancel" runat="server" style="padding-top:20px; min-width: 100px;">
<label id="lblEmail" for="email" class="formlabel"><b>Email</b></label>
<input type="text" id="email" class="forminput" />
<label id="lblZip" for="zip" class="formlabel"><b>Zip</b></label>
<input type="text" id="zip" class="forminput" />
<label id="lblLastName" for="lastName" class="formlabel"><b>Last Name</b></label>
<input type="text" id="lastName" class="forminput" />
<div id="fieldresponse" class="fieldresponse"></div>
<div id="result" class="formresult">
<div class="formdiv">
<b><input id="btnCancel" class="formbtn" type="button" value="Cancel Subscription" /></b>
</div><br>
</div>
<div id="info" class="forminfo">
</div>
</form>
</div>