Delay initialization until DOM ready

This commit is contained in:
Kiyomichi Kosaka 2025-06-15 00:40:50 +02:00
parent 400e4144ec
commit 552fdcc798

View File

@ -1,6 +1,13 @@
// CoBiE Time System Implementation
// Using Unix TAI epoch (January 1, 1970, 00:00:00 TAI)
// Note: TAI differs from UTC by leap seconds (37 seconds as of 2025)
(function() {
if (!window.Cobie) {
console.error('cobie.js not loaded');
return;
}
const {
COBIE_EPOCH,
COBIE_UNITS,
@ -794,6 +801,7 @@ function commitInput() {
span.addEventListener('click', enterEdit);
}
function init() {
// Timezone change handler
document.getElementById('timezone').addEventListener('change', (e) => {
currentTimezone = e.target.value;
@ -923,3 +931,15 @@ function wheelNavigate(e) {
}
document.addEventListener('wheel', wheelNavigate);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
window.navigatePeriod = navigatePeriod;
window.goToNow = goToNow;
})();