Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
647 lines (526 loc) · 18.3 KB
/
Copy pathscript.js
File metadata and controls
647 lines (526 loc) · 18.3 KB
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
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
// Slideshow functionality
let slideIndex = 1;
let slideInterval;
const slideDelay = 6000; // 6 seconds per slide
// Initialize slideshow
document.addEventListener('DOMContentLoaded', function() {
console.log('=== SLIDESHOW DEBUG START ===');
console.log('DOM loaded, initializing slideshow...');
// Check localStorage status
const hasSeenSlideshow = localStorage.getItem('slideshowSeen');
console.log('localStorage slideshowSeen:', hasSeenSlideshow);
// Check if user has seen the slideshow before
if (hasSeenSlideshow) {
console.log('User has seen slideshow before, hiding...');
hideSlideshow();
} else {
console.log('First time user, showing slideshow...');
// Check if overlay exists
const overlay = document.getElementById('slideshowOverlay');
console.log('Overlay element found:', !!overlay);
if (overlay) {
console.log('Initial overlay state:');
console.log('- display:', overlay.style.display);
console.log('- opacity:', overlay.style.opacity);
console.log('- visibility:', overlay.style.visibility);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
// Ensure the overlay is visible immediately
overlay.style.display = 'flex';
overlay.classList.remove('hidden');
overlay.style.opacity = '1';
overlay.style.pointerEvents = 'auto';
overlay.style.visibility = 'visible';
console.log('Slideshow overlay made visible immediately');
// Check state after making visible
console.log('After making visible:');
console.log('- display:', overlay.style.display);
console.log('- opacity:', overlay.style.opacity);
console.log('- visibility:', overlay.style.visibility);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
}
// Initialize slideshow after a short delay
setTimeout(function() {
console.log('=== INITIALIZING SLIDESHOW ===');
showSlides(slideIndex);
startSlideshow();
// Double-check the overlay is visible
if (overlay) {
overlay.style.display = 'flex';
overlay.classList.remove('hidden');
overlay.style.opacity = '1';
overlay.style.pointerEvents = 'auto';
overlay.style.visibility = 'visible';
console.log('Slideshow overlay confirmed visible');
// Final state check
console.log('Final overlay state:');
console.log('- display:', overlay.style.display);
console.log('- opacity:', overlay.style.opacity);
console.log('- visibility:', overlay.style.visibility);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
}
}, 100);
}
// Add event listener for skip button
const skipButton = document.querySelector('.skip-button');
if (skipButton) {
console.log('Skip button found, adding event listener');
skipButton.addEventListener('click', function(e) {
console.log('Skip button clicked!');
e.preventDefault();
e.stopPropagation();
skipSlideshow();
});
} else {
console.log('Skip button not found');
}
console.log('=== SLIDESHOW DEBUG END ===');
});
function showSlides(n) {
const slides = document.getElementsByClassName("slide");
const dots = document.getElementsByClassName("dot");
console.log('showSlides called with n =', n, 'slides.length =', slides.length, 'dots.length =', dots.length);
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
// Hide all slides
for (let i = 0; i < slides.length; i++) {
slides[i].classList.remove("active");
}
// Remove active class from all dots
for (let i = 0; i < dots.length; i++) {
dots[i].classList.remove("active");
}
// Show current slide and activate current dot
slides[slideIndex-1].classList.add("active");
dots[slideIndex-1].classList.add("active");
console.log('Current slide index:', slideIndex, 'Active slide:', slides[slideIndex-1]);
}
function changeSlide(n) {
showSlides(slideIndex += n);
resetSlideshowTimer();
}
function currentSlide(n) {
showSlides(slideIndex = n);
resetSlideshowTimer();
}
function startSlideshow() {
slideInterval = setInterval(() => {
slideIndex++;
showSlides(slideIndex);
}, slideDelay);
// Add a periodic check to ensure slideshow stays visible
setInterval(() => {
const overlay = document.getElementById('slideshowOverlay');
if (overlay && !localStorage.getItem('slideshowSeen')) {
if (overlay.style.display === 'none' || overlay.classList.contains('hidden')) {
console.log('=== SLIDESHOW WAS HIDDEN - RESTORING ===');
console.log('Slideshow was hidden, making it visible again...');
console.log('Previous state:');
console.log('- display:', overlay.style.display);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
console.log('- localStorage slideshowSeen:', localStorage.getItem('slideshowSeen'));
overlay.style.display = 'flex';
overlay.classList.remove('hidden');
overlay.style.opacity = '1';
overlay.style.pointerEvents = 'auto';
overlay.style.visibility = 'visible';
console.log('Restored state:');
console.log('- display:', overlay.style.display);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
}
}
}, 500); // Check every 500ms
}
function resetSlideshowTimer() {
clearInterval(slideInterval);
startSlideshow();
}
function skipSlideshow() {
console.log('skipSlideshow called');
localStorage.setItem('slideshowSeen', 'true');
hideSlideshow();
}
function hideSlideshow() {
console.log('=== HIDE SLIDESHOW CALLED ===');
console.log('hideSlideshow called from:', new Error().stack);
const overlay = document.getElementById('slideshowOverlay');
console.log('Overlay element found:', !!overlay);
if (overlay) {
console.log('Current overlay state before hiding:');
console.log('- display:', overlay.style.display);
console.log('- opacity:', overlay.style.opacity);
console.log('- visibility:', overlay.style.visibility);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
// Only hide if it's currently visible
if (overlay.style.display !== 'none' && !overlay.classList.contains('hidden')) {
console.log('Hiding slideshow...');
overlay.classList.add('hidden');
setTimeout(() => {
overlay.style.display = 'none';
console.log('Slideshow hidden completely');
}, 500);
clearInterval(slideInterval);
} else {
console.log('Slideshow already hidden, not hiding again');
}
} else {
console.error('slideshowOverlay element not found');
}
}
// Keyboard navigation for slideshow
document.addEventListener('keydown', function(e) {
const overlay = document.getElementById('slideshowOverlay');
if (overlay && overlay.style.display !== 'none' && !overlay.classList.contains('hidden')) {
switch(e.key) {
case 'ArrowLeft':
changeSlide(-1);
break;
case 'ArrowRight':
changeSlide(1);
break;
case 'Escape':
skipSlideshow();
break;
}
}
// Debug: Press 'R' to reset slideshow (for testing)
if (e.key === 'r' || e.key === 'R') {
console.log('Resetting slideshow...');
localStorage.removeItem('slideshowSeen');
location.reload();
}
// Debug: Press 'S' to force show slideshow (for testing)
if (e.key === 's' || e.key === 'S') {
console.log('Force showing slideshow...');
const overlay = document.getElementById('slideshowOverlay');
if (overlay) {
overlay.style.display = 'flex';
overlay.classList.remove('hidden');
showSlides(1);
startSlideshow();
}
}
});
// Close slideshow when clicking outside the slideshow container
document.addEventListener('click', function(e) {
const overlay = document.getElementById('slideshowOverlay');
const container = document.querySelector('.slideshow-container');
// Debug all clicks
console.log('=== CLICK EVENT DEBUG ===');
console.log('Click target:', e.target);
console.log('Click target class:', e.target.className);
console.log('Click target id:', e.target.id);
console.log('Overlay found:', !!overlay);
console.log('Container found:', !!container);
if (overlay) {
console.log('Overlay state during click:');
console.log('- display:', overlay.style.display);
console.log('- has hidden class:', overlay.classList.contains('hidden'));
console.log('- localStorage slideshowSeen:', localStorage.getItem('slideshowSeen'));
}
// Only process if slideshow is actually visible and user hasn't seen it before
if (overlay && overlay.style.display !== 'none' && !overlay.classList.contains('hidden') && !localStorage.getItem('slideshowSeen')) {
if (!container.contains(e.target)) {
console.log('=== CLOSING SLIDESHOW VIA CLICK ===');
console.log('Clicked outside slideshow, closing...');
skipSlideshow();
e.stopPropagation(); // Prevent this from triggering other click handlers
} else {
console.log('Click was inside slideshow container, not closing');
}
} else {
console.log('Click conditions not met for closing slideshow');
}
});
let fighters = document.querySelectorAll(".fighter");
// preview selects
let charactername = document.querySelector(".charname");
let charweight = document.querySelector(".weightkg");
let charheight = document.querySelector(".heightcm");
let chararchetype = document.querySelector(".chararchetype");
let charnumber = document.querySelector(".charnumber");
let render = document.querySelector(".preview")
let character = {
char1: {
name: "Kimberly",
weight: "134",
height: "5'6",
archetype: "rushdown",
num: "no4",
background: "url('images/kimgif.gif')"
},
char2: {
name: "Rashid",
weight: "187",
height: "5'10",
archetype: "rushdown",
num: "no19",
background: "url('images/rashidgif.gif')"
},
char3: {
name: "Ken",
weight: "183",
height: "5'9",
archetype: "shoto",
num: "no15",
background: "url('images/kenmasters.gif')"
},
char4: {
name: "Akuma",
weight: "198",
height: "5'10",
archetype: "shoto",
num: "no22",
background: "url('images/akumagif.gif')"
},
char5: {
name: "Bison",
weight: "247",
height: "6'0",
archetype: "Rushdown",
num: "no23",
background: "url('images/bisongif.gif')"
},
char6: {
name: "Blanka",
weight: "216",
height: "6'4",
archetype: "Trickster",
num: "no24",
background: "url('images/blankagif.gif')"
},
char7: {
name: "Cammy",
weight: "134",
height: "5'5",
archetype: "Rushdown",
num: "no10",
background: "url('images/cammygif.gif')"
},
char8: {
name: "Chun-Li",
weight: "secret♡",
height: "5'7",
archetype: "Defensive",
num: "no16",
background: "url('images/chunligif.gif')"
},
char9: {
name: "Dee jay",
weight: "203",
height: "6'0",
archetype: "Trickster",
num: "no9",
background: "url('images/deejaygif.gif')"
},
char10: {
name: "Dhalsim",
weight: "106",
height: "5'9",
archetype: "zoner",
num: "no18",
background: "url('images/simgif.gif')"
},
char11: {
name: "E.Honda",
weight: "302",
height: "6'1",
archetype: "Defensive",
num: "no12",
background: "url('images/hondagif.gif')"
},
char12: {
name: "Ed",
weight: "190",
height: "6'0",
archetype: "Defensive",
num: "no21",
background: "url('images/edgif.gif')"
},
char13: {
name: "Jamie",
weight: "170",
height: "5'9",
archetype: "Trickster",
num: "no2",
background: "url('images/jamiegif.gif')"
},
char14: {
name: "J.P",
weight: "214",
height: "6'3",
archetype: "Zoner",
num: "no7",
background: "url('images/jpgif.gif')"
},
char15: {
name: "Juri",
weight: "126",
height: "5'5",
archetype: "Rushdown",
num: "no8",
background: "url('images/jurigif.gif')"
},
char16: {
name: "Ryu",
weight: "187",
height: "5'9",
archetype: "Shoto",
num: "no11",
background: "url('images/ryu.gif')"
},
char17: {
name: "Terry",
weight: "170",
height: "6'0",
archetype: "Shoto",
num: "no17",
background: "url('images/terrygif.gif')"
},
char18: {
name: "Zangief",
weight: "399",
height: "7'0",
archetype: "Grappler",
num: "no17",
background: "url('images/gief.gif')"
},
char19: {
name: "Aki",
weight: "126",
height: "5'8",
archetype: "Rushdown/zoner",
num: "no20",
background: "url('images/akigif.gif')"
},
char20: {
name: "Lily",
weight: "106",
height: "5'3",
archetype: "Grappler",
num: "no6",
background: "url('images/lily.gif')"
},
char21: {
name: "Manon",
weight: "145",
height: "6'1",
archetype: "Grappler",
num: "no3",
background: "url('images/ManonGif.gif')"
},
char22: {
name: "Luke",
weight: "198",
height: "6'1",
archetype: "Shoto",
num: "no1",
background: "url('images/luke.gif')"
},
char23: {
name: "Guile",
weight: "218",
height: "6'0",
archetype: "Zoner",
num: "no14",
background: "url('images/newguile.gif')"
},
char24: {
name: "Marisa",
weight: "269",
height: "6'8",
archetype: "Big Body",
num: "no5",
background: "url('images/MarissaGif.gif')"
},
char25: {
name: "Mai",
weight: "110",
height: "5'5",
archetype: "Rushdown",
num: "no25",
background: "url('images/MaiGif.gif')"
},
char26: {
name: "Elena",
weight: "129",
height: "6'1",
archetype: "Defensive",
num: "no26",
background: "url('images/elena.gif')"
}
}
const preview = document.querySelector('.preview');
function updatePreview(imageUrl) {
preview.style.opacity = '0'; // fade out first
// match transition time
}
const fighterButtons = Array.from(document.querySelectorAll('.fighter.out'));
let currentIndex = 0;
const fightersPerRow = 4;
fighterButtons[currentIndex].focus();
document.addEventListener('keydown', (e) => {
let nextIndex = currentIndex;
switch (e.key) {
case "ArrowRight":
nextIndex = (currentIndex + 1) % fighterButtons.length;
break;
case "ArrowLeft":
nextIndex = (currentIndex - 1 + fighterButtons.length) % fighterButtons.length;
break;
case "ArrowDown":
nextIndex = (currentIndex + fightersPerRow) % fighterButtons.length;
break;
case "ArrowUp":
nextIndex = (currentIndex - fightersPerRow + fighterButtons.length) % fighterButtons.length;
break;
}
if (nextIndex !== currentIndex) {
currentIndex = nextIndex;
fighterButtons[currentIndex].focus();
}
});
fighters.forEach(function(fighter) {
fighter.addEventListener("mouseenter", () => {
let currentfighter = fighter.getAttribute("data-fighter")
let chardata = character[currentfighter];
charheight.textContent = chardata.height;
charweight.textContent = chardata.weight;
charactername.textContent = chardata.name;
chararchetype.textContent = chardata.archetype;
charnumber.textContent = chardata.num;
render.style.backgroundImage = chardata.background;
})
})
let info = document.querySelector(".info")
let about = document.querySelector(".about")
let mains = document.querySelector(".main");
let a;
info.addEventListener("click", function(event) {
event.stopPropagation();
about.style.display = "flex";
mains.style.filter = "grayscale(100%)";
mains.style.filter = "(100%)";
})
about.addEventListener("click", function(event) {
event.stopPropagation();
})
document.addEventListener("click", function (e) {
console.log('=== ABOUT MODAL CLICK HANDLER ===');
console.log('About modal click handler triggered');
// Don't close about modal if slideshow is active
const overlay = document.getElementById('slideshowOverlay');
console.log('Overlay found in about handler:', !!overlay);
if (overlay && overlay.style.display !== 'none' && !overlay.classList.contains('hidden')) {
console.log('Slideshow is active, not closing about modal');
return; // Don't process this click if slideshow is active
}
console.log('Closing about modal');
about.style.display = "none";
mains.style.filter = "grayscale(0%)";
});
let closebtn = document.querySelector(".close-button");
closebtn.addEventListener("click", function(event) {
event.stopPropagation();
about.style.display = "none";
mains.style.filter = "grayscale(0%)";
})