-
Notifications
You must be signed in to change notification settings - Fork 0
/
clickerScript.js
58 lines (43 loc) · 1.48 KB
/
clickerScript.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
document.addEventListener("DOMContentLoaded", () => {
//MAIN
const buttonClicker = document.querySelector(".clicker-button");
const generatedNumber = document.querySelector(".generated-number");
//const resetClicker = document.querySelector(".reset-button");
let increment = 1;
let bigNumber = 0;
if (localStorage.getItem("bigNumber") === null) {
localStorage.setItem("bigNumber", bigNumber)
}else{
bigNumber = parseFloat(localStorage.getItem("bigNumber"));
generatedNumber.innerHTML = parseFloat(bigNumber);
}
const animatedClick = () => {
buttonClicker.classList.add("clicker-button-shadow");
setTimeout(() => {
cancelAnimatedClick()
}, 100);
}
const cancelAnimatedClick = () => {
buttonClicker.classList.remove("clicker-button-shadow")
}
buttonClicker.addEventListener('click', () => {
animatedClick();
bigNumber += increment;
localStorage.setItem("bigNumber", bigNumber);
generatedNumber.innerHTML = bigNumber;
})
/*
resetClicker.addEventListener("click", () => {
bigNumber = 0;
generatedNumber.innerHTML = bigNumber;
})
const upgradeButton = document.querySelector(".upgrade-button")
upgradeButton.addEventListener("click", () => {
if(bigNumber >= 20){
increment++;
bigNumber -= 20;
generatedNumber.innerHTML = bigNumber;
}
})
*/
});