-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
755 lines (623 loc) · 22.4 KB
/
index.html
File metadata and controls
755 lines (623 loc) · 22.4 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
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>4ZSlide Puzzle</title>
<meta name="description" content="An interactive and customizable sliding puzzle game, 4ZSlide. Challenge yourself with different grid sizes, gaps, and even your own images." />
<meta name="keywords" content="puzzle, sliding puzzle, 4ZSlide, game, interactive game, brain teaser, logic puzzle, custom puzzle" />
<meta name="author" content="MSabaq" />
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website" />
<meta property="og:title" content="4ZSlide Puzzle Game" />
<meta property="og:description" content="An interactive and customizable sliding puzzle game. Create your own puzzles and challenge your friends!" />
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:title" content="4ZSlide Puzzle Game" />
<meta property="twitter:description" content="An interactive and customizable sliding puzzle game. Create your own puzzles and challenge your friends!" />
<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=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Irish+Grover&display=swap"
rel="stylesheet" />
<link rel="stylesheet" href="./style.css" />
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background-color: lavender;
font-family: "Inter", sans-serif;
}
header {
height: 5rem;
display: flex;
justify-content: space-between;
align-items: center;
max-width: 55rem;
margin: 0 auto;
padding: 0 1rem;
font-size: 1.6rem;
}
header h1 span:nth-child(1) {
font-family: "Irish Grover", sans-serif;
color: #b22525;
letter-spacing: 0.3rem;
}
header h1 span:nth-child(2) {
font-family: "Irish Grover", sans-serif;
color: rebeccapurple;
}
header h1 span:nth-child(3) {
color: rebeccapurple;
font-weight: 600;
}
.modal {
display: none;
justify-content: center;
align-items: center;
position: fixed;
z-index: 1;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
}
.modal .overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: -1;
}
.modal .modal-content {
background-color: #fefefe;
color: rgb(58, 29, 85);
border-radius: 5px;
margin: 15% auto;
padding: 20px;
border: 1px solid #888;
width: 95%;
max-width: 500px;
text-align: center;
}
.settings {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1rem;
margin-top: 1rem;
}
.settings #gap-input,
.settings #customize {
grid-column: span 2;
}
.settings .input-wrapper {
position: relative;
display: flex;
}
.settings input[type="number"] {
width: 100%;
display: block;
position: relative;
padding: 0.5rem;
border: 1px solid #ccc;
border-radius: 4px;
outline: none;
}
.settings input[type="number"]:focus {
border: 1px solid rebeccapurple;
}
.settings .input-wrapper::after {
content: attr(data-label);
position: absolute;
left: 0.5rem;
top: 50%;
transform: translateY(-50%);
background-color: #fefefe;
padding: 0 0.25rem;
color: #666;
pointer-events: none;
transition: all 0.3s ease;
}
.settings .input-wrapper:focus-within::after,
.settings .input-wrapper:has(input:not(:placeholder-shown))::after {
top: 0;
transform: translateY(-50%);
font-size: 0.75rem;
color: rebeccapurple;
}
.settings .gap-input-wrapper {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
grid-column: span 2;
}
.settings .gap-input-wrapper label {
color: #2c0d43;
font-weight: 600;
}
.settings input[type="range"] {
-webkit-appearance: none;
appearance: none;
width: 100%;
height: 10px;
background: #ddd;
outline: none;
opacity: 0.9;
-webkit-transition: opacity 0.2s;
transition: opacity 0.2s;
border-radius: 5px;
margin: 1rem 0;
}
.settings input[type="range"]:hover {
opacity: 1;
}
.settings input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 20px;
height: 20px;
background: rebeccapurple;
cursor: pointer;
border-radius: 50%;
}
.settings input[type="range"]::-moz-range-thumb {
width: 20px;
height: 20px;
background: rebeccapurple;
cursor: pointer;
border-radius: 50%;
border: none;
}
.settings input[type="file"] {
color: #444;
padding: 0.25rem;
border: 1px solid #ccc;
border-radius: 4px;
font-family: "Inter", sans-serif;
}
.settings .image-upload {
grid-column: span 2;
border: 2px dashed #ccc;
border-radius: 4px;
background-color: #fafafa;
transition: background-color 0.2s, border-color 0.2s;
cursor: pointer;
}
.settings .image-upload:hover {
background-color: lavenderblush;
border-color: rebeccapurple;
}
.settings .image-upload label {
color: rebeccapurple;
padding: 1rem;
font-weight: 600;
cursor: pointer;
display: block;
width: 100%;
height: 100%;
}
.settings button {
margin-top: 1rem;
grid-column: 2 / span 1;
padding: 0.75rem;
background-color: rebeccapurple;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
font-weight: 600;
transition: background-color 0.2s;
}
.settings button:hover {
background-color: #5a1a8a;
}
.modal.victory-modal .modal-content{
padding: 0;
background-color: #7b33b1;
border: none;
}
.modal.victory-modal h2.you-win{
display: block;
background-color: #7f50a3;
color: lavender;
margin-top: 1rem;
padding: .5rem 0;
font-weight: bold;
border-radius: 0 0 8px 8px;
border-bottom: .2rem solid #896aa1;
}
.modal.victory-modal h3.moves{
margin: .8rem 0;
color: lavender;
}
.modal.victory-modal h4.moves-count{
color: lavender;
margin-bottom: 1rem;
}
.modal.victory-modal .btn-box{
padding: 0 1rem;
margin-bottom: .5rem;
display: flex;
gap: .5rem;
}
.modal.victory-modal .btn-box button{
padding: .5rem 1rem;
background-color: #896aa1;
border: none;
font-weight: bold ;
font-size: 1rem;
width: 100%;
border-radius: .2rem;
cursor: pointer;
color: lavender;
}
.modal.victory-modal .btn-box button:nth-child(2){
background-color: #b14c4c;
}
.modal.victory-modal .btn-box button:hover{
filter: brightness(1.1);
}
footer {
position: fixed;
bottom: 0;
left:0;
right: 0;
display: flex;
align-items: center;
justify-content: space-between;
text-align: center;
padding: 0 1rem;
margin-top: 1rem;
color: rebeccapurple;
font-size: 1rem;
font-weight: 500;
height: 5rem;
}
footer a{
height: 50px;
margin-left: 0.8rem;
scale: 0.8;
}
footer a img {
height: 50px !important;
width: auto !important;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
footer a:hover img {
transform: scale(1.05);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}
</style>
</head>
<body>
<header>
<h1><span>4</span><span>Z</span><span>Slide</span></h1>
<div style="cursor: pointer" class="cog" onclick="openModal()">
<svg width="30" viewBox="0 0 65 64" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M7.90804 32C7.90804 38.5085 10.4935 44.7504 15.0957 49.3526C19.6979 53.9547 25.9398 56.5402 32.4483 56.5402C38.9567 56.5402 45.1986 53.9547 49.8008 49.3526C54.403 44.7504 56.9885 38.5085 56.9885 32M7.90804 32C7.90804 25.4915 10.4935 19.2496 15.0957 14.6474C19.6979 10.0453 25.9398 7.45978 32.4483 7.45978C38.9567 7.45978 45.1986 10.0453 49.8008 14.6474C54.403 19.2496 56.9885 25.4915 56.9885 32M7.90804 32H3M56.9885 32H61.8965M56.9885 32H32.4483L17.7241 6.49453M4.77671 42.068L9.39027 40.3895M55.5095 23.604L60.1231 21.9254M9.89089 50.9287L13.6537 47.7744M51.2493 16.2255L55.0089 13.0713M17.7274 57.5055L20.1814 53.2518L32.4548 32M44.7216 10.7482L47.1757 6.49453M27.3374 61L28.1881 56.1672M36.7117 7.83279L37.5624 3M37.5624 61L36.7117 56.1672M28.1881 7.83279L27.3374 3M47.1724 57.5022L44.7184 53.2518M55.0056 50.9287L51.2461 47.7744M13.6537 16.2223L9.89089 13.068M60.1231 42.0713L55.5095 40.3927M9.39355 23.6072L4.77998 21.9254"
stroke="#8B2CF2" stroke-width="5.8" stroke-linecap="round" stroke-linejoin="round" />
</svg>
</div>
</header>
<div class="modal">
<div class="overlay" onclick="this.parentElement.style.display='none'"></div>
<div class="modal-content">
<h2>Settings</h2>
<div class="settings">
<div class="input-wrapper" data-label="Rows">
<input type="number" id="rows" min="1" value="2" placeholder="" />
</div>
<div class="input-wrapper" data-label="Columns">
<input type="number" id="cols" min="1" value="5" placeholder="" />
</div>
<div class="gap-input-wrapper">
<label for="gap-input">Gap</label>
<input type="range" name="gap" id="gap-input" min="0" max="20" value="8" />
</div>
<div class="image-upload" id="customize">
<label for="file">
Use Custom Image
</label>
<input id="file" style="display: none" type="file" accept="image/*" />
</div>
<button onclick="applyConfiguration()">Customize</button>
</div>
</div>
</div>
<div class="modal victory-modal">
<div class="overlay" onclick="this.parentElement.style.display='none'"></div>
<div class="modal-content">
<h2 class="you-win">YOU WIN!</h2>
<h3 class="moves">Moves:</h3>
<h4 class="moves-count">53</h4>
<div class="btn-box">
<button
onclick="this.parentElement.parentElement.parentElement.style.display='none'"
>Cancel</button>
<button
onclick="startNewRound()"
>Next Round</button>
</div>
</div>
</div>
<div onclick="prev()" class="prev">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="15 18 9 12 15 6"></polyline>
</svg>
</div>
<div id="main-wrapper"></div>
<div onclick="next()" class="next">
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor"
stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="9 18 15 12 9 6"></polyline>
</svg>
</div>
<button class="apply" onclick="apply(event)">Apply</button>
<footer>
<p>Crafted with 💜 by <strong>MSabaq</strong></p>
<a href="https://www.buymeacoffee.com/msabaq" target="_blank" rel="noopener noreferrer">
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-violet.png" alt="Buy Me A Coffee">
</a>
</footer>
<script src="./logic.js"></script>
<script src="./utils.js"></script>
<script src="./drag.js"></script>
<script>
let emptyTilePositions = [],
puzzleGrids = [],
solvedGrids = [],
currentMoves = [],
currentGridIndex = 0;
let rows, cols;
const imageList = ["./pika.avif", "./z.webp", "./phin.webp", "./v.webp"];
let numberOfGrids = 0;
function createNewGrid(index) {
rows = parseInt(document.getElementById("rows").value);
cols = parseInt(document.getElementById("cols").value);
solvedGrids[index] = createGrid(rows, cols);
puzzleGrids[index] = solvedGrids[index].map(row => row.slice());
const shuffleDegree = Math.floor(Math.random() * 9000) + 1000;
emptyTilePositions[index] = shuffleGrid(puzzleGrids[index], shuffleDegree);
}
const mainWrapper = document.getElementById("main-wrapper");
swipe(mainWrapper, next, prev);
function createGridDOM(index, custom = false) {
let puzzleGrid, solvedGrid, puzzleGridFlattened;
if (puzzleGrids.length != 0) {
puzzleGrid = puzzleGrids[currentGridIndex];
solvedGrid = solvedGrids[currentGridIndex];
puzzleGridFlattened = custom && index ? solvedGrid.flat() : puzzleGrid.flat();
}
if (index >= numberOfGrids) {
const newContainer = document.createElement("div");
newContainer.className = "gridElement-container";
mainWrapper.appendChild(newContainer);
const newGridElement = document.createElement("div");
newGridElement.className = "gridElement";
newContainer.appendChild(newGridElement);
createNewGrid(numberOfGrids);
puzzleGrid = puzzleGrids[numberOfGrids];
solvedGrid = solvedGrids[numberOfGrids];
puzzleGridFlattened = custom && index ? solvedGrid.flat() : puzzleGrid.flat();
numberOfGrids++;
const imageElement = document.createElement("img");
if (index) {
imageElement.src = imageList[index - 1];
imageElement.draggable = true;
newGridElement.appendChild(imageElement);
imageElement.addEventListener('load', () => {
setImages(gridElement, index, imageElement);
if (currentGridIndex === index) {
gridElement.parentElement.style.display = "flex";
} else {
gridElement.parentElement.style.display = "none";
}
});
makeDraggable(imageElement, () => setImages(newGridElement, index, imageElement));
}
}
const gridElement = document.querySelectorAll(".gridElement")[index];
gridElement.style.gap = `${document.getElementById("gap-input").value / 2}px`;
gridElement.style.gridTemplateColumns = `repeat(${cols}, minmax(0, 50px))`;
while (gridElement.children.length > (index ? 1 : 0)) {
gridElement.removeChild(gridElement.lastElementChild);
}
for (let i = 0; i < rows * cols; i++) {
const cell = document.createElement("div");
if (!custom || !index) {
cell.addEventListener("click", handleCellClick);
cell.addEventListener("touchstart", handleCellClick);
cell.addEventListener("touchend", handleCellClick);
}
cell.style.userSelect = "none";
cell.style.backgroundColor =
Math.random() < 0.5 ? "#D92C2C" : "#B22525";
cell.textContent = puzzleGridFlattened[i] || 1;
if (index)
cell.style.color = "transparent";
if (!puzzleGridFlattened[i] && puzzleGridFlattened.length !== 1) {
cell.style.backgroundColor = "transparent";
cell.style.border = "none";
cell.textContent = "";
}
cell.className = "gridElement-cell";
gridElement.appendChild(cell);
}
const imageElement = gridElement.querySelector("img");
if (index) {
if (gridElement.offsetWidth / imageElement.width < gridElement.offsetHeight / imageElement.height) {
imageElement.style.height = "100%";
imageElement.style.width = "auto";
} else {
imageElement.style.width = "100%";
imageElement.style.height = "auto";
}
if (!custom) {
imageElement.style.visibility = "hidden";
imageElement.style.zIndex = "-1";
}
else {
imageElement.style.visibility = "visible";
imageElement.style.zIndex = "2";
}
setImages(gridElement, index, imageElement);
}
if (custom && index)
setShouldSwipe(false);
else
setShouldSwipe(true);
}
for (let i = 0; i <= imageList.length; i++) {
createGridDOM(i);
}
function prev() {
if (currentGridIndex > 0) {
currentGridIndex--;
document.querySelectorAll(".gridElement")[currentGridIndex + 1].parentElement.style.display = "none";
} else if (currentGridIndex == 0) {
currentGridIndex = numberOfGrids - 1;
document.querySelectorAll(".gridElement")[0].parentElement.style.display = "none";
}
document.querySelectorAll(".gridElement")[currentGridIndex].parentElement.style.display = "flex";
}
function next() {
if (currentGridIndex < numberOfGrids - 1) {
currentGridIndex++;
document.querySelectorAll(".gridElement")[currentGridIndex - 1].parentElement.style.display = "none";
} else if (currentGridIndex == numberOfGrids - 1) {
currentGridIndex = 0;
document.querySelectorAll(".gridElement")[numberOfGrids - 1].parentElement.style.display = "none";
}
document.querySelectorAll(".gridElement")[currentGridIndex].parentElement.style.display = "flex";
}
function apply(e) {
createGridDOM(currentGridIndex);
e.target.style.display = "none";
}
function setImages(gridElement, index, imageElement) {
const cellsList = gridElement.querySelectorAll(".gridElement-cell");
for (const cell of cellsList) {
const positionCellIndex = cell.textContent !== "" ? parseInt(cell.textContent) - 1 : cellsList.length - 1;
const positionCell = cellsList[positionCellIndex];
cell.style.background = `url(${imageElement.src})`;
cell.style.backgroundSize = `${imageElement.width}px ${imageElement.height}px`;
cell.style.backgroundRepeat = "no-repeat";
const deltaX = positionCell.getBoundingClientRect().left - imageElement.getBoundingClientRect().left;
const deltaY = positionCell.getBoundingClientRect().top - imageElement.getBoundingClientRect().top;
cell.style.backgroundPosition = `${-deltaX}px ${-deltaY}px`;
if (positionCellIndex === (cellsList.length - 1)) {
cell.style.background = "transparent";
cell.style.border = "none";
}
}
}
touchLocation = [];
async function handleCellClick(e) {
if (e.type == "touchstart") {
touchLocation = [e.touches[0].clientX, e.touches[0].clientY];
return;
}
if (e.type == "touchend") {
console.log(e);
const touch = [e.changedTouches[0].clientX, e.changedTouches[0].clientY];
const diff = Math.abs(touchLocation[0] - touch[0]) + Math.abs(touchLocation[1] - touch[1]);
touchLocation = [];
if (diff > 50)
return;
}
let puzzleGrid = puzzleGrids[currentGridIndex];
e.preventDefault();
const id = e.target.textContent;
const location = findValueIndices(puzzleGrid, id);
let emptyTilePosition = emptyTilePositions[currentGridIndex];
// Check if clicked cell is adjacent (non-diagonal) to empty cell
if (
(Math.abs(location[0] - emptyTilePosition[0]) === 1 &&
location[1] === emptyTilePosition[1]) ||
(Math.abs(location[1] - emptyTilePosition[1]) === 1 &&
location[0] === emptyTilePosition[0])
) {
let currentGrid =
document.querySelectorAll(".gridElement")[currentGridIndex];
let cells = currentGrid.querySelectorAll(".gridElement-cell");
emptyEl = findElementByContent(
cells,
puzzleGrid[emptyTilePosition[0]][emptyTilePosition[1]]
);
slide(puzzleGrid, location, emptyTilePosition);
await swapCells(e.target, emptyEl);
const puzzleGridFlattened = puzzleGrid.flat().map(i => i === 0 ? Infinity : i);
currentMoves[currentGridIndex] = (currentMoves[currentGridIndex] || 0) + 1;
if (puzzleGridFlattened.every((val, i) => i == 0 || val >= puzzleGridFlattened[i-1])){
setTimeout(() => {
showVictory();
}, 300);
}
emptyTilePositions[currentGridIndex] = location;
}
}
function openModal(e) {
const modal = document.querySelector(".modal:has(.settings)");
modal.style.display = "flex";
}
function showVictory(){
const modal = document.querySelector(".modal.victory-modal");
const movesCount = modal.querySelector(".moves-count");
movesCount.textContent = currentMoves[currentGridIndex];
modal.style.display = "flex";
}
function startNewRound() {
const modal = document.querySelector(".modal.victory-modal");
modal.style.display = "none";
currentMoves[currentGridIndex] = 0;
createNewGrid(currentGridIndex);
createGridDOM(currentGridIndex);
}
const gapInput = document.getElementById("gap-input");
gapInput.addEventListener("input", () => updateGapSlider(gapInput));
updateGapSlider(gapInput);
const fileInput = document.getElementById("file");
let settingImage = false;
fileInput.addEventListener('change', function () {
const file = this.files[0];
if (file) {
const reader = new FileReader();
reader.onload = function (e) {
document.querySelector(".image-upload label").textContent = file.name;
imageList.push(e.target.result);
createGridDOM(numberOfGrids);
settingImage = true;
};
reader.readAsDataURL(file);
}
});
function applyConfiguration(e) {
document.querySelectorAll(".gridElement")[currentGridIndex].parentElement.style.display = "none";
if (settingImage) {
currentGridIndex = numberOfGrids - 1;
}
if (currentGridIndex !== 0) {
document.querySelector(".apply").style.display = "block";
}
document.querySelectorAll(".gridElement")[currentGridIndex].parentElement.style.display = "flex";
const modal = document.querySelector(".modal");
modal.style.display = "none";
createNewGrid(currentGridIndex);
createGridDOM(currentGridIndex, true);
settingImage = false;
}
</script>
</body>
</html>