Sync analog clock with manual mode
This commit is contained in:
parent
f0ce3b29d6
commit
3a63ced4e6
28
clock.js
28
clock.js
@ -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') {
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user