Add daily Sleep event and restore detail navigation

This commit is contained in:
Kiyomichi Kosaka
2025-06-20 00:54:28 +02:00
parent 13dd3ec664
commit c991a58296
4 changed files with 46 additions and 4 deletions
+31 -1
View File
@@ -42,6 +42,7 @@ let compareManualMode = false;
let compareCobiets = 0;
let updateInterval;
let lastRenderedEonstrip = null;
let currentDetailCob = null;
function fmt(d, o) {
// shift if TAI, then format
@@ -685,6 +686,12 @@ function showEonstripDetails(index, startCobiets, opts) {
}
function showEonstripDetail(index, startCob) {
if (startCob === undefined) {
startCob = index;
const bdTmp = breakdownNonNeg(Math.abs(startCob));
index = bdTmp.eonstrip;
}
currentDetailCob = startCob;
const calendar = document.getElementById('calendarView');
const detail = document.getElementById('eonstripDetailView');
const timeline = document.getElementById('detailTimeline');
@@ -709,7 +716,7 @@ function showEonstripDetail(index, startCob) {
const offsetStart = ((startCob % COBIE_UNITS.cosmocycle) + COBIE_UNITS.cosmocycle) % COBIE_UNITS.cosmocycle;
const events = [];
window.SPECIAL_EVENTS.forEach(ev => {
const evCob = parseCobiets(ev.cobie);
const evCob = parseCobiets(ev.cobie || ev.start);
if (evCob === null) return;
const evOffset = ((evCob % COBIE_UNITS.cosmocycle) + COBIE_UNITS.cosmocycle) % COBIE_UNITS.cosmocycle;
if (evOffset >= offsetStart && evOffset < offsetStart + COBIE_UNITS.eonstrip) {
@@ -746,6 +753,22 @@ function showEonstripDetail(index, startCob) {
}
}
function detailPrev() {
if (currentDetailCob === null) return;
showEonstripDetail(currentDetailCob - COBIE_UNITS.eonstrip);
}
function detailNext() {
if (currentDetailCob === null) return;
showEonstripDetail(currentDetailCob + COBIE_UNITS.eonstrip);
}
function detailNow() {
const now = toCobiets(new Date());
const start = now - (now % COBIE_UNITS.eonstrip);
showEonstripDetail(start);
}
function getStep(mods) {
// base step = 1 megasequence
let step = 1;
@@ -904,7 +927,11 @@ if (matchingOption) {
document.getElementById('backToCalendar').addEventListener('click', () => {
document.getElementById('eonstripDetailView').style.display = 'none';
document.getElementById('calendarView').style.display = 'block';
currentDetailCob = null;
});
document.getElementById('detailPrev').addEventListener('click', detailPrev);
document.getElementById('detailNext').addEventListener('click', detailNext);
document.getElementById('detailNow').addEventListener('click', detailNow);
updateCurrentTime();
updateCalendar();
@@ -1029,4 +1056,7 @@ if (document.readyState === 'loading') {
window.navigatePeriod = navigatePeriod;
window.goToNow = goToNow;
window.detailPrev = detailPrev;
window.detailNext = detailNext;
window.detailNow = detailNow;
})();