-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.html
441 lines (413 loc) · 15.3 KB
/
index.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
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
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Onesignal In-App Message</title>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;700&family=Raleway:wght@500;600&display=swap"
rel="stylesheet"
/>
<!-- CSS Reset -->
<link
href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"
rel="stylesheet"
/>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@500;700&family=Raleway:wght@500;700&display=swap"
rel="stylesheet"
/>
<style>
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
display: flex;
align-items: center;
background: #e5e8eb;
padding-top: var(--safe-area-inset-top);
padding-right: var(--safe-area-inset-right);
padding-bottom: calc(var(--safe-area-inset-bottom) + 20px);
padding-left: var(--safe-area-inset-left);
background: #f1eee9;
}
.close-button {
position: absolute;
top: 30;
right: 15;
background: rgba(0, 0, 0, 0);
border: none;
z-index: 1;
display: flex;
justify-content: center;
flex-direction: column;
align-items: center;
/* Tip: Make your close-button relatively large so it's easy to click */
min-width: 48px;
min-height: 48px;
}
.flex-container {
width: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 12px;
}
h1 {
font-family: "Raleway";
font-style: normal;
font-weight: 700;
font-size: 36px;
line-height: 42px;
display: flex;
align-items: center;
text-align: center;
color: #051b2c;
}
h2 {
font-family: "Raleway";
font-style: normal;
font-weight: 500;
font-size: 16px;
line-height: 24px;
display: flex;
align-items: center;
text-align: center;
color: #28333e;
max-width: 270px;
margin-bottom: 36px;
}
.wheel-container {
position: relative;
margin-bottom: 48px;
height: calc(286px + (2 * 6px));
}
.stopper {
position: absolute;
top: 8px;
z-index: 1;
left: 62px;
transform: rotate(323deg);
}
.wheel-container .promo-code-code-message {
display: none;
position: relative;
top: calc(-286px - (2 * 6px));
z-index: 1;
/* display flex will be applied via javascript */
flex-direction: column;
justify-content: center;
align-items: center;
}
.promo-code-code-message h1,
.promo-code-code-message h2 {
color: #fff;
width: auto;
margin: 12px;
}
.promo-code-code-message h2 {
font-family: Raleway;
font-size: 24px;
font-weight: 700;
line-height: 24px;
letter-spacing: 0px;
}
.wheel {
height: 286px;
width: 286px;
position: relative;
border-radius: 50%;
overflow: hidden;
box-shadow: 0 0 10px gray;
transition: 3s all;
border: 6px solid #fff;
background: #000;
color: #fff;
}
.wheel div {
height: 50%;
width: 166px;
clip-path: polygon(100% 0, 50% 100%, 0 0);
transform: translateX(-50%);
transform-origin: bottom;
position: absolute;
left: 21%;
display: flex;
align-items: center;
justify-content: center;
font-size: 20px;
font-family: monospace;
font-weight: 1000;
writing-mode: vertical-rl;
}
.wheel > div:nth-child(odd) {
background: #000;
color: #ee8107;
}
.wheel > div:nth-child(even) {
color: #000;
background: #ee8107;
}
.wheel .one {
transform: rotate(30deg);
}
.wheel .two {
transform: rotate(90deg);
}
.wheel .three {
transform: rotate(150deg);
}
.wheel .four {
transform: rotate(210deg);
}
.wheel .five {
transform: rotate(270deg);
}
.wheel .six {
transform: rotate(330deg);
}
form {
width: 286px;
}
input[type="email"] {
background: #ffffff;
border: 1px solid #cbd1d7;
border-radius: 4px;
width: 100%;
height: 48px;
padding: 12px;
margin-bottom: 24px;
border: none;
box-shadow: 0px 1px 1px rgba(5, 27, 44, 0.16),
inset 0px 2px 0px rgba(255, 255, 255, 0.05);
}
input[type="submit"] {
background: #ee8107;
color: #ffffff;
border-radius: 4px;
width: 100%;
height: 48px;
padding: 12px;
border: none;
box-shadow: 0px 1px 1px rgba(5, 27, 44, 0.16),
inset 0px 2px 0px rgba(255, 255, 255, 0.05);
font-family: "Raleway";
font-weight: 500;
font-size: 16px;
line-height: 19px;
}
.shop-now-button {
display: none;
background: #ee8107;
color: #ffffff;
border-radius: 4px;
width: 286px;
height: 48px;
padding: 12px;
border: none;
font-family: "Raleway";
font-weight: 500;
font-size: 16px;
line-height: 19px;
box-shadow: 0px 1px 1px rgba(5, 27, 44, 0.16),
inset 0px 2px 0px rgba(255, 255, 255, 0.05);
margin-top: 48px;
}
h2.deal {
font-size: 36px;
}
@media screen and (min-width: 480px) {
}
</style>
</head>
<body>
<div class="close-button" data-onesignal-unique-label="close-button">
<svg
width="16"
height="16"
preserveAspectRatio="none"
viewBox="0 0 8 8"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M7.80309 1.14768C8.06564 0.885137 8.06564 0.459453 7.80309 0.196909C7.54055 -0.0656362 7.11486 -0.0656362 6.85232 0.196909L4 3.04923L1.14768 0.196909C0.885137 -0.0656362 0.459453 -0.0656362 0.196909 0.196909C-0.0656362 0.459453 -0.0656362 0.885137 0.196909 1.14768L3.04923 4L0.196909 6.85232C-0.0656362 7.11486 -0.0656362 7.54055 0.196909 7.80309C0.459453 8.06564 0.885137 8.06564 1.14768 7.80309L4 4.95077L6.85232 7.80309C7.11486 8.06564 7.54055 8.06564 7.80309 7.80309C8.06564 7.54055 8.06564 7.11486 7.80309 6.85232L4.95077 4L7.80309 1.14768Z"
fill="#111111"
/>
</svg>
</div>
<div class="flex-container">
<h1 class="primary-header">Cyber Monday</h1>
<h2 class="secondary-header">
Add your email address and spin the wheel!
</h2>
<div class="wheel-container">
<div class="stopper">
<svg
width="23"
height="29"
viewBox="0 0 23 29"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M11.6741 0.767822C8.69151 0.771461 5.83213 1.9579 3.72313 4.06688C1.61415 6.17588 0.42771 9.03526 0.424072 12.0178C0.424072 21.3541 10.5791 27.8078 11.0116 28.0778L11.6741 28.4928L12.3366 28.0778C12.7691 27.8078 22.9241 21.3541 22.9241 12.0178C22.9204 9.03526 21.7339 6.17588 19.6249 4.06688C17.5159 1.9579 14.6567 0.771461 11.6741 0.767822ZM11.6741 18.2678C10.4379 18.2678 9.22957 17.9013 8.20176 17.2144C7.17395 16.5277 6.37287 15.5516 5.89982 14.4096C5.42677 13.2676 5.30301 12.0109 5.54416 10.7985C5.78532 9.58612 6.38057 8.47249 7.25466 7.59841C8.12873 6.72432 9.24232 6.12907 10.4547 5.88791C11.6672 5.64676 12.9238 5.77052 14.0658 6.24357C15.2078 6.71662 16.1839 7.5177 16.8707 8.54551C17.5576 9.57331 17.9241 10.7817 17.9241 12.0178C17.9221 13.6748 17.2629 15.2633 16.0913 16.4351C14.9196 17.6067 13.3311 18.2658 11.6741 18.2678Z"
fill="#E54B4D"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12.3366 28.0778C12.7691 27.8078 22.9241 21.3541 22.9241 12.0178C22.9204 9.03526 21.7339 6.17588 19.6249 4.06688C17.5159 1.9579 14.6567 0.771461 11.6741 0.767822C8.69151 0.771461 5.83213 1.9579 3.72313 4.06688C1.61415 6.17588 0.42771 9.03526 0.424072 12.0178C0.424072 21.3541 10.5791 27.8078 11.0116 28.0778L11.6741 28.4928L12.3366 28.0778ZM11.6741 27.3128L11.807 27.2295C11.986 27.1178 14.5496 25.4917 17.0571 22.7701C19.5773 20.0346 21.9236 16.3213 21.9241 12.019C21.9208 9.30129 20.8396 6.69576 18.9178 4.77399C16.9964 2.85252 14.3915 1.77146 11.6741 1.76782C8.95675 1.77146 6.35172 2.85253 4.43024 4.77399M4.43024 4.77399C2.50863 6.69561 1.42754 9.3009 1.42407 12.0185C1.4243 16.3209 3.77074 20.0345 6.29108 22.7701C8.79858 25.4917 11.3621 27.1178 11.5411 27.2295L11.5424 27.2304L11.6741 27.3128M11.6741 18.2678C10.4379 18.2678 9.22957 17.9013 8.20176 17.2144C7.17395 16.5277 6.37287 15.5516 5.89982 14.4096C5.42677 13.2676 5.30301 12.0109 5.54416 10.7985C5.78532 9.58612 6.38057 8.47249 7.25466 7.59841C8.12873 6.72432 9.24232 6.12907 10.4547 5.88791C11.6672 5.64676 12.9238 5.77052 14.0658 6.24357C15.2078 6.71662 16.1839 7.5177 16.8707 8.54551C17.5576 9.57331 17.9241 10.7817 17.9241 12.0178C17.9221 13.6748 17.2629 15.2633 16.0913 16.4351C14.9196 17.6067 13.3311 18.2658 11.6741 18.2678ZM6.54755 6.89131C5.53361 7.90524 4.84312 9.19706 4.56337 10.6034C4.28364 12.0098 4.4272 13.4675 4.97595 14.7923C5.52468 16.117 6.45393 17.2493 7.6462 18.0459C8.8385 18.8427 10.2402 19.2678 11.6741 19.2678H11.6753C13.5971 19.2655 15.4394 18.501 16.7984 17.1422C18.1572 15.7832 18.9218 13.9408 18.9241 12.019V12.0178C18.9241 10.584 18.499 9.18224 17.7022 7.98995M6.54755 6.89131C7.56147 5.87738 8.85324 5.18688 10.2596 4.90713C11.6661 4.6274 13.1238 4.77095 14.4485 5.3197C15.7732 5.86842 16.9055 6.79771 17.7022 7.98995"
fill="white"
/>
</svg>
</div>
<div class="wheel">
<div class="one">15% OFF</div>
<div class="two">10% OFF</div>
<div class="three">30% OFF</div>
<div class="four">20% OFF</div>
<div class="five">25% OFF</div>
<div class="six">Try Again</div>
</div>
<div class="wheel promo-code-code-message">
<h2 class="deal"></h2>
<p>your next order</p>
<p>Use Code</p>
<h1 class="promo-code"></h1>
</div>
</div>
<button class="shop-now-button">Shop Now</button>
<form>
<input
type="email"
name="email-address"
placeholder="Enter your Email"
required
/>
<input
type="submit"
value="Try My Luck!"
data-onesignal-unique-label="submit-button"
/>
</form>
</div>
<script type="text/javascript">
window.deal = "";
window.promoCode = "";
window.addEventListener("load", (event) => {
document
.querySelector(".close-button")
.addEventListener("click", function (e) {
OneSignalIamApi.close(e);
});
document
.querySelector(".shop-now-button")
.addEventListener("click", function (e) {
// Redirect to shopping page
OneSignalIamApi.close(e);
});
document.querySelector("form").addEventListener("submit", function (e) {
e.preventDefault();
e.stopPropagation();
var emailAddress = e.target["email-address"].value;
var wheel = document.querySelector(".wheel");
var number = Math.ceil(Math.random() * 10000);
var edges = [30, 90, 150, 210, 270, 330];
if (edges.includes(number)) {
// Add one so that the wheel never lands on an edge 🤫
number += 1;
}
wheel.style.transform = "rotate(" + number + "deg)";
var results = handlePromoReceived(number);
var isPromoReceived = results.isPromoReceived;
var shouldTryAgain = results.shouldTryAgain;
var resultTimeout = 5000;
if (isPromoReceived) {
setTimeout(function () {
document.querySelector(".shop-now-button").style["display"] =
"block";
document.querySelector(
".promo-code-code-message"
).style["display"] = "flex";
document.querySelector(
".deal"
).innerText = window.deal;
document.querySelector(
".promo-code"
).innerText = window.promoCode;
document.querySelector(".wheel-container .stopper").style[
"display"
] = "none";
document.querySelector("form").style["display"] = "none";
document.querySelector(".primary-header").innerText =
"Congratulations";
document.querySelector(".secondary-header").innerText =
"You unlocked a good discount";
}, resultTimeout);
}
if (shouldTryAgain) {
setTimeout(function () {
document.querySelector('input[type="submit"]').value = "Try Again!";
}, resultTimeout)
}
});
function handlePromoReceived(number) {
var finalRotation = number % 360;
var isPromoReceived;
var shouldTryAgain;
if (finalRotation < 30) {
isPromoReceived = false;
shouldTryAgain = true;
}
if (finalRotation >= 30 && finalRotation < 90) {
window.deal = "25% Off!";
window.promoCode = "58UYGD";
isPromoReceived = true;
shouldTryAgain = false;
}
if (finalRotation >= 90 && finalRotation < 150) {
window.deal = "20% Off!";
window.promoCode = "18RYBQ";
isPromoReceived = true;
shouldTryAgain = false;
}
if (finalRotation >= 150 && finalRotation < 210) {
window.deal = "30% Off!";
window.promoCode = "48YTGA";
isPromoReceived = true;
shouldTryAgain = false;
}
if (finalRotation >= 210 && finalRotation < 270) {
window.deal = "10% Off!";
window.promoCode = "78UUWL";
isPromoReceived = true;
shouldTryAgain = false;
}
if (finalRotation >= 270 && finalRotation < 330) {
window.deal = "15% Off!";
window.promoCode = "01RLPW";
isPromoReceived = true;
shouldTryAgain = false;
}
if (finalRotation >= 330) {
isPromoReceived = false;
shouldTryAgain = true;
}
return {
isPromoReceived: isPromoReceived,
shouldTryAgain: shouldTryAgain,
}
}
});
</script>
</body>
</html>