Compare commits

...

2 Commits

Author SHA1 Message Date
Kiyomichi Kosaka aa2cca60b1 Merge pull request #34 from ok2/codex/synchronize-analog-clock-with-current-cobie-time 2025-06-15 10:07:09 +02:00
Kiyomichi Kosaka 3a63ced4e6 Sync analog clock with manual mode 2025-06-15 10:06:53 +02:00
2 changed files with 32 additions and 5 deletions
+23 -5
View File
@@ -71,9 +71,7 @@
lastAngles[id] = angle;
}
function updateClock() {
const now = new Date();
const cob = toCobiets(now);
function renderClock(cob) {
// Use fractional progress within each unit so angles stay small
const xf = (cob % COBIE_UNITS.quantic) / COBIE_UNITS.quantic;
const qf = (cob % COBIE_UNITS.chronon) / COBIE_UNITS.chronon;
@@ -87,10 +85,26 @@
rotateHand('handMegasequence', mf * 360);
}
function updateClock() {
renderClock(toCobiets(new Date()));
}
let intervalId = null;
function startClock() {
clearInterval(intervalId);
updateClock();
intervalId = setInterval(updateClock, 1000);
}
function showTime(cob) {
clearInterval(intervalId);
renderClock(cob);
}
function initClock() {
placeMarkers();
updateClock();
setInterval(updateClock, 1000);
startClock();
const clk = document.getElementById('clock');
if (clk) {
clk.addEventListener('click', () => {
@@ -100,6 +114,10 @@
});
}
window.addEventListener('resize', placeMarkers);
window.CobieClock = {
start: startClock,
showTime
};
}
if (document.readyState === 'loading') {
+9
View File
@@ -640,6 +640,9 @@ function updateCalendar() {
clearInterval(updateInterval);
document.querySelector('.current-time').classList.add('manual');
updateCurrentTime();
if (window.CobieClock) {
window.CobieClock.showTime(manualCobiets);
}
});
})(cellCob + currentTime);
}
@@ -737,6 +740,9 @@ function goToNow() {
clearInterval(updateInterval);
updateInterval = setInterval(updateCurrentTime, 1000);
document.querySelector('.current-time').classList.remove('manual');
if (window.CobieClock) {
window.CobieClock.start();
}
}
function enterEdit() {
@@ -794,6 +800,9 @@ function commitInput() {
updateCurrentTime();
updateCalendar();
document.querySelector('.current-time').classList.add('manual');
if (window.CobieClock) {
window.CobieClock.showTime(manualCobiets);
}
}
// swap elements