Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
95 lines (82 loc) · 3.73 KB
/
Copy pathindex.html
File metadata and controls
95 lines (82 loc) · 3.73 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Lukashian Calendar</title>
</head>
<body>
<h1>The Lukashian Calendar</h1>
<h2>Lite JS implementation</h2>
<div>
<label>Start Date:</label>
<input type="date" id="startDate">
<label>Number of Days:</label>
<input type="number" id="numDays" value="30">
<button id="precomputeBtn">Precompute</button>
</div>
<div id="datetime"></div>
<script src="lukashianShared.js"></script>
<script src="lukashianPrecompute.js"></script>
<script src="lukashianExecute.js"></script>
<script>
// Set default start date to 2 days ago
const twoDaysAgo = new Date(Date.now() - 2 * 86400000);
document.getElementById('startDate').value = twoDaysAgo.toISOString().split('T')[0];
let officialData = null;
let prevLocal = '';
let isFetching = false;
async function loadOfficialData() {
try {
const proxyUrl = 'https://corsproxy.io/?' + encodeURIComponent('https://www.lukashian.org/clockinfo');
const response = await fetch(proxyUrl);
if (!response.ok) throw new Error("Failed to fetch official data");
officialData = await response.json();
} catch (e) {
console.warn("Failed to load official data:", e.message);
}
}
loadData().then(() => {
return loadOfficialData();
}).then(() => {
updateTime();
setInterval(updateTime, 100000);
});
async function updateTime() {
const now = Date.now();
const utcDate = new Date(now).toUTCString();
const lukashian = getLukashianDatetime(now);
const currentLocal = lukashian.formattedString;
if (currentLocal !== prevLocal && !isFetching) {
isFetching = true;
loadOfficialData().then(() => {
isFetching = false;
});
}
prevLocal = currentLocal;
const agree = officialData && officialData.currentBeeps == lukashian.beep && officialData.currentDay == lukashian.day && officialData.currentYear == lukashian.year;
document.getElementById('datetime').innerHTML = `
<p><strong>UTC:</strong> ${utcDate}</p>
<p><strong>Official Lukashian:</strong> ${officialData ? `${officialData.currentBeeps} ${officialData.currentDay}-${officialData.currentYear}` : 'Loading...'}</p>
<p><strong>Local Lukashian:</strong> ${lukashian.formattedString}${agree ? ' <span style="color: green;">✓</span>' : ' <span style="color: red;">✗</span>'}</p>
<p><strong>Iteration Count:</strong> ${lukashian.iterationCount}</p>
`;
}
document.getElementById('precomputeBtn').addEventListener('click', () => {
const startDate = document.getElementById('startDate').value;
const numDays = parseInt(document.getElementById('numDays').value);
const unixStart = Date.parse(`${startDate}T00:00:00Z`);
const unixEnd = unixStart + numDays * 86400000 - 1; // Cover full days
const data = precompute(unixStart, unixEnd);
const json = JSON.stringify(data, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'lukashian_data.json';
a.click();
URL.revokeObjectURL(url);
});
</script>
</body>
</html>