-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
83 lines (65 loc) · 2.86 KB
/
script.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
75
76
77
78
79
80
81
82
83
document.addEventListener("DOMContentLoaded", function () {
const muteButton = document.getElementById("muteButton");
const settingsMenu = document.getElementById("settingsMenu");
const cursorButton1 = document.getElementById("cursorButton1");
const cursorButton2 = document.getElementById("cursorButton2");
const cursorDropdown = document.getElementById("cursorDropdown");
const historyButton = document.getElementById("history");
const hoverSound = new Audio();
hoverSound.loop = true;
hoverSound.src = "forest.mp3";
hoverSound.play();
const savedCursor = localStorage.getItem("cursorPreference");
if (savedCursor === "hand2") {
changeCursor2();
} else {
changeCursor1();
}
function toggleHistoryMenu() {
const historyMenu = document.getElementById("historyMenu");
historyMenu.style.display = historyMenu.style.display === "none" ? "block" : "none";
}
historyButton.addEventListener("click", toggleHistoryMenu);
const savedMute = localStorage.getItem("mutePreference");
if (savedMute === "true") {
hoverSound.muted = true;
muteButton.className = "fa-solid fa-volume-xmark fa-2xl";
} else {
hoverSound.muted = false;
muteButton.className = "fa-solid fa-volume-high fa-2xl";
}
document.getElementById("settings").addEventListener("click", function() {
settingsMenu.style.display = settingsMenu.style.display === "none" ? "block" : "none";
});
function toggleMute(event) {
event.stopPropagation();
hoverSound.muted = !hoverSound.muted;
if (hoverSound.muted) {
muteButton.className = "fa-solid fa-volume-xmark fa-2xl";
localStorage.setItem("mutePreference", "true");
} else {
muteButton.className = "fa-solid fa-volume-high fa-2xl";
localStorage.setItem("mutePreference", "false");
}
}
muteButton.addEventListener("click", toggleMute);
function changeCursor1() {
document.body.style.cursor = "url('/img/hand.cur'), auto";
cursorDropdown.classList.remove("active");
localStorage.setItem("cursorPreference", "hand1");
}
function changeCursor2() {
document.body.style.cursor = "url('/img/hand2.cur'), auto";
cursorDropdown.classList.remove("active");
localStorage.setItem("cursorPreference", "hand2");
}
cursorButton1.addEventListener("click", changeCursor1);
cursorButton2.addEventListener("click", changeCursor2);
cursorDropdown.addEventListener("click", function(event) {
event.stopPropagation();
cursorDropdown.classList.toggle("active");
});
window.addEventListener("click", function() {
cursorDropdown.classList.remove("active");
});
});