-
Notifications
You must be signed in to change notification settings - Fork 7
/
store.html
executable file
·446 lines (445 loc) · 24.9 KB
/
store.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
442
443
444
445
446
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Store items</title>
<style>
@font-face {
font-family: "Roboto";
src: url(fonts/Roboto.ttf);
}
@font-face {
font-family: "Game";
src: url(fonts/Game.ttf);
}
html, body {
font-family: "Roboto", Arial;
user-select: none !important;
overflow: none !important;
}
.body {
width: 98%;
height: 97%;
margin: 0;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1), 0 1px 8px rgba(0, 0, 0, 0.3);
padding: 0 !important;
border: 5px solid #333;
border-image: linear-gradient(to top, gold, #fff) 1 / 20px;
background: #fefefe;
overflow-y: scroll !important;
}
.card {
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
transition: box-shadow .3s;
width: 162px !important;
border-radius: 5px;
margin: 10px;
display: inline-block;
cursor: pointer;
background: #fff;
}
.card.hot {
border: 2px solid gold;
border-image: linear-gradient(to right, gold, #fff) 1 / 2px;
}
.card:hover {
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2);
}
.card:hover .preview {
display: block;
}
.card .preview {
display: none;
}
img {
border-radius: 5px 5px 0 0;
pointer-events: none;
}
.container {
padding: 2px 16px;
}
.light {
font-size: italic;
color: #999;
}
.wrapper {
display: inline-flex;
align-items: center;
justify-content: center;
position: relative;
top: 40%;
left: 50%;
transform: translate(-50%, -50%);
flex-wrap: wrap;
width: 80%;
}
.credit {
vertical-align: baseline;
width: 6%;
}
.price {
color: gold;
vertical-align: baseline;
}
.strike {
text-decoration: line-through;
filter: brightness(0%);
}
.sale {
width: 15%;
vertical-align: middle;
}
.user-points {
border-bottom: 2px solid gold;
}
h1.title, p.description {
text-shadow: 2.5px 2.5px 10px rgba(0, 0, 0, 0.25);
}
button {
padding: 2px;
border: 1px solid #333;
background: #fff;
margin: 5px;
border-radius: 2px;
cursor: pointer;
}
button:hover {
background: #eee;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
@keyframes spin-reverse {
0% {
transform: rotate(360deg);
}
100% {
transform: rotate(0deg);
}
}
.spin {
border: 2px solid #f3f3f3;
display: inline-block;
border-top: 2px solid gold;
border-radius: 50%;
width: 10px;
height: 10px;
margin-left: 15px;
animation: spin 2s linear infinite;
}
.spin-reverse {
animation: spin-reverse 2s linear infinite;
}
.spin.spin-large {
width: 100px;
height: 100px;
}
.center {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.center-h {
position: absolute;
left: 50%;
transform: translate(-50%, 0);
}
.loader {
background: #fff;
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: 0;
z-index: 999999999;
}
.center-origin {
display: inline-flex;
text-align: center;
align-items: center;
justify-content: center;
}
video {
position: fixed;
top: 0;
left: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
object-fit: contain;
z-index: 999999;
margin: 0 !important;
border: none;
}
#clearfix {
outline: none;
border: none;
background: #fff;
color: #333;
text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.24) !important;
box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1), 0 1px 4px rgba(0, 0, 0, 0.24) !important;
font-size: 18px;
padding: 6px;
border-radius: 3px;
cursor: pointer;
}
.gamepad-focus {
outline: 6px solid #ddd;
transform: scale(1.05);
}
.snowflake{z-index:999999;position:absolute;pointer-events:none!important}.snowflake{--size:1vw;width:var(--size);height:var(--size);background:#eee;box-shadow:0 0 5px 5px #eee;border-radius:50%;top:-5vh}@keyframes snowfall{0%{transform:translate3d(var(--left-ini),0,0)}100%{transform:translate3d(var(--left-end),110vh,0)}}.snowflake:first-child{--size:0.8vw;--left-ini:-8vw;--left-end:1vw;left:41vw;animation:13s linear -1s infinite snowfall}.snowflake:nth-child(2){--size:0.6vw;--left-ini:6vw;--left-end:1vw;left:72vw;animation:6s linear -2s infinite snowfall}.snowflake:nth-child(3){--size:1vw;--left-ini:5vw;--left-end:-9vw;left:57vw;animation:14s linear -4s infinite snowfall}.snowflake:nth-child(4){--size:0.2vw;--left-ini:2vw;--left-end:4vw;left:66vw;animation:10s linear -8s infinite snowfall}.snowflake:nth-child(5){--size:0.2vw;--left-ini:5vw;--left-end:-3vw;left:40vw;animation:6s linear -2s infinite snowfall}.snowflake:nth-child(6){--size:0.4vw;--left-ini:0vw;--left-end:-4vw;left:12vw;animation:11s linear -4s infinite snowfall}.snowflake:nth-child(7){--size:0.8vw;--left-ini:1vw;--left-end:-7vw;left:15vw;animation:7s linear -5s infinite snowfall}.snowflake:nth-child(8){--size:1vw;--left-ini:9vw;--left-end:-4vw;left:16vw;animation:13s linear -2s infinite snowfall}.snowflake:nth-child(9){--size:0.4vw;--left-ini:0vw;--left-end:-6vw;left:81vw;animation:7s linear -6s infinite snowfall}.snowflake:nth-child(10){--size:1vw;--left-ini:-7vw;--left-end:-5vw;left:14vw;animation:14s linear -1s infinite snowfall}.snowflake:nth-child(11){--size:1vw;--left-ini:-3vw;--left-end:3vw;left:69vw;animation:7s linear -1s infinite snowfall}.snowflake:nth-child(12){--size:0.8vw;--left-ini:-3vw;--left-end:4vw;left:52vw;animation:11s linear -6s infinite snowfall}.snowflake:nth-child(13){--size:0.8vw;--left-ini:4vw;--left-end:5vw;left:14vw;animation:13s linear -3s infinite snowfall}.snowflake:nth-child(14){--size:1vw;--left-ini:2vw;--left-end:-7vw;left:97vw;animation:8s linear -6s infinite snowfall}.snowflake:nth-child(15){--size:0.4vw;--left-ini:-4vw;--left-end:-9vw;left:77vw;animation:6s linear -10s infinite snowfall}.snowflake:nth-child(16){--size:0.8vw;--left-ini:-4vw;--left-end:6vw;left:27vw;animation:7s linear -8s infinite snowfall}.snowflake:nth-child(17){--size:0.8vw;--left-ini:6vw;--left-end:-6vw;left:74vw;animation:15s linear -8s infinite snowfall}.snowflake:nth-child(18){--size:0.4vw;--left-ini:-7vw;--left-end:-5vw;left:9vw;animation:10s linear -7s infinite snowfall}.snowflake:nth-child(19){--size:0.8vw;--left-ini:6vw;--left-end:-1vw;left:1vw;animation:9s linear -7s infinite snowfall}.snowflake:nth-child(20){--size:0.2vw;--left-ini:9vw;--left-end:0vw;left:22vw;animation:13s linear -10s infinite snowfall}.snowflake:nth-child(21){--size:1vw;--left-ini:-4vw;--left-end:5vw;left:96vw;animation:14s linear -8s infinite snowfall}.snowflake:nth-child(22){--size:0.2vw;--left-ini:7vw;--left-end:-8vw;left:15vw;animation:10s linear -6s infinite snowfall}.snowflake:nth-child(23){--size:1vw;--left-ini:0vw;--left-end:2vw;left:26vw;animation:13s linear -10s infinite snowfall}.snowflake:nth-child(24){--size:0.2vw;--left-ini:-4vw;--left-end:7vw;left:60vw;animation:14s linear -4s infinite snowfall}.snowflake:nth-child(25){--size:0.4vw;--left-ini:4vw;--left-end:4vw;left:17vw;animation:13s linear -6s infinite snowfall}.snowflake:nth-child(26){--size:1vw;--left-ini:2vw;--left-end:7vw;left:9vw;animation:10s linear -9s infinite snowfall}.snowflake:nth-child(27){--size:0.8vw;--left-ini:-4vw;--left-end:2vw;left:68vw;animation:10s linear -1s infinite snowfall}.snowflake:nth-child(28){--size:1vw;--left-ini:-8vw;--left-end:2vw;left:86vw;animation:6s linear -5s infinite snowfall}.snowflake:nth-child(29){--size:0.8vw;--left-ini:-4vw;--left-end:-5vw;left:6vw;animation:9s linear -9s infinite snowfall}.snowflake:nth-child(30){--size:1vw;--left-ini:-1vw;--left-end:5vw;left:80vw;animation:7s linear -1s infinite snowfall}.snowflake:nth-child(31){--size:0.6vw;--left-ini:4vw;--left-end:-3vw;left:100vw;animation:9s linear -10s infinite snowfall}.snowflake:nth-child(32){--size:0.2vw;--left-ini:9vw;--left-end:-5vw;left:71vw;animation:11s linear -1s infinite snowfall}.snowflake:nth-child(33){--size:0.4vw;--left-ini:-4vw;--left-end:-6vw;left:30vw;animation:9s linear -5s infinite snowfall}.snowflake:nth-child(34){--size:1vw;--left-ini:-2vw;--left-end:1vw;left:81vw;animation:13s linear -10s infinite snowfall}.snowflake:nth-child(35){--size:0.4vw;--left-ini:-4vw;--left-end:-1vw;left:22vw;animation:12s linear -6s infinite snowfall}.snowflake:nth-child(36){--size:0.4vw;--left-ini:-7vw;--left-end:1vw;left:33vw;animation:14s linear -3s infinite snowfall}.snowflake:nth-child(37){--size:0.8vw;--left-ini:6vw;--left-end:8vw;left:44vw;animation:9s linear -4s infinite snowfall}.snowflake:nth-child(38){--size:0.4vw;--left-ini:4vw;--left-end:-1vw;left:17vw;animation:10s linear -6s infinite snowfall}.snowflake:nth-child(39){--size:0.2vw;--left-ini:2vw;--left-end:-4vw;left:77vw;animation:11s linear -9s infinite snowfall}.snowflake:nth-child(40){--size:1vw;--left-ini:-6vw;--left-end:2vw;left:48vw;animation:8s linear -6s infinite snowfall}.snowflake:nth-child(41){--size:0.8vw;--left-ini:8vw;--left-end:3vw;left:93vw;animation:6s linear -9s infinite snowfall}.snowflake:nth-child(42){--size:1vw;--left-ini:-7vw;--left-end:-9vw;left:80vw;animation:12s linear -3s infinite snowfall}.snowflake:nth-child(43){--size:0.8vw;--left-ini:-3vw;--left-end:-6vw;left:30vw;animation:14s linear -9s infinite snowfall}.snowflake:nth-child(44){--size:1vw;--left-ini:-7vw;--left-end:-9vw;left:70vw;animation:12s linear -8s infinite snowfall}.snowflake:nth-child(45){--size:0.2vw;--left-ini:-4vw;--left-end:2vw;left:17vw;animation:6s linear -6s infinite snowfall}.snowflake:nth-child(46){--size:0.4vw;--left-ini:-8vw;--left-end:3vw;left:4vw;animation:13s linear -2s infinite snowfall}.snowflake:nth-child(47){--size:0.2vw;--left-ini:-6vw;--left-end:-3vw;left:53vw;animation:14s linear -3s infinite snowfall}.snowflake:nth-child(48){--size:0.8vw;--left-ini:8vw;--left-end:-7vw;left:91vw;animation:13s linear -3s infinite snowfall}.snowflake:nth-child(49){--size:0.6vw;--left-ini:2vw;--left-end:9vw;left:95vw;animation:11s linear -6s infinite snowfall}.snowflake:nth-child(50){--size:1vw;--left-ini:-6vw;--left-end:4vw;left:85vw;animation:6s linear -1s infinite snowfall}.snowflake:nth-child(6n){filter:blur(1px)}
</style>
<script src="js/user/user.js"></script>
<script src="https://cdn.jsdelivr.net/gh/notiflix/Notiflix@latest/dist/notiflix-aio-3.2.7.min.js"></script>
<script src="js/analytics.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script src="js/GamepadMenuControls.js"></script>
<script src="https://cdn.jsdelivr.net/gh/TSedlar/[email protected]/pseudostyler.js"></script>
</head>
<body>
<div class="loader">
<div class="spin spin-large center-origin" style="position: absolute; left: 50%; top: 50%; margin-left: -50px; margin-top: -50px; padding: 0 !important">
<p class="spin-reverse" style="display: inline-block"><img src="images/html/credit.png" style="width: 50%"></p>
</div>
</div>
<div class="body">
<h1 style="text-align: center; font-size: 3em" class="title"><img class="credit" src="images/html/credit.png" style="width: 2%; vertical-align: baseline"> Store</h1>
<p style="text-align: center" class="description">You currently own <span class="user-items">0</span> items, with <span class="user-points">0</span> available credit(s)</h1></p>
<div class="wrapper" style="margin-top: 100px">
<div class="card" data-item="Loadout.Assault_Rifle-Glock_19" data-price="300">
<img src="images/store/loadouts/Assault_Rifle-Glock_19.png" style="width:100%">
<div class="container">
<h4><b class="price">300 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Basic loadout</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Loadout.Sniper_Rifle-Shotgun" data-price="9000">
<img src="images/store/loadouts/Sniper_Rifle-Shotgun.png" style="width:100%">
<div class="container">
<h4><b class="price">9,000 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Sniper loadout</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Loadout.Tactical_Shotgun-Glock_19" data-price="3000">
<img src="images/store/loadouts/Tactical_Shotgun-Glock_19.png" style="width:100%">
<div class="container">
<h4><b class="price">3000 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Pistol loadout</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card hot" data-item="Loadout.Light_Machine_Gun-Auto_Pistol" data-price="12500">
<img src="images/store/loadouts/Light_Machine_Gun-Auto_Pistol.png" style="width:100%">
<div class="container">
<h4><b class="price strike">15,500</b> <b class="price">12,500 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Auto loadout <img class="sale" src="images/html/sale.png"></p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card hot" data-item="Loadout.Grenade_Launcher-Rocket_Pistol" data-price="30000">
<img src="images/store/loadouts/Grenade_Launcher-Rocket_Pistol.png" style="width:100%">
<div class="container">
<h4><b class="price strike">40,200</b> <b class="price">30,000 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Heavy loadout <img class="sale" src="images/html/sale.png"></p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Character.Steve" data-price="550">
<img src="images/store/characters/Steve.png" style="width:100%">
<div class="container">
<h4><b class="price">550 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Steve</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card hot" data-item="Character.Max" data-price="12500">
<img src="images/store/characters/Max.png" style="width:100%">
<div class="container">
<h4><b class="price">12,500 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Max</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Theme.Contrast" data-price="100">
<img src="images/store/themes/contrast.png" style="width:100%">
<div class="container">
<h4><b class="price">100 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Contrast theme</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Theme.Dark" data-price="100">
<img src="images/store/themes/dark.png" style="width:100%">
<div class="container">
<h4><b class="price">100 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Dark theme</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Theme.Light" data-price="100">
<img src="images/store/themes/light.png" style="width:100%">
<div class="container">
<h4><b class="price">100 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Light theme</p>
<button class="preview">Preview</button>
</div>
</div>
<div class="card" data-item="Theme.Auto" data-price="100">
<img src="images/store/themes/auto.png" style="width:100%">
<div class="container">
<h4><b class="price">100 <img class="credit" src="images/html/credit.png"></b></h4>
<p>Auto theme</p>
<button class="preview">Preview</button>
</div>
</div>
</div>
</div>
<div class="bypass" style="display: none; z-index: 999999999999999999999999; position: fixed; left: 0; top: 0; bottom: 0; right: 0; width: 100%; height: 100%; padding: 0; margin: 0; background: rgba(0, 0, 0, .435)">
<div style="z-index: 9999999999999999; color: #fff; display: inline-block; font-size: 35px; position: fixed; left: 50%; width: 60%; margin-left: -30%; top: 50%; height: 60%; margin-top: -10%; text-align: center; justify-content: center; align-items: center">You must have an account to use the store.
<br>
<br>
<button id="clearfix" onclick="location.replace('login.html?return=store.html')">Log in</button>
</div>
</div>
<script>
window.addEventListener("load", () => {
if (!userMan.isLoggedIn) return document.querySelector(".bypass").style.display = "block";
userMan.update(["tuser", "tpass"], function(key, value) {
if (key == "metadata") {
document.querySelectorAll(".user-points").forEach(x => x.textContent = (value.points - 0).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
document.querySelectorAll(".user-items").forEach(x => x.textContent = value.preferences.items.length);
setTimeout(() => document.querySelector(".loader").remove(), 1000);
}
});
document.querySelectorAll(".card").forEach(x => {
x.addEventListener("click", function(event) {
if (event.target.className == "preview") {
let video = document.createElement("video");
video.src = "previews/" + x.dataset.item + ".mp4";
video.play();
video.onended = () => video.remove();
document.body.appendChild(video);
return;
}
if (userMan.get("metadata").preferences.items.indexOf(x.dataset.item) > -1) {
Notiflix.Block.circle("[data-item='" + x.dataset.item + "']", ".");
x.querySelector(".notiflix-block-message").innerHTML = `Do you want to <b>sell</b> this item for ${((x.dataset.price - 0) / 2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}<img class="credit" src="images/html/credit.png">?<br><button>Yes</button><button>No</button>`;
x.querySelector(".notiflix-block-message").querySelectorAll("button")[0].addEventListener("click", function() {
let newdata = userMan.get("metadata");
newdata.points = newdata.points - 0;
newdata.points += ((x.dataset.price - 0) / 2) - 0;
newdata.points = newdata.points.toString();
newdata.preferences.items.splice(newdata.preferences.items.indexOf(x.dataset.item), 1);
Notiflix.Block.remove("[data-item='" + x.dataset.item + "']");
userMan.set("metadata", newdata, () => {
location.reload();
}, ["tuser", "tpass"]);
});
x.querySelector(".notiflix-block-message").querySelectorAll("button")[1].addEventListener("click", function() {
Notiflix.Block.remove("[data-item='" + x.dataset.item + "']");
});
} else {
Notiflix.Block.circle("[data-item='" + x.dataset.item + "']", ".");
x.querySelector(".notiflix-block-message").innerHTML = `Do you want to <b>buy</b> this item for ${x.dataset.price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",")}<img class="credit" src="images/html/credit.png">?<br><button>Yes</button><button>No</button>`;
x.querySelector(".notiflix-block-message").querySelectorAll("button")[0].addEventListener("click", function() {
let price = x.dataset.price;
if (price - 0 >= userMan.get("metadata").points - 0) {
Notiflix.Notify.failure("Failed to purchase: insufficient funds.");
Notiflix.Block.remove("[data-item='" + x.dataset.item + "']");
} else {
let newdata = userMan.get("metadata");
newdata.points = newdata.points - 0;
newdata.points -= x.dataset.price - 0;
newdata.points = newdata.points.toString();
newdata.preferences.items.push(x.dataset.item);
Notiflix.Block.remove("[data-item='" + x.dataset.item + "']");
userMan.set("metadata", newdata, () => {
location.reload();
}, ["tuser", "tpass"]);
}
});
x.querySelector(".notiflix-block-message").querySelectorAll("button")[1].addEventListener("click", function() {
Notiflix.Block.remove("[data-item='" + x.dataset.item + "']");
});
}
});
if (userMan.get("metadata").preferences.items.indexOf(x.dataset.item) > -1) {
x.querySelector("h4").innerHTML = "<i class='light'>Owned</i>";
x.querySelector("button").textContent = "Equip";
x.querySelector("button").addEventListener("click", (e) => {
e.preventDefault();
location.assign("settings.html?equip=" + encodeURIComponent(x.dataset.item));
});
x.classList.add("owned");
}
});
document.querySelectorAll(".user-points").forEach(x => x.textContent = userMan.get("metadata").points.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
document.querySelectorAll(".user-items").forEach(x => x.textContent = userMan.get("metadata").preferences.items.length);
});
// Gamepad setup
window.addEventListener("load", () => {
let cards = [];
document.querySelectorAll(".card").forEach(x => {
cards.push(".card:nth-child(" + (cards.length + 1) + ")");
});
console.log(cards)
GamepadControls = new GamepadMenuControls(cards, true);
GamepadControls.action = function(type, element) {
if (type == "click") {
if (element.textContent.trim().toLowerCase().includes("play")) {
if (element.previousElementSibling.style.visibility != "visible") {
GamepadControls.elements.splice(GamepadControls.elements.indexOf(".holder"), 1);
GamepadControls.elements.splice(GamepadControls.elements.indexOf(".mini-button"), 1);
GamepadControls.update();
GamepadControls.focus = 0;
return;
}
document.querySelector(".holder").onclick = function() {
document.querySelectorAll(".arrow-holder")[1].click();
};
GamepadControls.elements.splice(1, 0, ".holder");
GamepadControls.elements.splice(2, 0, ".mini-button");
GamepadControls.update();
GamepadControls.focus = 4;
}
}
}
});
setInterval(() => { if (navigator.getGamepads().length < 1) return; navigator.getGamepads()[0].axes[0] == -1 ? (controller.buttonActions[11].before(), controller.buttonActions[11].after(), controller.buttonActions[11].after()) : navigator.getGamepads()[0].axes[0] == 1 && (controller.buttonActions[12].before(), controller.buttonActions[12].after(), controller.buttonActions[12].after()) }, 100);
let checkGamepads = setInterval(() => {
if (navigator.getGamepads().length > 0) {
document.querySelectorAll(".card").forEach(x => {
x.addEventListener("click", (e) => {
if (e.target != x) return;
if (x.clicked) {
!x.querySelector(".notiflix-block-message").querySelector("button").clicked && x.querySelector(".notiflix-block-message").querySelector("button").click();
x.querySelector(".notiflix-block-message").querySelector("button").clicked = true;
e.preventDefault();
} else x.clicked = true;
});
});
clearInterval(checkGamepads);
}
});
</script>
<div class="snowflake"></div><div class="snowflake"></div><div class="snowflake"></div><div class="snowflake"></div><div class="snowflake"></div><div class="snowflake"></div>
<div class="simple-keyboard"></div>
</body>
</html>