-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
116 lines (100 loc) · 3.83 KB
/
script.js
File metadata and controls
116 lines (100 loc) · 3.83 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
let button10 = document.getElementById("button10");
let button100 = document.getElementById("button100");
let button1000 = document.getElementById("button1000");
let muteButton = document.getElementById("muteButton");
let sound = document.getElementById("click");
let d = new Date();
let cookieExpire = d.getTime() + 24*60*60*1000;
sound.volume = 0.1;
function calculateStats() {
let tempSound = sound.cloneNode();
tempSound.volume = sound.volume;
tempSound.play();
tempSound.remove();
let projSTR = document.getElementById("projStr");
let projDEX = document.getElementById("projDex");
let projCON = document.getElementById("projCon");
let projWIL = document.getElementById("projWil");
let projSPI = document.getElementById("projSpi");
let baseStat = document.getElementById("baseStat");
let strRatio = document.getElementById("strRatio");
let dexRatio = document.getElementById("dexRatio");
let conRatio = document.getElementById("conRatio");
let wilRatio = document.getElementById("wilRatio");
let spiRatio = document.getElementById("spiRatio");
projSTR.textContent = "Projected STR: " + parseFloat(baseStat.value) * parseFloat(strRatio.value);
projDEX.textContent = "Projected DEX: " + parseFloat(baseStat.value) * parseFloat(dexRatio.value);
projCON.textContent = "Projected CON: " + parseFloat(baseStat.value) * parseFloat(conRatio.value);
projWIL.textContent = "Projected WIL: " + parseFloat(baseStat.value) * parseFloat(wilRatio.value);
projSPI.textContent = "Projected SPI: " + parseFloat(baseStat.value) * parseFloat(spiRatio.value);
}
function addStatLevel(amount) {
let mainStatInParent = document.getElementById("baseStat");
let mainStatIn = parseInt(mainStatInParent.value);
if (isNaN(mainStatIn)) {
mainStatIn = 0;
}
mainStatIn += amount;
mainStatInParent.value = mainStatIn;
calculateStats();
}
function getCookie(cname) {
let name = cname + "=";
let decodedCookie = decodeURIComponent(document.cookie);
let ca = decodedCookie.split(';');
for(let i = 0; i <ca.length; i++) {
let c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function onLoad() {
let cookieString = getCookie("isMute");
console.log(cookieString);
if (cookieString === "0" || cookieString === 0) {
console.log("enabled");
sound.volume = 0.1;
muteButton.childNodes[0].src = "assets/volume-on.svg";
}
else if (cookieString == "1" || cookieString == 1) {
console.log("disabled");
sound.volume = 0;
muteButton.childNodes[0].src = "assets/volume-mute.svg";
}
else {
console.log("enabled1");
document.cookie = "isMute=0;expires=" + cookieExpire + ";path=/";
sound.volume = 0.1;
muteButton.childNodes[0].src = "assets/volume-on.svg";
}
}
muteButton.addEventListener("click", () => {
if (sound.volume > 0) {
let tempSound = sound.cloneNode();
tempSound.volume = sound.volume;
tempSound.play();
tempSound.remove();
document.cookie = "isMute=1;expires=" + cookieExpire + ";path=/;SameSite=Lax;";
sound.volume = 0;
muteButton.childNodes[0].childNodes[0].childNodes[0].src = "assets/volume-mute.svg";
}
else {
document.cookie = "isMute=0;expires=" + cookieExpire + ";path=/;SameSite=Lax;";
sound.volume = 0.1;
muteButton.childNodes[0].childNodes[0].childNodes[0].src = "assets/volume-on.svg";
}
});
button10.addEventListener("click", () => {
addStatLevel(10);
});
button100.addEventListener("click", () => {
addStatLevel(100);
});
button1000.addEventListener("click", () => {
addStatLevel(1000);
});