Skip to content

lightweight, client-only calendar web application. All data persists in the URL hash for instant sharing, No backend required. Optional AES-GCM password protection keeps shared links locked without a server

JavaScript

feat: Implement time grid rendering with event slotting to correctly display event durations and overlaps.

Supun Lakmald787bb402823
diff --git a/modules/calendarRender.js b/modules/calendarRender.js
index 143e971..4558325 100644
--- a/modules/calendarRender.js
+++ b/modules/calendarRender.js
@@ -347,6 +347,33 @@ export function renderTimeGrid({ container, dates, occurrences, onSelectDay, onE
dayWrapper.appendChild(chip);
});
});
+
+ // 4. Current Time Indicator
+ const now = new Date();
+ const todayKey = formatDateKey(now);
+ const currentMinutes = now.getHours() * 60 + now.getMinutes();
+
+ dates.forEach((date, i) => {
+ if (formatDateKey(date) === todayKey) {
+ const indicator = document.createElement("div");
+ indicator.className = "time-indicator";
+
+ // grid-row: minute + 2 (header is row 1)
+ const row = 2 + currentMinutes;
+ indicator.style.gridRow = `${row}`;
+ indicator.style.gridColumn = `${i + 2}`;
+
+ const line = document.createElement("div");
+ line.className = "time-indicator-line";
+ indicator.appendChild(line);
+
+ const circle = document.createElement("div");
+ circle.className = "time-indicator-circle";
+ indicator.appendChild(circle);
+
+ container.appendChild(indicator);
+ }
+ });
}
export function renderYearView({ container, year, eventsByDay, selectedDate, weekStartsOnMonday, onSelectDay }) {
diff --git a/script.js b/script.js
index 0fd76c0..6c1be82 100644
--- a/script.js
+++ b/script.js
@@ -599,7 +599,11 @@ function initTimezones() {
const delay = (60 - now.getSeconds()) * 1000;
window.setTimeout(() => {
renderTimezones();
- timezoneTimer = window.setInterval(renderTimezones, TIMEZONE_UPDATE_INTERVAL_MS);
+ render(); // Update time indicator
+ timezoneTimer = window.setInterval(() => {
+ renderTimezones();
+ render(); // Update time indicator
+ }, TIMEZONE_UPDATE_INTERVAL_MS);
}, delay);
}
diff --git a/styles.css b/styles.css
index 759a7fd..06f4a12 100644
--- a/styles.css
+++ b/styles.css
@@ -909,6 +909,38 @@ body[data-theme="dark"] .time-event:hover {
background: var(--bg);
}
+.time-indicator {
+ position: relative;
+ z-index: 15;
+ pointer-events: none;
+ display: flex;
+ align-items: center;
+ height: 0;
+}
+
+.time-indicator-line {
+ flex: 1;
+ height: 2px;
+ background: var(--focus-urgent);
+ box-shadow: 0 0 4px rgba(239, 68, 68, 0.4);
+}
+
+.time-indicator-circle {
+ width: 10px;
+ height: 10px;
+ background: var(--focus-urgent);
+ border-radius: 50%;
+ position: absolute;
+ left: -2px;
+ box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
+}
+
+body[data-theme="dark"] .time-indicator-line,
+body[data-theme="dark"] .time-indicator-circle {
+ background: #ff5252;
+ box-shadow: 0 0 8px rgba(255, 82, 82, 0.5);
+}
+
.mini-month {
border: 1px solid var(--border);
background: var(--panel);