-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstats.html
More file actions
62 lines (52 loc) · 1.54 KB
/
Copy pathstats.html
File metadata and controls
62 lines (52 loc) · 1.54 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
<!DOCTYPE html>
<html>
<head>
<title>Monthly Page Loads</title>
</head>
<body>
<h1>Monthly Page Loads</h1>
<div id="results"></div>
<script>
async function getMonthStats(year, month) {
const namespace = "andrej0909";
const baseKey = "dutyrestcalculator-";
const daysInMonth = new Date(year, month, 0).getDate();
const resultsDiv = document.getElementById("results");
resultsDiv.innerHTML = "Loading...";
const results = [];
for (let day = 1; day <= daysInMonth; day++) {
const date = new Date(year, month - 1, day);
const dateStr = date.toISOString().slice(0, 10);
try {
const res = await fetch(
`https://api.countapi.xyz/get/${namespace}/${baseKey}${dateStr}`
);
const data = await res.json();
results.push({
date: dateStr,
value: data.value || 0
});
} catch {
results.push({
date: dateStr,
value: 0
});
}
}
renderTable(results);
}
function renderTable(data) {
const resultsDiv = document.getElementById("results");
let html = "<table border='1'><tr><th>Date</th><th>Loads</th></tr>";
data.forEach(row => {
html += `<tr><td>${row.date}</td><td>${row.value}</td></tr>`;
});
html += "</table>";
resultsDiv.innerHTML = html;
}
// automatikusan aktuális hónap
const now = new Date();
getMonthStats(now.getFullYear(), now.getMonth() + 1);
</script>
</body>
</html>