-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhome.html
More file actions
63 lines (59 loc) · 1.49 KB
/
Copy pathhome.html
File metadata and controls
63 lines (59 loc) · 1.49 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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Visitor Counter</title>
<style>
body { font-family: "Nunito", sans-serif; padding: 40px; }
#count { font-size: 26px; margin-top: 20px; }
</style>
</head>
<!-- Visitor counter box -->
<div id="visitor-counter"></div>
<style>
#visitor-counter {
position: fixed;
bottom: 20px;
right: 22px;
background: #008653;
color: rgba(255, 255, 255, 0.904);
font-size: 10px;
padding: 6px 10px;
border-radius: 6px;
font-family: "Nunito", sans-serif;
z-index: 9999;
}
</style>
<script>
async function showVisitorCount() {
try {
const res = await fetch('/api/visit'); // call your server API
const data = await res.json();
document.getElementById('visitor-counter').innerText =
'Visitors: ' + data.count;
} catch (e) {
document.getElementById('visitor-counter').innerText =
'Visitors: error';
console.error(e);
}
}
showVisitorCount(); // run immediately on page load
</script>
<body>
<script>
// 🔹 AUTO count when page loads
async function countVisit() {
try {
const res = await fetch('/visit');
const data = await res.json();
document.getElementById('count').innerText =
'Total visitors: ' + data.count;
} catch {
document.getElementById('count').innerText =
'Error loading visitor count';
}
}
countVisit(); // run immediately on page load
</script>
</body>
</html>