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 responsive mobile UI with a hamburger menu and full-screen side panels.

Supun Lakmal49a056cae7ed
diff --git a/index.html b/index.html
index bce2376..ed2a9f4 100644
--- a/index.html
+++ b/index.html
@@ -86,22 +86,34 @@
<button id="today-btn" type="button">Today</button>
<button id="next-month" type="button" aria-label="Next month">Next</button>
</div>
- <div class="view-toggle" role="tablist" aria-label="Calendar view">
- <button type="button" data-view="day" role="tab" aria-selected="false">Day</button>
- <button type="button" data-view="week" role="tab" aria-selected="false">Week</button>
- <button type="button" data-view="month" role="tab" aria-selected="true">Month</button>
- <button type="button" data-view="year" role="tab" aria-selected="false">Year</button>
- <button type="button" data-view="agenda" role="tab" aria-selected="false">Agenda</button>
+
+ <div id="mobile-menu-toggle" class="mobile-only">
+ <button id="hamburger-btn" type="button" aria-label="Menu" class="icon-btn">
+ <i class="fa-solid fa-bars"></i>
+ </button>
+ </div>
+
+ <div id="secondary-actions" class="secondary-actions">
+ <div class="view-toggle" role="tablist">
+ <button data-view="day" role="tab" aria-selected="false">Day</button>
+ <button data-view="week" role="tab" aria-selected="false">Week</button>
+ <button data-view="month" role="tab" aria-selected="true" class="active">Month</button>
+ <button data-view="year" role="tab" aria-selected="false">Year</button>
+ <button data-view="agenda" role="tab" aria-selected="false">Agenda</button>
+ </div>
+ <button id="focus-btn" type="button">Focus</button>
+
+ <div class="action-divider desktop-only"></div>
+
+ <button id="add-event" class="primary" type="button">Add event</button>
+ <button id="copy-link" type="button">Copy link</button>
+ <button id="share-qr" type="button">Share QR</button>
+ <button id="lock-btn" type="button">Lock</button>
+ <a class="action-link" href="https://github.com/supunlakmal/hash-calendar" target="_blank" rel="noreferrer">
+ <i class="fa-brands fa-github" aria-hidden="true"></i>
+ <span>GitHub</span>
+ </a>
</div>
- <button id="focus-btn" type="button" class="ghost">Focus</button>
- <button id="add-event" type="button" class="primary">Add event</button>
- <button id="copy-link" type="button">Copy link</button>
- <button id="share-qr" type="button">Share QR</button>
- <button id="lock-btn" type="button">Lock</button>
- <a class="action-link" href="https://github.com/supunlakmal/hash-calendar" target="_blank" rel="noreferrer">
- <i class="fa-brands fa-github" aria-hidden="true"></i>
- <span>GitHub</span>
- </a>
</div>
</header>
@@ -120,8 +132,12 @@
<div>
<h2 id="month-label" class="month-label">Month 2026</h2>
<div class="panel-actions">
- <button id="weekstart-toggle" type="button" class="ghost">Week starts Sunday</button>
- <button id="theme-toggle" type="button" class="ghost">Theme: Light</button>
+ <button id="mobile-sidebar-toggle" class="mobile-only" type="button">
+ <i class="fa-solid fa-list-ul"></i>
+ <span>Details</span>
+ </button>
+ <button id="weekstart-toggle" type="button">Week starts Sunday</button>
+ <button id="theme-toggle" type="button">Theme: Light</button>
</div>
</div>
</div>
@@ -137,6 +153,9 @@
</section>
<aside class="side-panel">
+ <button id="side-panel-close" class="side-close mobile-only" type="button" aria-label="Close details">
+ <i class="fa-solid fa-xmark"></i>
+ </button>
<div class="side-card">
<h3 id="selected-date-label" class="side-title">Selected day</h3>
<div id="event-list" class="event-list"></div>
@@ -165,6 +184,9 @@
</aside>
<aside id="timezone-ruler" class="tz-sidebar">
+ <button id="tz-sidebar-close" class="side-close mobile-only" type="button" aria-label="Close clock">
+ <i class="fa-solid fa-xmark"></i>
+ </button>
<div class="tz-header">
<div>
<h4 class="tz-title">World Clock</h4>
@@ -349,4 +371,4 @@
<script type="module" src="script.js"></script>
</body>
-</html>
+</html>
\ No newline at end of file
diff --git a/script.js b/script.js
index ad77770..813a42c 100644
--- a/script.js
+++ b/script.js
@@ -1,14 +1,14 @@
-import { readStateFromHash, writeStateToHash, isEncryptedHash, clearHash } from "./modules/hashcalUrlManager.js";
-import { expandEvents } from "./modules/recurrenceEngine.js";
-import { renderAgendaView } from "./modules/agendaRender.js";
-import { FocusMode } from "./modules/focusMode.js";
-import { initQRCodeManager } from "./modules/qrCodeManager.js";
-import { initCountdownWidget } from "./modules/countdownManager.js";
-import { AVAILABLE_ZONES, getZoneInfo, isValidZone } from "./modules/timezoneManager.js";
-import {
- formatDateKey,
- getMonthGridRange,
- getWeekRange,
+import { readStateFromHash, writeStateToHash, isEncryptedHash, clearHash } from "./modules/hashcalUrlManager.js";
+import { expandEvents } from "./modules/recurrenceEngine.js";
+import { renderAgendaView } from "./modules/agendaRender.js";
+import { FocusMode } from "./modules/focusMode.js";
+import { initQRCodeManager } from "./modules/qrCodeManager.js";
+import { initCountdownWidget } from "./modules/countdownManager.js";
+import { AVAILABLE_ZONES, getZoneInfo, isValidZone } from "./modules/timezoneManager.js";
+import {
+ formatDateKey,
+ getMonthGridRange,
+ getWeekRange,
renderCalendar,
renderTimeGrid,
renderWeekdayHeaders,
@@ -16,42 +16,42 @@ import {
} from "./modules/calendarRender.js";
import { parseIcs } from "./modules/icsImporter.js";
-const DEFAULT_COLORS = ["#ff6b6b", "#ffd43b", "#4dabf7", "#63e6be", "#9775fa"];
-const DEFAULT_VIEW = "month";
-const VALID_VIEWS = new Set(["day", "week", "month", "year", "agenda"]);
-const DEFAULT_STATE = {
- t: "hash-calendar",
- c: DEFAULT_COLORS,
- e: [],
- s: {
- d: 0,
- m: 0,
- v: DEFAULT_VIEW,
- },
- timezones: [],
-};
-
-const DEBOUNCE_MS = 500;
-const MAX_TITLE_LENGTH = 60;
-const MAX_TZ_RESULTS = 12;
-const TZ_EMPTY_MESSAGE = "No matches yet. Try a city, region, or UTC+5:30.";
-const MOBILE_WARNING_QUERY = "(max-width: 1024px)";
-const MOBILE_WARNING_KEY = "hashcal.mobileWarningDismissed";
+const DEFAULT_COLORS = ["#ff6b6b", "#ffd43b", "#4dabf7", "#63e6be", "#9775fa"];
+const DEFAULT_VIEW = "month";
+const VALID_VIEWS = new Set(["day", "week", "month", "year", "agenda"]);
+const DEFAULT_STATE = {
+ t: "hash-calendar",
+ c: DEFAULT_COLORS,
+ e: [],
+ s: {
+ d: 0,
+ m: 0,
+ v: DEFAULT_VIEW,
+ },
+ timezones: [],
+};
+
+const DEBOUNCE_MS = 500;
+const MAX_TITLE_LENGTH = 60;
+const MAX_TZ_RESULTS = 12;
+const TZ_EMPTY_MESSAGE = "No matches yet. Try a city, region, or UTC+5:30.";
+const MOBILE_WARNING_QUERY = "(max-width: 1024px)";
+const MOBILE_WARNING_KEY = "hashcal.mobileWarningDismissed";
let state = cloneState(DEFAULT_STATE);
let viewDate = startOfDay(new Date());
let selectedDate = startOfDay(new Date());
-let currentView = DEFAULT_VIEW;
+let currentView = DEFAULT_VIEW;
let password = null;
-let lockState = { encrypted: false, unlocked: true };
-let saveTimer = null;
-let occurrencesByDay = new Map();
-let editingIndex = null;
-let passwordResolver = null;
-let passwordMode = "unlock";
-let focusMode = null;
-let qrManager = null;
-let timezoneTimer = null;
+let lockState = { encrypted: false, unlocked: true };
+let saveTimer = null;
+let occurrencesByDay = new Map();
+let editingIndex = null;
+let passwordResolver = null;
+let passwordMode = "unlock";
+let focusMode = null;
+let qrManager = null;
+let timezoneTimer = null;
const ui = {};
@@ -105,39 +105,39 @@ function formatRangeLabel(start, end) {
})}`;
}
-function formatTime(date) {
- return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
-}
-
-function getStoredView(view) {
- return VALID_VIEWS.has(view) ? view : DEFAULT_VIEW;
-}
-
-function applyStoredView() {
- const stored = state && state.s ? state.s.v : null;
- currentView = getStoredView(stored);
- if (state && state.s) state.s.v = currentView;
- updateViewButtons();
-}
-
-function normalizeTimezones(rawZones) {
- if (!Array.isArray(rawZones)) return [];
- const zones = [];
- const seen = new Set();
- rawZones.forEach((zone) => {
- if (typeof zone !== "string") return;
- const trimmed = zone.trim();
- if (!trimmed || seen.has(trimmed)) return;
- if (!isValidZone(trimmed)) return;
- seen.add(trimmed);
- zones.push(trimmed);
- });
- return zones;
-}
-
-function normalizeState(raw) {
- const next = cloneState(DEFAULT_STATE);
- if (!raw || typeof raw !== "object") return next;
+function formatTime(date) {
+ return date.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" });
+}
+
+function getStoredView(view) {
+ return VALID_VIEWS.has(view) ? view : DEFAULT_VIEW;
+}
+
+function applyStoredView() {
+ const stored = state && state.s ? state.s.v : null;
+ currentView = getStoredView(stored);
+ if (state && state.s) state.s.v = currentView;
+ updateViewButtons();
+}
+
+function normalizeTimezones(rawZones) {
+ if (!Array.isArray(rawZones)) return [];
+ const zones = [];
+ const seen = new Set();
+ rawZones.forEach((zone) => {
+ if (typeof zone !== "string") return;
+ const trimmed = zone.trim();
+ if (!trimmed || seen.has(trimmed)) return;
+ if (!isValidZone(trimmed)) return;
+ seen.add(trimmed);
+ zones.push(trimmed);
+ });
+ return zones;
+}
+
+function normalizeState(raw) {
+ const next = cloneState(DEFAULT_STATE);
+ if (!raw || typeof raw !== "object") return next;
if (typeof raw.t === "string") {
next.t = raw.t.slice(0, MAX_TITLE_LENGTH);
@@ -174,34 +174,34 @@ function normalizeState(raw) {
.filter((entry) => Number.isFinite(entry[0]));
}
- if (raw.s && typeof raw.s === "object") {
- next.s.d = raw.s.d ? 1 : 0;
- next.s.m = raw.s.m ? 1 : 0;
- next.s.v = getStoredView(raw.s.v);
- }
-
- if (Array.isArray(raw.timezones) || Array.isArray(raw.z) || Array.isArray(raw.tz)) {
- const zones = Array.isArray(raw.timezones) ? raw.timezones : Array.isArray(raw.z) ? raw.z : raw.tz;
- next.timezones = normalizeTimezones(zones);
- }
-
- return next;
-}
-
-function cacheElements() {
- ui.mobileWarning = document.getElementById("mobile-warning");
- ui.mobileWarningDismiss = document.getElementById("mobile-warning-dismiss");
- ui.topbar = document.querySelector(".topbar");
- ui.titleInput = document.getElementById("calendar-title");
+ if (raw.s && typeof raw.s === "object") {
+ next.s.d = raw.s.d ? 1 : 0;
+ next.s.m = raw.s.m ? 1 : 0;
+ next.s.v = getStoredView(raw.s.v);
+ }
+
+ if (Array.isArray(raw.timezones) || Array.isArray(raw.z) || Array.isArray(raw.tz)) {
+ const zones = Array.isArray(raw.timezones) ? raw.timezones : Array.isArray(raw.z) ? raw.z : raw.tz;
+ next.timezones = normalizeTimezones(zones);
+ }
+
+ return next;
+}
+
+function cacheElements() {
+ ui.mobileWarning = document.getElementById("mobile-warning");
+ ui.mobileWarningDismiss = document.getElementById("mobile-warning-dismiss");
+ ui.topbar = document.querySelector(".topbar");
+ ui.titleInput = document.getElementById("calendar-title");
ui.prevMonth = document.getElementById("prev-month");
ui.nextMonth = document.getElementById("next-month");
- ui.todayBtn = document.getElementById("today-btn");
- ui.addEventBtn = document.getElementById("add-event");
- ui.copyLinkBtn = document.getElementById("copy-link");
- ui.shareQrBtn = document.getElementById("share-qr");
- ui.lockBtn = document.getElementById("lock-btn");
- ui.focusBtn = document.getElementById("focus-btn");
- ui.viewButtons = Array.from(document.querySelectorAll(".view-toggle button"));
+ ui.todayBtn = document.getElementById("today-btn");
+ ui.addEventBtn = document.getElementById("add-event");
+ ui.copyLinkBtn = document.getElementById("copy-link");
+ ui.shareQrBtn = document.getElementById("share-qr");
+ ui.lockBtn = document.getElementById("lock-btn");
+ ui.focusBtn = document.getElementById("focus-btn");
+ ui.viewButtons = Array.from(document.querySelectorAll(".view-toggle button"));
ui.weekstartToggle = document.getElementById("weekstart-toggle");
ui.themeToggle = document.getElementById("theme-toggle");
ui.monthLabel = document.getElementById("month-label");
@@ -250,359 +250,367 @@ function cacheElements() {
ui.jsonClose = document.getElementById("json-close");
ui.jsonHash = document.getElementById("json-hash");
ui.jsonOutput = document.getElementById("json-output");
- ui.jsonCopy = document.getElementById("json-copy");
- ui.jsonCopyHash = document.getElementById("json-copy-hash");
- ui.jsonDownload = document.getElementById("json-download");
-
- ui.toastContainer = document.getElementById("toast-container");
-
- ui.tzSidebar = document.getElementById("timezone-ruler");
- ui.tzList = document.getElementById("tz-list");
- ui.tzAddBtn = document.getElementById("add-tz-btn");
- ui.tzModal = document.getElementById("tz-modal");
- ui.tzSearch = document.getElementById("tz-search");
- ui.tzResults = document.getElementById("tz-results");
- ui.tzClose = document.getElementById("close-tz-modal");
- ui.tzEmpty = document.getElementById("tz-empty");
-}
-
-function showToast(message, type = "info") {
- if (!ui.toastContainer) return;
- const toast = document.createElement("div");
- toast.className = `toast ${type}`.trim();
- toast.textContent = message;
- ui.toastContainer.appendChild(toast);
- setTimeout(() => {
- toast.remove();
- }, 3200);
-}
-
-function isMobileViewport() {
- if (window.matchMedia) {
- return window.matchMedia(MOBILE_WARNING_QUERY).matches;
- }
- return window.innerWidth <= 720;
-}
-
-function getMobileWarningDismissed() {
- try {
- return window.localStorage.getItem(MOBILE_WARNING_KEY) === "1";
- } catch (error) {
- return false;
- }
-}
-
-function setMobileWarningDismissed() {
- try {
- window.localStorage.setItem(MOBILE_WARNING_KEY, "1");
- } catch (error) {
- // Ignore storage errors (private mode, blocked, etc.).
- }
-}
-
-function updateMobileWarningVisibility() {
- if (!ui.mobileWarning) return;
- const shouldShow = isMobileViewport() && !getMobileWarningDismissed();
- ui.mobileWarning.classList.toggle("hidden", !shouldShow);
-}
-
-function dismissMobileWarning() {
- setMobileWarningDismissed();
- if (ui.mobileWarning) ui.mobileWarning.classList.add("hidden");
-}
-
-function initMobileWarning() {
- if (!ui.mobileWarning) return;
- updateMobileWarningVisibility();
- window.addEventListener("resize", updateMobileWarningVisibility);
- if (!window.matchMedia) return;
- const mediaQuery = window.matchMedia(MOBILE_WARNING_QUERY);
- const handleChange = () => updateMobileWarningVisibility();
- if (mediaQuery.addEventListener) {
- mediaQuery.addEventListener("change", handleChange);
- } else if (mediaQuery.addListener) {
- mediaQuery.addListener(handleChange);
- }
-}
-
-function hasStoredData() {
- return (state.e && state.e.length) || (state.timezones && state.timezones.length);
-}
-
-function getLocalZone() {
- return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
-}
-
-function createTzCard(zoneId, isLocal) {
- const data = getZoneInfo(zoneId);
- const div = document.createElement("div");
- div.className = `tz-card${isLocal ? " is-local" : ""}`;
-
- div.innerHTML = `
- <div class="tz-name">
- <span class="tz-label">${data.name}</span>
- <span class="tz-offset">UTC${data.offset}</span>
- </div>
- <div class="tz-time">${data.time}</div>
- ${data.dayDiff ? `<div class="tz-diff">${data.dayDiff}</div>` : ""}
- ${!isLocal ? `<button class="tz-remove" type="button" data-zone="${data.fullZone}" aria-label="Remove timezone">x</button>` : ""}
- `;
-
- return div;
-}
-
-function renderTimezones() {
- if (!ui.tzList) return;
- ui.tzList.innerHTML = "";
-
- const localZone = getLocalZone();
- ui.tzList.appendChild(createTzCard(localZone, true));
-
- const zones = Array.isArray(state.timezones) ? state.timezones : [];
- let added = 0;
- const seen = new Set();
- zones.forEach((zone) => {
- if (zone === localZone) return;
- if (seen.has(zone)) return;
- if (!isValidZone(zone)) return;
- seen.add(zone);
- ui.tzList.appendChild(createTzCard(zone, false));
- added += 1;
- });
-
- if (!added) {
- const empty = document.createElement("p");
- empty.className = "tz-empty";
- empty.textContent = "Add a timezone to compare.";
- ui.tzList.appendChild(empty);
- }
-}
-
-function addTimezone(zoneStr) {
- if (!zoneStr || !isValidZone(zoneStr)) return;
- const localZone = getLocalZone();
- if (zoneStr === localZone) return;
- if (!Array.isArray(state.timezones)) state.timezones = [];
- if (state.timezones.includes(zoneStr)) return;
- state.timezones.push(zoneStr);
- scheduleSave();
- renderTimezones();
-}
-
-function removeTimezone(zoneStr) {
- if (!Array.isArray(state.timezones) || !zoneStr) return;
- state.timezones = state.timezones.filter((zone) => zone !== zoneStr);
- scheduleSave();
- renderTimezones();
-}
-
-function renderTzResults(results) {
- if (!ui.tzResults) return;
- ui.tzResults.innerHTML = "";
- results.forEach((zone) => {
- const li = document.createElement("li");
- const button = document.createElement("button");
- button.type = "button";
- button.className = "tz-result-btn";
- const info = getZoneInfo(zone);
- const name = document.createElement("span");
- name.className = "tz-result-name";
- name.textContent = zone;
- const offset = document.createElement("span");
- offset.className = "tz-result-offset";
- offset.textContent = `UTC${info.offset}`;
- button.append(name, offset);
- button.dataset.zone = zone;
- li.appendChild(button);
- ui.tzResults.appendChild(li);
- });
-}
-
-function parseOffsetSearchTerm(raw) {
- if (!raw) return null;
- let term = raw.toLowerCase().replace(/\s+/g, "");
- let hasPrefix = false;
- if (term.startsWith("utc")) {
- term = term.slice(3);
- hasPrefix = true;
- } else if (term.startsWith("gmt")) {
- term = term.slice(3);
- hasPrefix = true;
- }
- if (!term) return null;
-
- let sign = null;
- if (term.startsWith("+") || term.startsWith("-")) {
- sign = term[0];
- term = term.slice(1);
- }
-
- const hasSeparator = term.includes(":") || term.includes(".");
-
- let hours = null;
- let minutes = null;
- let hasMinutes = false;
-
- if (hasSeparator) {
- const parts = term.split(/[:.]/);
- if (parts.length !== 2) return null;
- hours = Number(parts[0]);
- minutes = Number(parts[1]);
- hasMinutes = parts[1].length > 0;
- } else if (/^\d{1,2}$/.test(term)) {
- hours = Number(term);
- minutes = 0;
- } else if (/^\d{3,4}$/.test(term)) {
- const padded = term.padStart(4, "0");
- hours = Number(padded.slice(0, 2));
- minutes = Number(padded.slice(2));
- hasMinutes = true;
- } else {
- return null;
- }
-
- if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return null;
- if (hours > 14 || minutes > 59) return null;
-
- const signChar = sign || "+";
- const value = `${signChar}${hours}:${String(minutes).padStart(2, "0")}`;
- return { value, sign, hours, minutes, hasMinutes };
-}
-
-function handleTzSearch() {
- if (!ui.tzSearch) return;
- const term = ui.tzSearch.value.trim().toLowerCase();
- const offsetQuery = parseOffsetSearchTerm(term);
- if (!AVAILABLE_ZONES.length) {
- if (ui.tzEmpty) {
- ui.tzEmpty.textContent = "Timezone search isn't supported in this browser.";
- ui.tzEmpty.classList.remove("hidden");
- }
- renderTzResults([]);
- return;
- }
- if (term.length < 2 && !offsetQuery) {
- renderTzResults([]);
- if (ui.tzEmpty) ui.tzEmpty.classList.add("hidden");
- return;
- }
- const localZone = getLocalZone();
- const existing = new Set([localZone, ...(state.timezones || [])]);
- const matches = AVAILABLE_ZONES.filter((zone) => {
- if (existing.has(zone)) return false;
- const zoneLower = zone.toLowerCase();
- if (zoneLower.includes(term)) return true;
- if (offsetQuery) {
- const zoneOffset = getZoneInfo(zone).offset;
- const normalized = `${offsetQuery.hours}:${String(offsetQuery.minutes).padStart(2, "0")}`;
- if (offsetQuery.hasMinutes) {
- if (offsetQuery.sign) {
- return zoneOffset === `${offsetQuery.sign}${normalized}`;
- }
- return zoneOffset === `+${normalized}` || zoneOffset === `-${normalized}`;
- }
- if (offsetQuery.sign) {
- return zoneOffset.startsWith(`${offsetQuery.sign}${offsetQuery.hours}`);
- }
- return zoneOffset.startsWith(`+${offsetQuery.hours}`) || zoneOffset.startsWith(`-${offsetQuery.hours}`);
- }
- return false;
- }).slice(0, MAX_TZ_RESULTS);
- renderTzResults(matches);
- if (ui.tzEmpty) {
- ui.tzEmpty.textContent = TZ_EMPTY_MESSAGE;
- ui.tzEmpty.classList.toggle("hidden", matches.length > 0);
- }
-}
-
-function openTzModal() {
- if (!ui.tzModal) return;
- if (ui.tzSearch) ui.tzSearch.value = "";
- if (ui.tzEmpty) {
- ui.tzEmpty.textContent = TZ_EMPTY_MESSAGE;
- ui.tzEmpty.classList.add("hidden");
- }
- renderTzResults([]);
- handleTzSearch();
- if (typeof ui.tzModal.showModal === "function") {
- ui.tzModal.showModal();
- } else {
- ui.tzModal.setAttribute("open", "");
- }
- if (ui.tzSearch) ui.tzSearch.focus();
-}
-
-function closeTzModal() {
- if (!ui.tzModal) return;
- if (typeof ui.tzModal.close === "function") {
- ui.tzModal.close();
- } else {
- ui.tzModal.removeAttribute("open");
- }
-}
-
-function handleTzResultsClick(event) {
- const button = event.target.closest("button[data-zone]");
- if (!button) return;
- const zone = button.dataset.zone;
- addTimezone(zone);
- closeTzModal();
-}
-
-function handleTzListClick(event) {
- const button = event.target.closest("button[data-zone]");
- if (!button) return;
- removeTimezone(button.dataset.zone);
-}
-
-function initTimezones() {
- if (!ui.tzList) return;
- renderTimezones();
- if (timezoneTimer) {
- window.clearInterval(timezoneTimer);
- timezoneTimer = null;
- }
- const now = new Date();
- const delay = (60 - now.getSeconds()) * 1000;
- window.setTimeout(() => {
- renderTimezones();
- timezoneTimer = window.setInterval(renderTimezones, 60000);
- }, delay);
-}
-
-async function persistStateToHash() {
- if (lockState.encrypted && !lockState.unlocked) return;
- if (!hasStoredData()) {
- if (window.location.hash) clearHash();
- updateUrlLength();
- if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
- updateJsonModal();
- }
- return;
- }
- await writeStateToHash(state, password);
- updateUrlLength();
- if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
- updateJsonModal();
- }
-}
-
-function scheduleSave() {
- if (lockState.encrypted && !lockState.unlocked) return;
- if (!hasStoredData()) {
- if (saveTimer) {
- window.clearTimeout(saveTimer);
- saveTimer = null;
- }
- persistStateToHash();
- return;
- }
- if (saveTimer) window.clearTimeout(saveTimer);
- saveTimer = window.setTimeout(() => {
- saveTimer = null;
- persistStateToHash();
- }, DEBOUNCE_MS);
-}
+ ui.jsonCopy = document.getElementById("json-copy");
+ ui.jsonCopyHash = document.getElementById("json-copy-hash");
+ ui.jsonDownload = document.getElementById("json-download");
+
+ ui.toastContainer = document.getElementById("toast-container");
+
+ ui.tzSidebar = document.getElementById("timezone-ruler");
+ ui.tzList = document.getElementById("tz-list");
+ ui.tzAddBtn = document.getElementById("add-tz-btn");
+ ui.tzModal = document.getElementById("tz-modal");
+ ui.tzSearch = document.getElementById("tz-search");
+ ui.tzResults = document.getElementById("tz-results");
+ ui.tzClose = document.getElementById("close-tz-modal");
+ ui.tzEmpty = document.getElementById("tz-empty");
+
+ ui.hamburgerBtn = document.getElementById("hamburger-btn");
+ ui.secondaryActions = document.getElementById("secondary-actions");
+ ui.mobileSidebarToggle = document.getElementById("mobile-sidebar-toggle");
+ ui.sidePanel = document.querySelector(".side-panel");
+ ui.tzSidebar = document.getElementById("timezone-ruler");
+ ui.sidePanelClose = document.getElementById("side-panel-close");
+ ui.tzSidebarClose = document.getElementById("tz-sidebar-close");
+}
+
+function showToast(message, type = "info") {
+ if (!ui.toastContainer) return;
+ const toast = document.createElement("div");
+ toast.className = `toast ${type}`.trim();
+ toast.textContent = message;
+ ui.toastContainer.appendChild(toast);
+ setTimeout(() => {
+ toast.remove();
+ }, 3200);
+}
+
+function isMobileViewport() {
+ if (window.matchMedia) {
+ return window.matchMedia(MOBILE_WARNING_QUERY).matches;
+ }
+ return window.innerWidth <= 720;
+}
+
+function getMobileWarningDismissed() {
+ try {
+ return window.localStorage.getItem(MOBILE_WARNING_KEY) === "1";
+ } catch (error) {
+ return false;
+ }
+}
+
+function setMobileWarningDismissed() {
+ try {
+ window.localStorage.setItem(MOBILE_WARNING_KEY, "1");
+ } catch (error) {
+ // Ignore storage errors (private mode, blocked, etc.).
+ }
+}
+
+function updateMobileWarningVisibility() {
+ if (!ui.mobileWarning) return;
+ const shouldShow = isMobileViewport() && !getMobileWarningDismissed();
+ ui.mobileWarning.classList.toggle("hidden", !shouldShow);
+}
+
+function dismissMobileWarning() {
+ setMobileWarningDismissed();
+ if (ui.mobileWarning) ui.mobileWarning.classList.add("hidden");
+}
+
+function initMobileWarning() {
+ if (!ui.mobileWarning) return;
+ updateMobileWarningVisibility();
+ window.addEventListener("resize", updateMobileWarningVisibility);
+ if (!window.matchMedia) return;
+ const mediaQuery = window.matchMedia(MOBILE_WARNING_QUERY);
+ const handleChange = () => updateMobileWarningVisibility();
+ if (mediaQuery.addEventListener) {
+ mediaQuery.addEventListener("change", handleChange);
+ } else if (mediaQuery.addListener) {
+ mediaQuery.addListener(handleChange);
+ }
+}
+
+function hasStoredData() {
+ return (state.e && state.e.length) || (state.timezones && state.timezones.length);
+}
+
+function getLocalZone() {
+ return Intl.DateTimeFormat().resolvedOptions().timeZone || "UTC";
+}
+
+function createTzCard(zoneId, isLocal) {
+ const data = getZoneInfo(zoneId);
+ const div = document.createElement("div");
+ div.className = `tz-card${isLocal ? " is-local" : ""}`;
+
+ div.innerHTML = `
+ <div class="tz-name">
+ <span class="tz-label">${data.name}</span>
+ <span class="tz-offset">UTC${data.offset}</span>
+ </div>
+ <div class="tz-time">${data.time}</div>
+ ${data.dayDiff ? `<div class="tz-diff">${data.dayDiff}</div>` : ""}
+ ${!isLocal ? `<button class="tz-remove" type="button" data-zone="${data.fullZone}" aria-label="Remove timezone">x</button>` : ""}
+ `;
+
+ return div;
+}
+
+function renderTimezones() {
+ if (!ui.tzList) return;
+ ui.tzList.innerHTML = "";
+
+ const localZone = getLocalZone();
+ ui.tzList.appendChild(createTzCard(localZone, true));
+
+ const zones = Array.isArray(state.timezones) ? state.timezones : [];
+ let added = 0;
+ const seen = new Set();
+ zones.forEach((zone) => {
+ if (zone === localZone) return;
+ if (seen.has(zone)) return;
+ if (!isValidZone(zone)) return;
+ seen.add(zone);
+ ui.tzList.appendChild(createTzCard(zone, false));
+ added += 1;
+ });
+
+ if (!added) {
+ const empty = document.createElement("p");
+ empty.className = "tz-empty";
+ empty.textContent = "Add a timezone to compare.";
+ ui.tzList.appendChild(empty);
+ }
+}
+
+function addTimezone(zoneStr) {
+ if (!zoneStr || !isValidZone(zoneStr)) return;
+ const localZone = getLocalZone();
+ if (zoneStr === localZone) return;
+ if (!Array.isArray(state.timezones)) state.timezones = [];
+ if (state.timezones.includes(zoneStr)) return;
+ state.timezones.push(zoneStr);
+ scheduleSave();
+ renderTimezones();
+}
+
+function removeTimezone(zoneStr) {
+ if (!Array.isArray(state.timezones) || !zoneStr) return;
+ state.timezones = state.timezones.filter((zone) => zone !== zoneStr);
+ scheduleSave();
+ renderTimezones();
+}
+
+function renderTzResults(results) {
+ if (!ui.tzResults) return;
+ ui.tzResults.innerHTML = "";
+ results.forEach((zone) => {
+ const li = document.createElement("li");
+ const button = document.createElement("button");
+ button.type = "button";
+ button.className = "tz-result-btn";
+ const info = getZoneInfo(zone);
+ const name = document.createElement("span");
+ name.className = "tz-result-name";
+ name.textContent = zone;
+ const offset = document.createElement("span");
+ offset.className = "tz-result-offset";
+ offset.textContent = `UTC${info.offset}`;
+ button.append(name, offset);
+ button.dataset.zone = zone;
+ li.appendChild(button);
+ ui.tzResults.appendChild(li);
+ });
+}
+
+function parseOffsetSearchTerm(raw) {
+ if (!raw) return null;
+ let term = raw.toLowerCase().replace(/\s+/g, "");
+ let hasPrefix = false;
+ if (term.startsWith("utc")) {
+ term = term.slice(3);
+ hasPrefix = true;
+ } else if (term.startsWith("gmt")) {
+ term = term.slice(3);
+ hasPrefix = true;
+ }
+ if (!term) return null;
+
+ let sign = null;
+ if (term.startsWith("+") || term.startsWith("-")) {
+ sign = term[0];
+ term = term.slice(1);
+ }
+
+ const hasSeparator = term.includes(":") || term.includes(".");
+
+ let hours = null;
+ let minutes = null;
+ let hasMinutes = false;
+
+ if (hasSeparator) {
+ const parts = term.split(/[:.]/);
+ if (parts.length !== 2) return null;
+ hours = Number(parts[0]);
+ minutes = Number(parts[1]);
+ hasMinutes = parts[1].length > 0;
+ } else if (/^\d{1,2}$/.test(term)) {
+ hours = Number(term);
+ minutes = 0;
+ } else if (/^\d{3,4}$/.test(term)) {
+ const padded = term.padStart(4, "0");
+ hours = Number(padded.slice(0, 2));
+ minutes = Number(padded.slice(2));
+ hasMinutes = true;
+ } else {
+ return null;
+ }
+
+ if (!Number.isFinite(hours) || !Number.isFinite(minutes)) return null;
+ if (hours > 14 || minutes > 59) return null;
+
+ const signChar = sign || "+";
+ const value = `${signChar}${hours}:${String(minutes).padStart(2, "0")}`;
+ return { value, sign, hours, minutes, hasMinutes };
+}
+
+function handleTzSearch() {
+ if (!ui.tzSearch) return;
+ const term = ui.tzSearch.value.trim().toLowerCase();
+ const offsetQuery = parseOffsetSearchTerm(term);
+ if (!AVAILABLE_ZONES.length) {
+ if (ui.tzEmpty) {
+ ui.tzEmpty.textContent = "Timezone search isn't supported in this browser.";
+ ui.tzEmpty.classList.remove("hidden");
+ }
+ renderTzResults([]);
+ return;
+ }
+ if (term.length < 2 && !offsetQuery) {
+ renderTzResults([]);
+ if (ui.tzEmpty) ui.tzEmpty.classList.add("hidden");
+ return;
+ }
+ const localZone = getLocalZone();
+ const existing = new Set([localZone, ...(state.timezones || [])]);
+ const matches = AVAILABLE_ZONES.filter((zone) => {
+ if (existing.has(zone)) return false;
+ const zoneLower = zone.toLowerCase();
+ if (zoneLower.includes(term)) return true;
+ if (offsetQuery) {
+ const zoneOffset = getZoneInfo(zone).offset;
+ const normalized = `${offsetQuery.hours}:${String(offsetQuery.minutes).padStart(2, "0")}`;
+ if (offsetQuery.hasMinutes) {
+ if (offsetQuery.sign) {
+ return zoneOffset === `${offsetQuery.sign}${normalized}`;
+ }
+ return zoneOffset === `+${normalized}` || zoneOffset === `-${normalized}`;
+ }
+ if (offsetQuery.sign) {
+ return zoneOffset.startsWith(`${offsetQuery.sign}${offsetQuery.hours}`);
+ }
+ return zoneOffset.startsWith(`+${offsetQuery.hours}`) || zoneOffset.startsWith(`-${offsetQuery.hours}`);
+ }
+ return false;
+ }).slice(0, MAX_TZ_RESULTS);
+ renderTzResults(matches);
+ if (ui.tzEmpty) {
+ ui.tzEmpty.textContent = TZ_EMPTY_MESSAGE;
+ ui.tzEmpty.classList.toggle("hidden", matches.length > 0);
+ }
+}
+
+function openTzModal() {
+ if (!ui.tzModal) return;
+ if (ui.tzSearch) ui.tzSearch.value = "";
+ if (ui.tzEmpty) {
+ ui.tzEmpty.textContent = TZ_EMPTY_MESSAGE;
+ ui.tzEmpty.classList.add("hidden");
+ }
+ renderTzResults([]);
+ handleTzSearch();
+ if (typeof ui.tzModal.showModal === "function") {
+ ui.tzModal.showModal();
+ } else {
+ ui.tzModal.setAttribute("open", "");
+ }
+ if (ui.tzSearch) ui.tzSearch.focus();
+}
+
+function closeTzModal() {
+ if (!ui.tzModal) return;
+ if (typeof ui.tzModal.close === "function") {
+ ui.tzModal.close();
+ } else {
+ ui.tzModal.removeAttribute("open");
+ }
+}
+
+function handleTzResultsClick(event) {
+ const button = event.target.closest("button[data-zone]");
+ if (!button) return;
+ const zone = button.dataset.zone;
+ addTimezone(zone);
+ closeTzModal();
+}
+
+function handleTzListClick(event) {
+ const button = event.target.closest("button[data-zone]");
+ if (!button) return;
+ removeTimezone(button.dataset.zone);
+}
+
+function initTimezones() {
+ if (!ui.tzList) return;
+ renderTimezones();
+ if (timezoneTimer) {
+ window.clearInterval(timezoneTimer);
+ timezoneTimer = null;
+ }
+ const now = new Date();
+ const delay = (60 - now.getSeconds()) * 1000;
+ window.setTimeout(() => {
+ renderTimezones();
+ timezoneTimer = window.setInterval(renderTimezones, 60000);
+ }, delay);
+}
+
+async function persistStateToHash() {
+ if (lockState.encrypted && !lockState.unlocked) return;
+ if (!hasStoredData()) {
+ if (window.location.hash) clearHash();
+ updateUrlLength();
+ if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
+ updateJsonModal();
+ }
+ return;
+ }
+ await writeStateToHash(state, password);
+ updateUrlLength();
+ if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
+ updateJsonModal();
+ }
+}
+
+function scheduleSave() {
+ if (lockState.encrypted && !lockState.unlocked) return;
+ if (!hasStoredData()) {
+ if (saveTimer) {
+ window.clearTimeout(saveTimer);
+ saveTimer = null;
+ }
+ persistStateToHash();
+ return;
+ }
+ if (saveTimer) window.clearTimeout(saveTimer);
+ saveTimer = window.setTimeout(() => {
+ saveTimer = null;
+ persistStateToHash();
+ }, DEBOUNCE_MS);
+}
function updateUrlLength() {
const length = window.location.hash.length;
@@ -615,31 +623,31 @@ function updateUrlLength() {
}
}
-function updateTheme() {
- document.body.dataset.theme = state.s.d ? "dark" : "light";
- if (ui.themeToggle) {
- ui.themeToggle.textContent = `Theme: ${state.s.d ? "Dark" : "Light"}`;
- }
-}
-
-function syncTopbarHeight() {
- if (!ui.topbar) return;
- document.documentElement.style.setProperty("--topbar-height", `${ui.topbar.offsetHeight}px`);
-}
-
-function updateWeekStartLabel() {
- if (!ui.weekstartToggle) return;
- ui.weekstartToggle.textContent = state.s.m ? "Week starts Monday" : "Week starts Sunday";
-}
-
-function updateFocusButton(isActive) {
- if (!ui.focusBtn) return;
- const active = typeof isActive === "boolean" ? isActive : focusMode && focusMode.isActive();
- ui.focusBtn.textContent = active ? "Exit focus" : "Focus";
- ui.focusBtn.setAttribute("aria-pressed", active ? "true" : "false");
-}
-
-function updateViewButtons() {
+function updateTheme() {
+ document.body.dataset.theme = state.s.d ? "dark" : "light";
+ if (ui.themeToggle) {
+ ui.themeToggle.textContent = `Theme: ${state.s.d ? "Dark" : "Light"}`;
+ }
+}
+
+function syncTopbarHeight() {
+ if (!ui.topbar) return;
+ document.documentElement.style.setProperty("--topbar-height", `${ui.topbar.offsetHeight}px`);
+}
+
+function updateWeekStartLabel() {
+ if (!ui.weekstartToggle) return;
+ ui.weekstartToggle.textContent = state.s.m ? "Week starts Monday" : "Week starts Sunday";
+}
+
+function updateFocusButton(isActive) {
+ if (!ui.focusBtn) return;
+ const active = typeof isActive === "boolean" ? isActive : focusMode && focusMode.isActive();
+ ui.focusBtn.textContent = active ? "Exit focus" : "Focus";
+ ui.focusBtn.setAttribute("aria-pressed", active ? "true" : "false");
+}
+
+function updateViewButtons() {
if (!ui.viewButtons || !ui.viewButtons.length) return;
ui.viewButtons.forEach((button) => {
const isActive = button.dataset.view === currentView;
@@ -648,15 +656,15 @@ function updateViewButtons() {
});
}
-function setView(view) {
- if (!VALID_VIEWS.has(view)) return;
- if (currentView === view) return;
- currentView = view;
- if (state && state.s) state.s.v = view;
- updateViewButtons();
- render();
- persistStateToHash();
-}
+function setView(view) {
+ if (!VALID_VIEWS.has(view)) return;
+ if (currentView === view) return;
+ currentView = view;
+ if (state && state.s) state.s.v = view;
+ updateViewButtons();
+ render();
+ persistStateToHash();
+}
function updateLockUI() {
const isLocked = lockState.encrypted && !lockState.unlocked;
@@ -670,11 +678,11 @@ function updateLockUI() {
if (ui.lockedOverlay) {
ui.lockedOverlay.classList.toggle("hidden", !isLocked);
}
- const disabled = isLocked;
- [ui.addEventBtn, ui.addEventInline, ui.copyLinkBtn, ui.shareQrBtn].forEach((btn) => {
- if (btn) btn.disabled = disabled;
- });
-}
+ const disabled = isLocked;
+ [ui.addEventBtn, ui.addEventInline, ui.copyLinkBtn, ui.shareQrBtn].forEach((btn) => {
+ if (btn) btn.disabled = disabled;
+ });
+}
function groupOccurrences(occurrences) {
const map = new Map();
@@ -711,9 +719,9 @@ function render() {
ui.calendarGrid.style.gridTemplateColumns = "";
ui.calendarGrid.style.gridTemplateRows = "";
}
- if (ui.weekdayRow) {
- ui.weekdayRow.classList.toggle("hidden", currentView === "year" || currentView === "agenda");
- }
+ if (ui.weekdayRow) {
+ ui.weekdayRow.classList.toggle("hidden", currentView === "year" || currentView === "agenda");
+ }
if (currentView === "month") {
const range = getMonthGridRange(viewDate, weekStartsOnMonday);
@@ -752,10 +760,10 @@ function render() {
onEventClick: (event) => openEventModal({ index: event.sourceIndex }),
});
}
- } else if (currentView === "day") {
- const start = startOfDay(selectedDate);
- const end = new Date(start.getFullYear(), start.getMonth(), start.getDate(), 23, 59, 59);
- const expanded = expandEvents(state.e, start, end);
+ } else if (currentView === "day") {
+ const start = startOfDay(selectedDate);
+ const end = new Date(start.getFullYear(), start.getMonth(), start.getDate(), 23, 59, 59);
+ const expanded = expandEvents(state.e, start, end);
const decorated = decorateOccurrences(expanded);
occurrencesByDay = groupOccurrences(decorated);
@@ -768,23 +776,23 @@ function render() {
occurrences: decorated,
onSelectDay: handleSelectDay,
onEventClick: (event) => openEventModal({ index: event.sourceIndex }),
- });
- }
- } else if (currentView === "agenda") {
- const agendaData = renderAgendaView({
- events: state.e,
- colors: state.c,
- container: ui.calendarGrid,
- rangeMonths: 6,
- onEventClick: (event) => openEventModal({ index: event.sourceIndex }),
- });
- occurrencesByDay = agendaData && agendaData.occurrencesByDay ? agendaData.occurrencesByDay : new Map();
- if (ui.monthLabel && agendaData && agendaData.range) {
- ui.monthLabel.textContent = `Agenda · ${formatRangeLabel(agendaData.range.start, agendaData.range.end)}`;
- }
- } else if (currentView === "year") {
- const year = viewDate.getFullYear();
- const start = new Date(year, 0, 1);
+ });
+ }
+ } else if (currentView === "agenda") {
+ const agendaData = renderAgendaView({
+ events: state.e,
+ colors: state.c,
+ container: ui.calendarGrid,
+ rangeMonths: 6,
+ onEventClick: (event) => openEventModal({ index: event.sourceIndex }),
+ });
+ occurrencesByDay = agendaData && agendaData.occurrencesByDay ? agendaData.occurrencesByDay : new Map();
+ if (ui.monthLabel && agendaData && agendaData.range) {
+ ui.monthLabel.textContent = `Agenda · ${formatRangeLabel(agendaData.range.start, agendaData.range.end)}`;
+ }
+ } else if (currentView === "year") {
+ const year = viewDate.getFullYear();
+ const start = new Date(year, 0, 1);
const end = new Date(year, 11, 31, 23, 59, 59);
const expanded = expandEvents(state.e, start, end);
const decorated = decorateOccurrences(expanded);
@@ -803,15 +811,15 @@ function render() {
}
}
- renderEventList();
- renderTimezones();
- updateUrlLength();
- if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
- updateJsonModal();
- }
- updateLockUI();
- initCountdownWidget(state.e);
-}
+ renderEventList();
+ renderTimezones();
+ updateUrlLength();
+ if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
+ updateJsonModal();
+ }
+ updateLockUI();
+ initCountdownWidget(state.e);
+}
function renderEventList() {
if (!ui.eventList || !ui.selectedDateLabel) return;
@@ -1090,13 +1098,13 @@ async function attemptUnlock() {
});
if (!value) return;
try {
- const loaded = await readStateFromHash(value);
- password = value;
- lockState = { encrypted: true, unlocked: true };
- state = normalizeState(loaded);
- applyStoredView();
- render();
- showToast("Calendar unlocked", "success");
+ const loaded = await readStateFromHash(value);
+ password = value;
+ lockState = { encrypted: true, unlocked: true };
+ state = normalizeState(loaded);
+ applyStoredView();
+ render();
+ showToast("Calendar unlocked", "success");
} catch (error) {
showToast("Incorrect password", "error");
lockState = { encrypted: true, unlocked: false };
@@ -1104,29 +1112,28 @@ async function attemptUnlock() {
}
}
-async function loadStateFromHash() {
- if (!window.location.hash) {
- state = cloneState(DEFAULT_STATE);
- applyStoredView();
- return;
- }
-
- if (isEncryptedHash()) {
- lockState = { encrypted: true, unlocked: false };
- state = cloneState(DEFAULT_STATE);
- applyStoredView();
- updateLockUI();
- return;
- }
-
- try {
- const loaded = await readStateFromHash();
- state = normalizeState(loaded);
- } catch (error) {
- state = cloneState(DEFAULT_STATE);
- }
- applyStoredView();
-}
+async function loadStateFromHash() {
+ if (!window.location.hash) {
+ state = cloneState(DEFAULT_STATE);
+ applyStoredView();
+ return;
+ }
+
+ if (isEncryptedHash()) {
+ lockState = { encrypted: true, unlocked: false };
+ state = cloneState(DEFAULT_STATE);
+ updateLockUI();
+ return;
+ }
+
+ try {
+ const loaded = await readStateFromHash();
+ state = normalizeState(loaded);
+ } catch (error) {
+ state = cloneState(DEFAULT_STATE);
+ }
+ applyStoredView();
+}
function handleHashChange() {
loadStateFromHash().then(render);
@@ -1173,66 +1180,66 @@ function handleNextMonth() {
shiftView(1);
}
-function handleToday() {
- const today = startOfDay(new Date());
- viewDate = today;
- selectedDate = today;
- render();
-}
-
-function fallbackCopyText(text) {
- const textArea = document.createElement("textarea");
- textArea.value = text;
- textArea.setAttribute("readonly", "");
- textArea.style.position = "absolute";
- textArea.style.left = "-9999px";
- document.body.appendChild(textArea);
- textArea.select();
- let success = false;
- try {
- success = document.execCommand("copy");
- } catch (error) {
- success = false;
- }
- document.body.removeChild(textArea);
- return success;
-}
-
-async function handleCopyLink() {
- await persistStateToHash();
- const url = window.location.href;
- if (navigator.clipboard && navigator.clipboard.writeText) {
- try {
- await navigator.clipboard.writeText(url);
- showToast("Link copied", "success");
- return;
- } catch (error) {
- // Fallback below
- }
- }
- if (fallbackCopyText(url)) {
- showToast("Link copied", "success");
- } else {
- showToast("Unable to copy link", "error");
- }
-}
-
-function handleShareQr() {
- if (qrManager) {
- qrManager.show();
- }
-}
-
-function handleFocusToggle() {
- if (!focusMode) return;
- if (focusMode.isActive()) {
- focusMode.stop();
- } else {
- focusMode.start();
- }
-}
-
-function updateJsonModal() {
+function handleToday() {
+ const today = startOfDay(new Date());
+ viewDate = today;
+ selectedDate = today;
+ render();
+}
+
+function fallbackCopyText(text) {
+ const textArea = document.createElement("textarea");
+ textArea.value = text;
+ textArea.setAttribute("readonly", "");
+ textArea.style.position = "absolute";
+ textArea.style.left = "-9999px";
+ document.body.appendChild(textArea);
+ textArea.select();
+ let success = false;
+ try {
+ success = document.execCommand("copy");
+ } catch (error) {
+ success = false;
+ }
+ document.body.removeChild(textArea);
+ return success;
+}
+
+async function handleCopyLink() {
+ await persistStateToHash();
+ const url = window.location.href;
+ if (navigator.clipboard && navigator.clipboard.writeText) {
+ try {
+ await navigator.clipboard.writeText(url);
+ showToast("Link copied", "success");
+ return;
+ } catch (error) {
+ // Fallback below
+ }
+ }
+ if (fallbackCopyText(url)) {
+ showToast("Link copied", "success");
+ } else {
+ showToast("Unable to copy link", "error");
+ }
+}
+
+function handleShareQr() {
+ if (qrManager) {
+ qrManager.show();
+ }
+}
+
+function handleFocusToggle() {
+ if (!focusMode) return;
+ if (focusMode.isActive()) {
+ focusMode.stop();
+ } else {
+ focusMode.start();
+ }
+}
+
+function updateJsonModal() {
if (ui.jsonOutput) {
ui.jsonOutput.value = JSON.stringify(state, null, 2);
}
@@ -1328,9 +1335,9 @@ function handleClearAll() {
render();
}
-function bindEvents() {
- if (ui.mobileWarningDismiss) ui.mobileWarningDismiss.addEventListener("click", dismissMobileWarning);
- if (ui.titleInput) ui.titleInput.addEventListener("input", handleTitleInput);
+function bindEvents() {
+ if (ui.mobileWarningDismiss) ui.mobileWarningDismiss.addEventListener("click", dismissMobileWarning);
+ if (ui.titleInput) ui.titleInput.addEventListener("input", handleTitleInput);
if (ui.prevMonth) ui.prevMonth.addEventListener("click", handlePrevMonth);
if (ui.nextMonth) ui.nextMonth.addEventListener("click", handleNextMonth);
if (ui.todayBtn) ui.todayBtn.addEventListener("click", handleToday);
@@ -1339,13 +1346,13 @@ function bindEvents() {
button.addEventListener("click", () => setView(button.dataset.view));
});
}
- if (ui.addEventBtn) ui.addEventBtn.addEventListener("click", () => openEventModal({ date: selectedDate }));
- if (ui.addEventInline) ui.addEventInline.addEventListener("click", () => openEventModal({ date: selectedDate }));
- if (ui.copyLinkBtn) ui.copyLinkBtn.addEventListener("click", handleCopyLink);
- if (ui.shareQrBtn) ui.shareQrBtn.addEventListener("click", handleShareQr);
- if (ui.lockBtn) ui.lockBtn.addEventListener("click", handleLockAction);
- if (ui.focusBtn) ui.focusBtn.addEventListener("click", handleFocusToggle);
- if (ui.weekstartToggle) ui.weekstartToggle.addEventListener("click", handleWeekStartToggle);
+ if (ui.addEventBtn) ui.addEventBtn.addEventListener("click", () => openEventModal({ date: selectedDate }));
+ if (ui.addEventInline) ui.addEventInline.addEventListener("click", () => openEventModal({ date: selectedDate }));
+ if (ui.copyLinkBtn) ui.copyLinkBtn.addEventListener("click", handleCopyLink);
+ if (ui.shareQrBtn) ui.shareQrBtn.addEventListener("click", handleShareQr);
+ if (ui.lockBtn) ui.lockBtn.addEventListener("click", handleLockAction);
+ if (ui.focusBtn) ui.focusBtn.addEventListener("click", handleFocusToggle);
+ if (ui.weekstartToggle) ui.weekstartToggle.addEventListener("click", handleWeekStartToggle);
if (ui.themeToggle) ui.themeToggle.addEventListener("click", handleThemeToggle);
if (ui.unlockBtn) ui.unlockBtn.addEventListener("click", attemptUnlock);
if (ui.viewJson) ui.viewJson.addEventListener("click", openJsonModal);
@@ -1363,53 +1370,112 @@ function bindEvents() {
if (ui.passwordClose) ui.passwordClose.addEventListener("click", closePasswordModal);
if (ui.passwordCancel) ui.passwordCancel.addEventListener("click", closePasswordModal);
if (ui.passwordSubmit) ui.passwordSubmit.addEventListener("click", submitPassword);
- if (ui.jsonClose) ui.jsonClose.addEventListener("click", closeJsonModal);
- if (ui.jsonCopy) ui.jsonCopy.addEventListener("click", handleCopyJson);
- if (ui.jsonCopyHash) ui.jsonCopyHash.addEventListener("click", handleCopyHash);
- if (ui.jsonDownload) ui.jsonDownload.addEventListener("click", handleExportJson);
- if (ui.tzAddBtn) ui.tzAddBtn.addEventListener("click", openTzModal);
- if (ui.tzClose) ui.tzClose.addEventListener("click", closeTzModal);
- if (ui.tzSearch) ui.tzSearch.addEventListener("input", handleTzSearch);
- if (ui.tzResults) ui.tzResults.addEventListener("click", handleTzResultsClick);
- if (ui.tzList) ui.tzList.addEventListener("click", handleTzListClick);
- if (ui.tzModal) {
- ui.tzModal.addEventListener("click", (event) => {
- if (event.target === ui.tzModal) closeTzModal();
- });
- }
-
- window.addEventListener("hashchange", handleHashChange);
- window.addEventListener("resize", syncTopbarHeight);
-}
-
-async function init() {
- cacheElements();
- syncTopbarHeight();
- qrManager = initQRCodeManager({
- onBeforeOpen: persistStateToHash,
- onCopyLink: handleCopyLink,
- showToast,
- });
- focusMode = new FocusMode({
- getState: () => state,
- fallbackColors: DEFAULT_COLORS,
- onToggle: updateFocusButton,
- });
- bindEvents();
- initMobileWarning();
- await loadStateFromHash();
- if (!isEncryptedHash() && !hasStoredData() && window.location.hash) {
- clearHash();
- }
-
- updateViewButtons();
- updateFocusButton(false);
- render();
- initTimezones();
-
- if (isEncryptedHash() && !lockState.unlocked) {
- attemptUnlock();
- }
+ if (ui.jsonClose) ui.jsonClose.addEventListener("click", closeJsonModal);
+ if (ui.jsonCopy) ui.jsonCopy.addEventListener("click", handleCopyJson);
+ if (ui.jsonCopyHash) ui.jsonCopyHash.addEventListener("click", handleCopyHash);
+ if (ui.jsonDownload) ui.jsonDownload.addEventListener("click", handleExportJson);
+ if (ui.tzAddBtn) ui.tzAddBtn.addEventListener("click", openTzModal);
+ if (ui.tzClose) ui.tzClose.addEventListener("click", closeTzModal);
+ if (ui.tzSearch) ui.tzSearch.addEventListener("input", handleTzSearch);
+ if (ui.tzResults) ui.tzResults.addEventListener("click", handleTzResultsClick);
+ if (ui.tzList) ui.tzList.addEventListener("click", handleTzListClick);
+ if (ui.tzModal) {
+ ui.tzModal.addEventListener("click", (event) => {
+ if (event.target === ui.tzModal) closeTzModal();
+ });
+ }
+
+ window.addEventListener("hashchange", handleHashChange);
+ window.addEventListener("resize", syncTopbarHeight);
+}
+
+function initResponsiveFeatures() {
+ if (ui.hamburgerBtn && ui.secondaryActions) {
+ ui.hamburgerBtn.addEventListener("click", (e) => {
+ e.stopPropagation();
+ ui.secondaryActions.classList.toggle("is-active");
+ const icon = ui.hamburgerBtn.querySelector("i");
+ if (icon) {
+ icon.classList.toggle("fa-bars");
+ icon.classList.toggle("fa-xmark");
+ }
+ });
+
+ document.addEventListener("click", (e) => {
+ if (!ui.secondaryActions.contains(e.target) && !ui.hamburgerBtn.contains(e.target)) {
+ ui.secondaryActions.classList.remove("is-active");
+ const icon = ui.hamburgerBtn.querySelector("i");
+ if (icon) {
+ icon.classList.add("fa-bars");
+ icon.classList.remove("fa-xmark");
+ }
+ }
+ });
+ }
+
+ if (ui.mobileSidebarToggle) {
+ ui.mobileSidebarToggle.addEventListener("click", () => {
+ if (ui.sidePanel.classList.contains("is-active")) {
+ // From Events to Clock
+ ui.sidePanel.classList.remove("is-active");
+ ui.tzSidebar.classList.add("is-active");
+ ui.mobileSidebarToggle.querySelector("span").textContent = "Clock";
+ } else if (ui.tzSidebar.classList.contains("is-active")) {
+ // From Clock to Calendar (Close both)
+ ui.tzSidebar.classList.remove("is-active");
+ ui.mobileSidebarToggle.querySelector("span").textContent = "Details";
+ } else {
+ // From Calendar to Events
+ ui.sidePanel.classList.add("is-active");
+ ui.mobileSidebarToggle.querySelector("span").textContent = "Events";
+ }
+ });
+ }
+
+ if (ui.sidePanelClose) {
+ ui.sidePanelClose.addEventListener("click", () => {
+ ui.sidePanel.classList.remove("is-active");
+ if (ui.mobileSidebarToggle) ui.mobileSidebarToggle.querySelector("span").textContent = "Details";
+ });
+ }
+
+ if (ui.tzSidebarClose) {
+ ui.tzSidebarClose.addEventListener("click", () => {
+ ui.tzSidebar.classList.remove("is-active");
+ if (ui.mobileSidebarToggle) ui.mobileSidebarToggle.querySelector("span").textContent = "Details";
+ });
+ }
+}
+
+async function init() {
+ cacheElements();
+ syncTopbarHeight();
+ qrManager = initQRCodeManager({
+ onBeforeOpen: persistStateToHash,
+ onCopyLink: handleCopyLink,
+ showToast,
+ });
+ focusMode = new FocusMode({
+ getState: () => state,
+ fallbackColors: DEFAULT_COLORS,
+ onToggle: updateFocusButton,
+ });
+ bindEvents();
+ initMobileWarning();
+ initResponsiveFeatures();
+ await loadStateFromHash();
+ if (!isEncryptedHash() && !hasStoredData() && window.location.hash) {
+ clearHash();
+ }
+
+ updateViewButtons();
+ updateFocusButton(false);
+ render();
+ initTimezones();
+
+ if (isEncryptedHash() && !lockState.unlocked) {
+ attemptUnlock();
+ }
}
if (document.readyState === "loading") {
diff --git a/styles.css b/styles.css
index 5b7cb44..0a74413 100644
--- a/styles.css
+++ b/styles.css
@@ -1,14 +1,14 @@
-:root {
- color-scheme: light;
- --font-body: "Space Grotesk", "Roboto", "Segoe UI", sans-serif;
- --font-display: "Space Grotesk", "Roboto", "Segoe UI", sans-serif;
- --bg: #f1f3f4;
- --panel: #ffffff;
- --panel-2: #fafafa;
- --border: #dadce0;
- --border-soft: #e6e6e6;
- --text: #3c4043;
- --muted: #5f6368;
+:root {
+ color-scheme: light;
+ --font-body: "Space Grotesk", "Roboto", "Segoe UI", sans-serif;
+ --font-display: "Space Grotesk", "Roboto", "Segoe UI", sans-serif;
+ --bg: #f1f3f4;
+ --panel: #ffffff;
+ --panel-2: #fafafa;
+ --border: #dadce0;
+ --border-soft: #e6e6e6;
+ --text: #3c4043;
+ --muted: #5f6368;
--accent: #1a73e8;
--accent-soft: rgba(26, 115, 232, 0.12);
--accent-strong: #0b57d0;
@@ -24,14 +24,14 @@
}
body[data-theme="dark"] {
- color-scheme: dark;
- --bg: #202124;
- --panel: #2b2c2f;
- --panel-2: #27272a;
- --border: #3c4043;
- --border-soft: #33363a;
- --text: #e8eaed;
- --muted: #9aa0a6;
+ color-scheme: dark;
+ --bg: #202124;
+ --panel: #2b2c2f;
+ --panel-2: #27272a;
+ --border: #3c4043;
+ --border-soft: #33363a;
+ --text: #e8eaed;
+ --muted: #9aa0a6;
--accent: #8ab4f8;
--accent-soft: rgba(138, 180, 248, 0.2);
--accent-strong: #a8c7fa;
@@ -44,24 +44,24 @@ body[data-theme="dark"] {
--shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
--shadow-md: 0 2px 8px rgba(0, 0, 0, 0.4);
}
-
-* {
- box-sizing: border-box;
-}
-
-html,
-body {
- height: 100%;
-}
-
-body {
- margin: 0;
- font-family: var(--font-body);
- background: var(--bg);
- color: var(--text);
- overflow: hidden;
-}
-
+
+* {
+ box-sizing: border-box;
+}
+
+html,
+body {
+ height: 100%;
+}
+
+body {
+ margin: 0;
+ font-family: var(--font-body);
+ background: var(--bg);
+ color: var(--text);
+ overflow: hidden;
+}
+
button {
font-family: inherit;
}
@@ -88,13 +88,13 @@ button {
box-shadow: var(--shadow-md);
transform: translateY(-1px);
}
-
-.app {
- height: 100vh;
- display: flex;
- flex-direction: column;
-}
-
+
+.app {
+ height: 100vh;
+ display: flex;
+ flex-direction: column;
+}
+
.topbar {
display: flex;
align-items: center;
@@ -189,138 +189,152 @@ button {
border-color: var(--border-soft);
color: var(--muted);
}
-
-.brand {
- display: flex;
- align-items: center;
- gap: 12px;
-}
-
-.brand-mark {
- width: 40px;
- height: 40px;
- border-radius: 10px;
- background: var(--accent);
- color: #fff;
- display: grid;
- place-items: center;
- font-weight: 700;
- font-family: var(--font-display);
-}
-
-.brand-text {
- display: flex;
- flex-direction: column;
- gap: 2px;
-}
-
-.title-input {
- font-family: var(--font-display);
- font-size: 18px;
- font-weight: 600;
- color: var(--text);
- border: none;
- background: transparent;
- padding: 0;
- outline: none;
-}
-
-.brand-subtitle {
- font-size: 0.78rem;
- color: var(--muted);
-}
-
-.top-actions {
- display: flex;
- align-items: center;
- gap: 10px;
- flex-wrap: wrap;
-}
-
-.nav-group {
- display: flex;
- gap: 8px;
-}
-
-.view-toggle {
- display: inline-flex;
- align-items: center;
- border: 1px solid var(--border);
- background: var(--panel-2);
- border-radius: 999px;
- overflow: hidden;
-}
-
-button {
- font-size: 0.85rem;
- padding: 7px 14px;
- border-radius: 6px;
- border: 1px solid var(--border);
- background: var(--panel);
- color: var(--text);
- cursor: pointer;
- transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
-}
-
-button:hover {
- background: var(--panel-2);
- border-color: var(--border-soft);
- box-shadow: var(--shadow-sm);
-}
-
-button:focus-visible {
- outline: 2px solid var(--accent);
- outline-offset: 2px;
-}
-
-button.primary {
- background: var(--accent);
- color: #fff;
- border-color: transparent;
- box-shadow: var(--shadow-sm);
-}
-
-button.primary:hover {
- background: var(--accent-strong);
-}
-
-/* View toggle overrides */
-.view-toggle button {
- border: none;
- background: transparent;
- color: var(--muted);
- font-size: 0.78rem;
- padding: 6px 12px;
- box-shadow: none;
-}
-
-.view-toggle button:hover {
- background: transparent;
- box-shadow: none;
-}
-
-.view-toggle button.active {
- background: var(--accent);
- color: #fff;
-}
-
-button.ghost {
- background: transparent;
-}
-
-button.danger,
-.danger-btn {
- background: var(--danger);
- color: var(--danger-ink);
- border-color: transparent;
-}
-
-button:disabled {
- opacity: 0.6;
- cursor: not-allowed;
- box-shadow: none;
-}
-
+
+.brand {
+ display: flex;
+ align-items: center;
+ gap: 12px;
+ flex-shrink: 0;
+}
+
+.brand-mark {
+ width: 40px;
+ height: 40px;
+ border-radius: 10px;
+ background: var(--accent);
+ color: #fff;
+ display: grid;
+ place-items: center;
+ font-weight: 700;
+ font-family: var(--font-display);
+}
+
+.brand-text {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.title-input {
+ font-family: var(--font-display);
+ font-size: 18px;
+ font-weight: 600;
+ color: var(--text);
+ border: none;
+ background: transparent;
+ padding: 0;
+ outline: none;
+}
+
+.brand-subtitle {
+ font-size: 0.78rem;
+ color: var(--muted);
+}
+
+.top-actions {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+ flex-wrap: wrap;
+}
+
+.secondary-actions {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+}
+
+.action-divider {
+ width: 1px;
+ height: 24px;
+ background: var(--border);
+ margin: 0 4px;
+}
+
+.nav-group {
+ display: flex;
+ gap: 8px;
+}
+
+.view-toggle {
+ display: inline-flex;
+ align-items: center;
+ border: 1px solid var(--border);
+ background: var(--panel-2);
+ border-radius: 999px;
+ overflow: hidden;
+}
+
+button {
+ font-size: 0.85rem;
+ padding: 7px 14px;
+ border-radius: 6px;
+ border: 1px solid var(--border);
+ background: var(--panel);
+ color: var(--text);
+ cursor: pointer;
+ transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
+}
+
+button:hover {
+ background: var(--panel-2);
+ border-color: var(--border-soft);
+ box-shadow: var(--shadow-sm);
+}
+
+button:focus-visible {
+ outline: 2px solid var(--accent);
+ outline-offset: 2px;
+}
+
+button.primary {
+ background: var(--accent);
+ color: #fff;
+ border-color: transparent;
+ box-shadow: var(--shadow-sm);
+}
+
+button.primary:hover {
+ background: var(--accent-strong);
+}
+
+/* View toggle overrides */
+.view-toggle button {
+ border: none;
+ background: transparent;
+ color: var(--muted);
+ font-size: 0.78rem;
+ padding: 6px 12px;
+ box-shadow: none;
+}
+
+.view-toggle button:hover {
+ background: transparent;
+ box-shadow: none;
+}
+
+.view-toggle button.active {
+ background: var(--accent);
+ color: #fff;
+}
+
+button.ghost {
+ background: transparent;
+}
+
+button.danger,
+.danger-btn {
+ background: var(--danger);
+ color: var(--danger-ink);
+ border-color: transparent;
+}
+
+button:disabled {
+ opacity: 0.6;
+ cursor: not-allowed;
+ box-shadow: none;
+}
+
.layout {
flex: 1;
min-height: 0;
@@ -336,9 +350,9 @@ button:disabled {
border-right: 1px solid var(--border);
padding: 16px;
display: flex;
- flex-direction: column;
- gap: 16px;
- overflow-y: auto;
+ flex-direction: column;
+ gap: 16px;
+ overflow-y: auto;
}
.calendar-panel {
@@ -489,44 +503,44 @@ button:disabled {
display: flex;
align-items: center;
justify-content: space-between;
- gap: 16px;
- padding: 16px 20px 12px;
- border-bottom: 1px solid var(--border);
-}
-
-.month-label {
- margin: 0 0 4px;
- font-size: 1.4rem;
- font-weight: 600;
- font-family: var(--font-display);
-}
-
-.panel-actions {
- display: flex;
- gap: 8px;
- flex-wrap: wrap;
-}
-
-.weekday-row {
- display: grid;
- grid-template-columns: repeat(7, minmax(0, 1fr));
- border-bottom: 1px solid var(--border);
- background: var(--panel);
-}
-
-.weekday-row.hidden {
- display: none;
-}
-
-.weekday {
- padding: 8px 12px;
- text-align: center;
- font-size: 0.72rem;
- color: var(--muted);
- text-transform: uppercase;
- letter-spacing: 0.08em;
-}
-
+ gap: 16px;
+ padding: 16px 20px 12px;
+ border-bottom: 1px solid var(--border);
+}
+
+.month-label {
+ margin: 0 0 4px;
+ font-size: 1.4rem;
+ font-weight: 600;
+ font-family: var(--font-display);
+}
+
+.panel-actions {
+ display: flex;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.weekday-row {
+ display: grid;
+ grid-template-columns: repeat(7, minmax(0, 1fr));
+ border-bottom: 1px solid var(--border);
+ background: var(--panel);
+}
+
+.weekday-row.hidden {
+ display: none;
+}
+
+.weekday {
+ padding: 8px 12px;
+ text-align: center;
+ font-size: 0.72rem;
+ color: var(--muted);
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+}
+
.calendar-grid {
flex: 1;
min-height: 0;
@@ -618,71 +632,71 @@ button:disabled {
display: grid;
grid-template-columns: repeat(7, minmax(0, 1fr));
grid-template-rows: repeat(6, minmax(0, 1fr));
- border-left: 1px solid var(--border);
- border-top: 1px solid var(--border);
-}
-
-.day-cell {
- border-right: 1px solid var(--border);
- border-bottom: 1px solid var(--border);
- padding: 8px 10px;
- display: flex;
- flex-direction: column;
- gap: 6px;
- cursor: pointer;
- background: var(--panel);
- transition: background 0.15s ease;
-}
-
-.day-cell:hover {
- background: var(--panel-2);
-}
-
-.day-cell.is-outside {
- background: var(--panel-2);
- color: var(--muted);
-}
-
-.day-cell.is-today {
- background: var(--accent-soft);
-}
-
-.day-cell.is-selected {
- box-shadow: inset 0 0 0 2px var(--accent);
-}
-
-.day-number {
- font-size: 0.72rem;
- font-weight: 600;
- color: inherit;
- align-self: flex-end;
-}
-
-.event-chip {
- border-radius: 4px;
- padding: 2px 6px;
- font-size: 0.7rem;
- display: inline-flex;
- align-items: center;
- gap: 6px;
- color: #fff;
- border: none;
- box-shadow: none;
- overflow: hidden;
- white-space: nowrap;
- text-overflow: ellipsis;
-}
-
-.event-chip .time {
- font-weight: 600;
- font-size: 0.65rem;
-}
-
-.event-more {
- font-size: 0.72rem;
- color: var(--muted);
-}
-
+ border-left: 1px solid var(--border);
+ border-top: 1px solid var(--border);
+}
+
+.day-cell {
+ border-right: 1px solid var(--border);
+ border-bottom: 1px solid var(--border);
+ padding: 8px 10px;
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ cursor: pointer;
+ background: var(--panel);
+ transition: background 0.15s ease;
+}
+
+.day-cell:hover {
+ background: var(--panel-2);
+}
+
+.day-cell.is-outside {
+ background: var(--panel-2);
+ color: var(--muted);
+}
+
+.day-cell.is-today {
+ background: var(--accent-soft);
+}
+
+.day-cell.is-selected {
+ box-shadow: inset 0 0 0 2px var(--accent);
+}
+
+.day-number {
+ font-size: 0.72rem;
+ font-weight: 600;
+ color: inherit;
+ align-self: flex-end;
+}
+
+.event-chip {
+ border-radius: 4px;
+ padding: 2px 6px;
+ font-size: 0.7rem;
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ color: #fff;
+ border: none;
+ box-shadow: none;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
+
+.event-chip .time {
+ font-weight: 600;
+ font-size: 0.65rem;
+}
+
+.event-more {
+ font-size: 0.72rem;
+ color: var(--muted);
+}
+
.calendar-grid.week-view,
.calendar-grid.day-view {
display: grid;
@@ -694,197 +708,197 @@ button:disabled {
-webkit-overflow-scrolling: touch;
scrollbar-gutter: stable;
}
-
-.time-label {
- border-right: 1px solid var(--border);
- border-bottom: 1px solid var(--border);
- padding: 4px 6px;
- font-size: 0.68rem;
- color: var(--muted);
- text-align: right;
- background: var(--panel);
-}
-
-.time-label.all-day-label {
- text-align: center;
- font-weight: 600;
-}
-
-.time-cell {
- border-right: 1px solid var(--border);
- border-bottom: 1px solid var(--border);
- padding: 4px;
- background: var(--panel);
- display: flex;
- flex-direction: column;
- gap: 4px;
- overflow: hidden;
-}
-
-.time-cell.all-day {
- background: var(--panel-2);
-}
-
-.time-event {
- border-radius: 4px;
- padding: 2px 6px;
- font-size: 0.68rem;
- color: #fff;
- border: none;
- text-align: left;
- cursor: pointer;
-}
-
-.calendar-grid.year-view {
- display: grid;
- grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
- gap: 16px;
- padding: 16px;
- overflow: auto;
- background: var(--bg);
-}
-
-.mini-month {
- border: 1px solid var(--border);
- background: var(--panel);
- border-radius: 8px;
- padding: 12px;
- display: flex;
- flex-direction: column;
- gap: 8px;
-}
-
-.mini-title {
- font-size: 0.9rem;
- font-weight: 600;
- color: var(--text);
-}
-
-.mini-grid {
- display: grid;
- grid-template-columns: repeat(7, minmax(0, 1fr));
- gap: 4px;
-}
-
-.mini-weekday {
- font-size: 0.6rem;
- text-align: center;
- color: var(--muted);
- text-transform: uppercase;
-}
-
-.mini-day {
- border: none;
- background: transparent;
- color: var(--text);
- font-size: 0.65rem;
- padding: 4px 0;
- border-radius: 4px;
- position: relative;
-}
-
-.mini-day.is-outside {
- color: var(--muted);
-}
-
-.mini-day.is-selected {
- background: var(--accent-soft);
-}
-
-.mini-day:hover {
- background: var(--panel-2);
-}
-
-.mini-dot {
- position: absolute;
- bottom: 2px;
- left: 50%;
- width: 4px;
- height: 4px;
- background: var(--accent);
- border-radius: 50%;
- transform: translateX(-50%);
-}
-
-.side-card {
- border: 1px solid var(--border);
- border-radius: 8px;
- padding: 12px;
- background: var(--panel);
- display: flex;
- flex-direction: column;
- gap: 10px;
-}
-
-.side-card.danger {
- border-color: rgba(217, 48, 37, 0.4);
-}
-
-.side-title {
- margin: 0;
- font-size: 0.9rem;
- font-weight: 600;
-}
-
-.event-list {
- display: flex;
- flex-direction: column;
- gap: 8px;
- min-height: 120px;
-}
-
-.event-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 10px;
- padding: 8px 10px;
- border-radius: 6px;
- border: 1px solid var(--border-soft);
- background: var(--panel-2);
- cursor: pointer;
-}
-
-.event-item:hover {
- border-color: var(--border);
-}
-
-.event-info {
- display: flex;
- flex-direction: column;
- gap: 2px;
-}
-
-.event-title {
- font-weight: 600;
- font-size: 0.85rem;
-}
-
-.event-time {
- font-size: 0.75rem;
- color: var(--muted);
-}
-
-.event-dot {
- width: 10px;
- height: 10px;
- border-radius: 50%;
- flex-shrink: 0;
-}
-
-.status-row {
- display: flex;
- justify-content: space-between;
- font-size: 0.8rem;
- color: var(--muted);
-}
-
-.url-warning {
- margin: 0;
- font-size: 0.72rem;
- color: var(--danger);
-}
-
+
+.time-label {
+ border-right: 1px solid var(--border);
+ border-bottom: 1px solid var(--border);
+ padding: 4px 6px;
+ font-size: 0.68rem;
+ color: var(--muted);
+ text-align: right;
+ background: var(--panel);
+}
+
+.time-label.all-day-label {
+ text-align: center;
+ font-weight: 600;
+}
+
+.time-cell {
+ border-right: 1px solid var(--border);
+ border-bottom: 1px solid var(--border);
+ padding: 4px;
+ background: var(--panel);
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ overflow: hidden;
+}
+
+.time-cell.all-day {
+ background: var(--panel-2);
+}
+
+.time-event {
+ border-radius: 4px;
+ padding: 2px 6px;
+ font-size: 0.68rem;
+ color: #fff;
+ border: none;
+ text-align: left;
+ cursor: pointer;
+}
+
+.calendar-grid.year-view {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
+ gap: 16px;
+ padding: 16px;
+ overflow: auto;
+ background: var(--bg);
+}
+
+.mini-month {
+ border: 1px solid var(--border);
+ background: var(--panel);
+ border-radius: 8px;
+ padding: 12px;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+.mini-title {
+ font-size: 0.9rem;
+ font-weight: 600;
+ color: var(--text);
+}
+
+.mini-grid {
+ display: grid;
+ grid-template-columns: repeat(7, minmax(0, 1fr));
+ gap: 4px;
+}
+
+.mini-weekday {
+ font-size: 0.6rem;
+ text-align: center;
+ color: var(--muted);
+ text-transform: uppercase;
+}
+
+.mini-day {
+ border: none;
+ background: transparent;
+ color: var(--text);
+ font-size: 0.65rem;
+ padding: 4px 0;
+ border-radius: 4px;
+ position: relative;
+}
+
+.mini-day.is-outside {
+ color: var(--muted);
+}
+
+.mini-day.is-selected {
+ background: var(--accent-soft);
+}
+
+.mini-day:hover {
+ background: var(--panel-2);
+}
+
+.mini-dot {
+ position: absolute;
+ bottom: 2px;
+ left: 50%;
+ width: 4px;
+ height: 4px;
+ background: var(--accent);
+ border-radius: 50%;
+ transform: translateX(-50%);
+}
+
+.side-card {
+ border: 1px solid var(--border);
+ border-radius: 8px;
+ padding: 12px;
+ background: var(--panel);
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+}
+
+.side-card.danger {
+ border-color: rgba(217, 48, 37, 0.4);
+}
+
+.side-title {
+ margin: 0;
+ font-size: 0.9rem;
+ font-weight: 600;
+}
+
+.event-list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ min-height: 120px;
+}
+
+.event-item {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ padding: 8px 10px;
+ border-radius: 6px;
+ border: 1px solid var(--border-soft);
+ background: var(--panel-2);
+ cursor: pointer;
+}
+
+.event-item:hover {
+ border-color: var(--border);
+}
+
+.event-info {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.event-title {
+ font-weight: 600;
+ font-size: 0.85rem;
+}
+
+.event-time {
+ font-size: 0.75rem;
+ color: var(--muted);
+}
+
+.event-dot {
+ width: 10px;
+ height: 10px;
+ border-radius: 50%;
+ flex-shrink: 0;
+}
+
+.status-row {
+ display: flex;
+ justify-content: space-between;
+ font-size: 0.8rem;
+ color: var(--muted);
+}
+
+.url-warning {
+ margin: 0;
+ font-size: 0.72rem;
+ color: var(--danger);
+}
+
.stacked-actions {
display: flex;
flex-direction: column;
@@ -1142,13 +1156,13 @@ button:disabled {
.modal.hidden {
display: none;
}
-
-.modal-backdrop {
- position: absolute;
- inset: 0;
- background: rgba(32, 33, 36, 0.6);
-}
-
+
+.modal-backdrop {
+ position: absolute;
+ inset: 0;
+ background: rgba(32, 33, 36, 0.6);
+}
+
.modal-card {
position: relative;
background: var(--panel);
@@ -1212,22 +1226,22 @@ button:disabled {
.qr-modal-actions {
justify-content: center;
}
-
-.modal-header {
- display: flex;
- justify-content: space-between;
- align-items: center;
- gap: 12px;
- margin-bottom: 12px;
-}
-
-.icon-btn {
- width: 32px;
- height: 32px;
- border-radius: 50%;
- padding: 0;
-}
-
+
+.modal-header {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+ gap: 12px;
+ margin-bottom: 12px;
+}
+
+.icon-btn {
+ width: 32px;
+ height: 32px;
+ border-radius: 50%;
+ padding: 0;
+}
+
.modal-form {
display: flex;
flex-direction: column;
@@ -1240,15 +1254,15 @@ button:disabled {
resize: vertical;
white-space: pre;
}
-
-.field {
- display: flex;
- flex-direction: column;
- gap: 6px;
- font-size: 0.8rem;
- color: var(--muted);
-}
-
+
+.field {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+ font-size: 0.8rem;
+ color: var(--muted);
+}
+
.field input,
.field select,
.field textarea {
@@ -1266,82 +1280,82 @@ button:disabled {
outline: 2px solid var(--accent-soft);
border-color: var(--accent);
}
-
-.field-row {
- display: grid;
- grid-template-columns: repeat(2, minmax(0, 1fr));
- gap: 12px;
-}
-
-.checkbox-field {
- flex-direction: row;
- align-items: center;
- gap: 10px;
- color: var(--text);
-}
-
-.color-palette {
- display: flex;
- gap: 8px;
- flex-wrap: wrap;
-}
-
-.color-swatch {
- width: 20px;
- height: 20px;
- border-radius: 50%;
- border: 2px solid transparent;
- cursor: pointer;
-}
-
-.color-swatch.active {
- border-color: var(--accent);
-}
-
-.modal-actions {
- display: flex;
- align-items: center;
- justify-content: space-between;
- gap: 12px;
- margin-top: 4px;
-}
-
-.modal-actions-right {
- display: flex;
- gap: 8px;
-}
-
-.modal-note {
- margin: 0;
- font-size: 0.78rem;
- color: var(--muted);
-}
-
-.modal-error {
- margin: 0;
- font-size: 0.75rem;
- color: var(--danger);
-}
-
-.locked-overlay {
- position: absolute;
- inset: 0;
- display: grid;
- place-items: center;
- background: rgba(32, 33, 36, 0.4);
- z-index: 5;
-}
-
-.locked-overlay.hidden {
- display: none;
-}
-
+
+.field-row {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 12px;
+}
+
+.checkbox-field {
+ flex-direction: row;
+ align-items: center;
+ gap: 10px;
+ color: var(--text);
+}
+
+.color-palette {
+ display: flex;
+ gap: 8px;
+ flex-wrap: wrap;
+}
+
+.color-swatch {
+ width: 20px;
+ height: 20px;
+ border-radius: 50%;
+ border: 2px solid transparent;
+ cursor: pointer;
+}
+
+.color-swatch.active {
+ border-color: var(--accent);
+}
+
+.modal-actions {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ margin-top: 4px;
+}
+
+.modal-actions-right {
+ display: flex;
+ gap: 8px;
+}
+
+.modal-note {
+ margin: 0;
+ font-size: 0.78rem;
+ color: var(--muted);
+}
+
+.modal-error {
+ margin: 0;
+ font-size: 0.75rem;
+ color: var(--danger);
+}
+
+.locked-overlay {
+ position: absolute;
+ inset: 0;
+ display: grid;
+ place-items: center;
+ background: rgba(32, 33, 36, 0.4);
+ z-index: 5;
+}
+
+.locked-overlay.hidden {
+ display: none;
+}
+
.locked-card {
background: var(--panel);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
- text-align: center;
+ text-align: center;
width: min(320px, 80%);
box-shadow: var(--shadow-md);
}
@@ -1389,61 +1403,194 @@ button:disabled {
position: fixed;
bottom: 24px;
right: 24px;
- display: flex;
- flex-direction: column;
- gap: 10px;
- z-index: 40;
-}
-
-.toast {
- background: var(--panel);
- color: var(--text);
- padding: 10px 14px;
- border-radius: 8px;
- border: 1px solid var(--border);
- box-shadow: var(--shadow-sm);
- min-width: 200px;
-}
-
-.toast.success {
- border-color: rgba(52, 168, 83, 0.6);
-}
-
-.toast.error {
- border-color: rgba(217, 48, 37, 0.6);
-}
-
-.hidden {
- display: none !important;
-}
-
-@media (max-width: 1024px) {
+ display: flex;
+ flex-direction: column;
+ gap: 10px;
+ z-index: 40;
+}
+
+.toast {
+ background: var(--panel);
+ color: var(--text);
+ padding: 10px 14px;
+ border-radius: 8px;
+ border: 1px solid var(--border);
+ box-shadow: var(--shadow-sm);
+ min-width: 200px;
+}
+
+.toast.success {
+ border-color: rgba(52, 168, 83, 0.6);
+}
+
+.toast.error {
+ border-color: rgba(217, 48, 37, 0.6);
+}
+
+.hidden {
+ display: none !important;
+}
+
+.mobile-only {
+ display: none;
+}
+
+@media (max-width: 1100px) {
+ .desktop-only {
+ display: none !important;
+ }
+
+ .mobile-only {
+ display: block;
+ }
+
+ .topbar {
+ padding: 0 16px;
+ }
+
+ .brand-subtitle {
+ display: none;
+ }
+
+ .secondary-actions {
+ position: fixed;
+ top: 64px;
+ right: 16px;
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 16px;
+ flex-direction: column;
+ align-items: stretch;
+ box-shadow: var(--shadow-md);
+ z-index: 100;
+ opacity: 0;
+ visibility: hidden;
+ transform: translateY(-10px);
+ transition: all 0.2s ease;
+ }
+
+ .secondary-actions.is-active {
+ opacity: 1;
+ visibility: visible;
+ transform: translateY(0);
+ }
+
+ .secondary-actions .view-toggle {
+ flex-direction: column;
+ width: 100%;
+ border-radius: 8px;
+ }
+
+ .secondary-actions .view-toggle button {
+ width: 100%;
+ padding: 10px;
+ text-align: left;
+ border-radius: 0;
+ border-bottom: 1px solid var(--border-soft);
+ }
+
+ .secondary-actions .view-toggle button:last-child {
+ border-bottom: none;
+ }
+
+ .secondary-actions button,
+ .secondary-actions .action-link {
+ width: 100%;
+ justify-content: flex-start;
+ }
+
.layout {
grid-template-columns: 1fr;
- grid-template-areas:
- "calendar"
- "side"
- "tz";
+ grid-template-areas: "calendar";
+ position: relative;
+ overflow: hidden;
}
- .side-panel {
- order: 0;
- border-right: none;
- border-bottom: 1px solid var(--border);
- flex-direction: row;
- flex-wrap: wrap;
+ .side-panel,
+ .tz-sidebar {
+ position: absolute;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ z-index: 20;
+ background: var(--panel);
+ transform: translateX(100%);
+ transition: transform 0.3s ease;
+ border: none;
}
- .side-card {
- flex: 1 1 280px;
+ .side-panel.is-active,
+ .tz-sidebar.is-active {
+ transform: translateX(0);
}
- .tz-sidebar {
- border-left: none;
- border-top: 1px solid var(--border);
+ .calendar-panel {
+ height: 100%;
+ overflow: hidden;
+ }
+
+ .panel-header {
+ padding: 12px 16px;
+ }
+
+ .month-label {
+ font-size: 1.2rem;
+ }
+
+ .panel-actions {
+ width: 100%;
+ justify-content: space-between;
+ }
+
+ .calendar-grid.month-view {
+ font-size: 0.8rem;
+ }
+
+ .day-cell {
+ padding: 4px;
+ }
+
+ .event-chip {
+ padding: 1px 4px;
+ font-size: 0.6rem;
+ }
+
+ .side-close {
+ position: absolute;
+ top: 12px;
+ right: 12px;
+ z-index: 30;
+ width: 36px;
+ height: 36px;
+ border-radius: 50%;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ background: var(--panel-2);
+ border: 1px solid var(--border);
+ color: var(--text);
+ cursor: pointer;
+ box-shadow: var(--shadow-sm);
+ }
+
+ .side-close:hover {
+ background: var(--bg);
}
}
-
+
+@media (max-width: 480px) {
+ .brand-text {
+ display: none;
+ }
+
+ .nav-group button {
+ padding: 7px 10px;
+ font-size: 0.8rem;
+ }
+}
+
@media (max-width: 720px) {
.topbar {
height: auto;
@@ -1467,11 +1614,11 @@ button:disabled {
max-width: 100%;
white-space: normal;
}
-
- .layout {
- grid-template-columns: 1fr;
- }
-
+
+ .layout {
+ grid-template-columns: 1fr;
+ }
+
.panel-header {
flex-direction: column;
align-items: flex-start;