-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
64 lines (55 loc) · 1.79 KB
/
index.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="index.css">
<link rel="shortcut icon" href="icon.ico" type="image/x-icon">
<title>Click Clack</title>
</head>
<body>
<div class="main">
<div id="cli-cla" class="elements"><span id="click">Click</span> <span id="clack">Clack</span></div>
<span class="elements" id="count" style="opacity: 0.4;">Counter: 0</span>
<button class="elements" id="btn">Tap this</button>
</div>
<span style="opacity: 0.2;">Created by Levorin</span>
</body>
<script>
const button = document.getElementById("btn");
const clickTag = document.getElementById("click");
const clackTag = document.getElementById("clack");
const countText = document.getElementById("count");
let isClick = true;
let counter = localStorage.getItem("counter");
if (counter == null){
counter = 0;
}
countText.innerText = "Counter: " + counter;
clackTag.style.opacity = 0.3;
function countCount(event)
{
isClick = !isClick;
counter++;
countText.innerText = "Counter: " + counter;
localStorage.setItem("counter", counter);
if (isClick)
{
clackTag.style.opacity = 0.3;
clickTag.style.opacity = 1;
}
else
{
clackTag.style.opacity = 1;
clickTag.style.opacity = 0.3;
}
}
button.addEventListener("click", countCount);
countText.addEventListener("click", (event) => {
counter = 0;
localStorage.setItem("counter", 0);
countText.innerText = "Counter: " + counter;
})
</script>
</html>