-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuttonclicker.html
More file actions
71 lines (68 loc) · 2.37 KB
/
buttonclicker.html
File metadata and controls
71 lines (68 loc) · 2.37 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Fakemon's Website | Button Clicker</title>
<script>
let clicks = 0;
let changeLsSaveNotice = [false, null];
try {
clicks = parseInt(localStorage.getItem("clicks")) || 0; // Click count
changeLsSaveNotice = [false, null];
} catch (e) {
clicks = 0;
changeLsSaveNotice = [true, "unsupported"];
console.error(e);
}
let btn; // Button elem, to be defined later
document.addEventListener("DOMContentLoaded", () => {
localStorage.setItem("clicks", clicks);
btn = document.getElementById("clickme");
let lsSaveNotice = document.getElementById("lsSaveNotice");
if (changeLsSaveNotice[0]) {
switch (changeLsSaveNotice[1]) {
case "unsupported":
lsSaveNotice.innerHTML =
"This game would normally use local storage to save your click count, but, for some reason, it's unavailable.<br>Your browser may not have it, or you're in incognito/private browsing mode.<br>If you're a nerd, you can check the console for the error.";
}
}
if (clicks != 0) {
btn.innerHTML = `Clicks: ${clicks}`;
}
});
function btnClicked() {
clicks++;
btn.innerHTML = `Clicks: ${clicks}`;
localStorage.setItem("clicks", clicks);
}
</script>
<script src="UniversalElements.js">
// Script for automatically filling element data across pages (this is an anti-React household)
</script>
</head>
<body>
<div class="main">
<div class="navbar">
<!--UniversalElements.js will load elements here-->
</div>
<img
src="https://uploads.scratch.mit.edu/get_image/user/117698316_99x99.png"
class="pfp"
/>
<h1>Button Clicker</h1>
<i>The Ultimate Game to Cure your Boredom!</i>
<br />
- Scratch_Fakemon
<br />
<button id="clickme" onclick="btnClicked()">Click Me!</button>
<small id="lsSaveNotice"
>Your progress will be saved. Please note that your browser may clear
local storage data automatically.</small
>
<hr class="but" />
<div class="links">
<!--Also UniversalElements.js-->
</div>
</div>
</body>
</html>