-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
74 lines (64 loc) · 1.83 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
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<title>Tweeter Scroll Counter</title>
<style>
body {
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}
#container {
text-align: center;
}
#counter {
font-size: 24px;
margin-bottom: 20px;
}
button {
padding: 15px 30px;
font-size: 20px;
}
</style>
</head>
<body>
<div id="container">
<h1>Tweeter Scroll Counter</h1>
<p id="currentDate"></p>
<p id="counter">600</p>
<button onclick="decrementCounter()">Decrement</button>
<button onclick="displayCurrentDate()">Show Current Date</button>
</div>
<script>
// Scroll counter
window.addEventListener('scroll', function() {
var windowHeight = window.innerHeight;
var documentHeight = document.documentElement.scrollHeight;
var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop;
if (documentHeight - scrollTop <= windowHeight) {
incrementCounter();
}
});
function incrementCounter() {
var counterElement = document.getElementById('counter');
var currentCount = parseInt(counterElement.innerText);
counterElement.innerText = currentCount + 1;
}
function decrementCounter() {
var counterElement = document.getElementById('counter');
var currentCount = parseInt(counterElement.innerText);
if (currentCount > 0) {
counterElement.innerText = currentCount - 1;
}
}
// Display current date
function displayCurrentDate() {
var currentDateElement = document.getElementById('currentDate');
var currentDate = new Date().toLocaleDateString();
currentDateElement.innerText = currentDate;
}
</script>
</body>
</html>