-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
52 lines (48 loc) · 1.64 KB
/
main.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
function startSound() {
const fireSound = document.getElementById("fireSound");
const start = document.getElementById("start");
const fire = document.getElementById("fire");
fire.classList.add("on");
start.style.display = "none";
fireSound.play();
}
let lastClickTime = 0;
document.addEventListener("click", function (event) {
const currentTime = new Date().getTime();
const tapLength = currentTime - lastClickTime;
if (tapLength < 500 && tapLength > 0) {
toggleFullScreen();
event.preventDefault();
}
lastClickTime = currentTime;
});
// Toggle fullscreen mode
function toggleFullScreen() {
const element = document.documentElement;
const isFullScreen =
document.fullscreenElement ||
document.mozFullScreenElement ||
document.webkitFullscreenElement ||
document.msFullscreenElement;
if (!isFullScreen) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
} else {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
}