-
Notifications
You must be signed in to change notification settings - Fork 0
/
sweetalert2.min.js
74 lines (69 loc) · 2.13 KB
/
sweetalert2.min.js
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
const custom_message = window.matchMedia("(max-width: 850px)");
let htmlContent;
function widthChangeCallback() {
if (custom_message.matches) {
htmlContent =
"<div id='how-to'>" +
"<ul>" +
"<li>Press Start The game! for the game to start.</li>" +
"<li>" +
"When the game starts, you have to memorize which <br />" +
"color flashes and press the same color." +
"</li>" +
"<li>" +
"Every time you guess correctly, a new color will <br />" +
"flash. Try to guess the color flash sequence! Good luck!" +
"</li>" +
"</ul>" +
"</div>";
} else {
htmlContent =
"<div id='how-to'>" +
"<ul>" +
"<li>Press any key on the keyboard for the game to start.</li>" +
"<li>" +
"When the game starts, you have to memorize which <br />" +
"color flashes and press the same color." +
"</li>" +
"<li>" +
"Every time you guess correctly, a new color will <br />" +
"flash. Try to guess the color flash sequence! Good luck!" +
"</li>" +
"</ul>" +
"</div>";
}
}
// Call widthChangeCallback to initialize the htmlContent variable
widthChangeCallback();
// Check if the message has been displayed before
const hasDisplayedMessage = localStorage.getItem("hasDisplayedMessage");
window.addEventListener("load", (event) => {
if (!hasDisplayedMessage) {
Swal.fire({
title: "How to play the game ?",
imageUrl: "https://i.ibb.co/58z8PJq/ezgif-5-a675c3ffff.gif",
imageWidth: 250,
imageHeight: 250,
html: htmlContent,
background: "#171717",
color: "#fef2bf",
showCancelButton: false,
customClass: "swal",
});
// Set a flag in local storage to indicate that the message has been displayed
localStorage.setItem("hasDisplayedMessage", "true");
}
});
$(".hide").click(() => {
Swal.fire({
title: "How to play the game ?",
imageUrl: "https://i.ibb.co/58z8PJq/ezgif-5-a675c3ffff.gif",
imageWidth: 250,
imageHeight: 250,
html: htmlContent,
background: "#171717",
color: "#fef2bf",
showCancelButton: false,
customClass: "swal",
});
});