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

time zone.

Supun Lakmaldbe629d3aa7c
diff --git a/favicon.ico b/favicon.ico
index 9d8459d..8fe3dd6 100644
Binary files a/favicon.ico and b/favicon.ico differ
diff --git a/index.html b/index.html
index b906c54..bce2376 100644
--- a/index.html
+++ b/index.html
@@ -61,6 +61,15 @@
</head>
<body>
+ <div id="mobile-warning" class="mobile-warning hidden" role="status" aria-live="polite">
+ <div class="mobile-warning-card">
+ <div class="mobile-warning-copy">
+ <span class="mobile-warning-title">Mobile view notice</span>
+ <span class="mobile-warning-text">This app isn't optimized for mobile and tab view yet.</span>
+ </div>
+ <button id="mobile-warning-dismiss" type="button" class="ghost">Got it</button>
+ </div>
+ </div>
<div class="app">
<header class="topbar">
<div class="brand">
@@ -154,6 +163,17 @@
<button id="clear-all" type="button" class="danger-btn">Clear calendar</button>
</div>
</aside>
+
+ <aside id="timezone-ruler" class="tz-sidebar">
+ <div class="tz-header">
+ <div>
+ <h4 class="tz-title">World Clock</h4>
+ <p class="tz-subtitle">Local time plus saved zones</p>
+ </div>
+ <button id="add-tz-btn" type="button" class="icon-btn tz-add" aria-label="Add timezone">+</button>
+ </div>
+ <div id="tz-list" class="tz-list" aria-live="polite"></div>
+ </aside>
</main>
</div>
@@ -307,6 +327,21 @@
</div>
</div>
+ <dialog id="tz-modal" class="tz-modal" aria-labelledby="tz-modal-title">
+ <div class="tz-modal-card">
+ <header class="tz-modal-header">
+ <h3 id="tz-modal-title">Select timezone</h3>
+ <button id="close-tz-modal" type="button" class="icon-btn" aria-label="Close">x</button>
+ </header>
+ <label class="field">
+ <span>Search</span>
+ <input type="text" id="tz-search" placeholder="Search (e.g. London)" autocomplete="off">
+ </label>
+ <ul id="tz-results" class="tz-results" role="listbox"></ul>
+ <p id="tz-empty" class="tz-empty hidden">No matches yet. Try a city, region, or UTC+5:30.</p>
+ </div>
+ </dialog>
+
<div id="toast-container" class="toast-container" aria-live="polite" aria-atomic="true"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
diff --git a/modules/hashcalUrlManager.js b/modules/hashcalUrlManager.js
index 88763cb..ab2a75d 100644
--- a/modules/hashcalUrlManager.js
+++ b/modules/hashcalUrlManager.js
@@ -49,9 +49,13 @@ function compactState(state) {
out.s = state.s;
}
}
-
- return out;
-}
+
+ if (Array.isArray(state.timezones) && state.timezones.length) {
+ out.z = state.timezones;
+ }
+
+ return out;
+}
function ensureLzString() {
if (!window.LZString) {
diff --git a/modules/timezoneManager.js b/modules/timezoneManager.js
new file mode 100644
index 0000000..64e3ace
--- /dev/null
+++ b/modules/timezoneManager.js
@@ -0,0 +1,97 @@
+const supportedZones =
+ typeof Intl.supportedValuesOf === "function" ? Intl.supportedValuesOf("timeZone") : [];
+
+export const AVAILABLE_ZONES = Array.isArray(supportedZones) ? supportedZones : [];
+
+function formatDateKey(date, timeZone) {
+ const options = {
+ year: "numeric",
+ month: "2-digit",
+ day: "2-digit",
+ };
+ if (timeZone) options.timeZone = timeZone;
+ const formatter = new Intl.DateTimeFormat("en-US", options);
+ const parts = formatter.formatToParts(date);
+ const lookup = {};
+ parts.forEach((part) => {
+ if (part.type !== "literal") {
+ lookup[part.type] = part.value;
+ }
+ });
+ return `${lookup.year}-${lookup.month}-${lookup.day}`;
+}
+
+function getOffsetMinutes(date, timeZone) {
+ const formatter = new Intl.DateTimeFormat("en-US", {
+ timeZone,
+ year: "numeric",
+ month: "2-digit",
+ day: "2-digit",
+ hour: "2-digit",
+ minute: "2-digit",
+ second: "2-digit",
+ hour12: false,
+ });
+ const parts = formatter.formatToParts(date);
+ const lookup = {};
+ parts.forEach((part) => {
+ if (part.type !== "literal") {
+ lookup[part.type] = part.value;
+ }
+ });
+ const hourValue = lookup.hour === "24" ? "00" : lookup.hour;
+ const asUtc = Date.UTC(
+ Number(lookup.year),
+ Number(lookup.month) - 1,
+ Number(lookup.day),
+ Number(hourValue),
+ Number(lookup.minute),
+ Number(lookup.second),
+ );
+ return Math.round((asUtc - date.getTime()) / 60000);
+}
+
+function formatUtcOffset(offsetMinutes) {
+ const sign = offsetMinutes >= 0 ? "+" : "-";
+ const absMinutes = Math.abs(offsetMinutes);
+ const hours = Math.floor(absMinutes / 60);
+ const minutes = absMinutes % 60;
+ return `${sign}${hours}:${String(minutes).padStart(2, "0")}`;
+}
+
+export function getZoneInfo(zoneName) {
+ const now = new Date();
+
+ const timeFormatter = new Intl.DateTimeFormat(undefined, {
+ timeZone: zoneName,
+ hour: "numeric",
+ minute: "2-digit",
+ });
+
+ const localDateKey = formatDateKey(now);
+ const targetDateKey = formatDateKey(now, zoneName);
+ const offsetMinutes = getOffsetMinutes(now, zoneName);
+ const offsetLabel = formatUtcOffset(offsetMinutes);
+
+ let dayDiffLabel = "";
+ if (targetDateKey > localDateKey) dayDiffLabel = "Tomorrow";
+ else if (targetDateKey < localDateKey) dayDiffLabel = "Yesterday";
+
+ return {
+ name: zoneName.split("/").pop().replace(/_/g, " "),
+ fullZone: zoneName,
+ time: timeFormatter.format(now),
+ dayDiff: dayDiffLabel,
+ offset: offsetLabel,
+ };
+}
+
+export function isValidZone(zoneName) {
+ if (!zoneName || typeof zoneName !== "string") return false;
+ try {
+ Intl.DateTimeFormat(undefined, { timeZone: zoneName });
+ return true;
+ } catch (error) {
+ return false;
+ }
+}
diff --git a/script.js b/script.js
index 1c23014..ad77770 100644
--- a/script.js
+++ b/script.js
@@ -4,6 +4,7 @@ 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,
@@ -18,8 +19,8 @@ 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",
+const DEFAULT_STATE = {
+ t: "hash-calendar",
c: DEFAULT_COLORS,
e: [],
s: {
@@ -27,24 +28,30 @@ const DEFAULT_STATE = {
m: 0,
v: DEFAULT_VIEW,
},
+ timezones: [],
};
-
-const DEBOUNCE_MS = 500;
-const MAX_TITLE_LENGTH = 60;
+
+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 password = null;
-let lockState = { encrypted: false, unlocked: true };
-let saveTimer = 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 = {};
@@ -113,6 +120,21 @@ function applyStoredView() {
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;
@@ -157,11 +179,18 @@ function normalizeState(raw) {
next.s.m = raw.s.m ? 1 : 0;
next.s.v = getStoredView(raw.s.v);
}
-
- return next;
-}
+
+ 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");
@@ -221,12 +250,21 @@ 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.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;
@@ -239,9 +277,302 @@ function showToast(message, type = "info") {
}, 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 (!state.e.length) {
+ if (!hasStoredData()) {
if (window.location.hash) clearHash();
updateUrlLength();
if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
@@ -258,7 +589,7 @@ async function persistStateToHash() {
function scheduleSave() {
if (lockState.encrypted && !lockState.unlocked) return;
- if (!state.e.length) {
+ if (!hasStoredData()) {
if (saveTimer) {
window.clearTimeout(saveTimer);
saveTimer = null;
@@ -472,8 +803,9 @@ function render() {
}
}
- renderEventList();
- updateUrlLength();
+ renderEventList();
+ renderTimezones();
+ updateUrlLength();
if (ui.jsonModal && !ui.jsonModal.classList.contains("hidden")) {
updateJsonModal();
}
@@ -996,8 +1328,9 @@ function handleClearAll() {
render();
}
-function bindEvents() {
- 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);
@@ -1030,10 +1363,20 @@ 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.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);
@@ -1053,18 +1396,20 @@ async function init() {
onToggle: updateFocusButton,
});
bindEvents();
+ initMobileWarning();
await loadStateFromHash();
- if (!isEncryptedHash() && !state.e.length && window.location.hash) {
+ if (!isEncryptedHash() && !hasStoredData() && window.location.hash) {
clearHash();
}
updateViewButtons();
updateFocusButton(false);
render();
-
- if (isEncryptedHash() && !lockState.unlocked) {
- attemptUnlock();
- }
+ initTimezones();
+
+ if (isEncryptedHash() && !lockState.unlocked) {
+ attemptUnlock();
+ }
}
if (document.readyState === "loading") {
diff --git a/styles.css b/styles.css
index ec128b4..5b7cb44 100644
--- a/styles.css
+++ b/styles.css
@@ -321,35 +321,174 @@ button:disabled {
box-shadow: none;
}
-.layout {
- flex: 1;
- min-height: 0;
- display: grid;
- grid-template-columns: 280px 1fr;
-}
-
-.side-panel {
- order: -1;
- background: var(--panel);
- border-right: 1px solid var(--border);
- padding: 16px;
- display: flex;
+.layout {
+ flex: 1;
+ min-height: 0;
+ display: grid;
+ grid-template-columns: 280px minmax(0, 1fr) 260px;
+ grid-template-areas: "side calendar tz";
+}
+
+.side-panel {
+ grid-area: side;
+ order: -1;
+ background: var(--panel);
+ border-right: 1px solid var(--border);
+ padding: 16px;
+ display: flex;
flex-direction: column;
gap: 16px;
overflow-y: auto;
-}
-
-.calendar-panel {
- background: var(--panel);
- display: flex;
- flex-direction: column;
- min-height: 0;
-}
-
-.panel-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
+}
+
+.calendar-panel {
+ grid-area: calendar;
+ background: var(--panel);
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ min-height: 0;
+}
+
+.tz-sidebar {
+ grid-area: tz;
+ background: var(--panel);
+ border-left: 1px solid var(--border);
+ padding: 16px;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ overflow: hidden;
+}
+
+.tz-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.tz-title {
+ margin: 0;
+ font-size: 0.9rem;
+ font-weight: 600;
+}
+
+.tz-subtitle {
+ margin: 0;
+ font-size: 0.72rem;
+ color: var(--muted);
+}
+
+.tz-add {
+ font-size: 1rem;
+ line-height: 1;
+}
+
+.tz-list {
+ flex: 1;
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ overflow-y: auto;
+ padding-right: 4px;
+}
+
+.tz-card {
+ background: var(--panel-2);
+ padding: 10px 12px;
+ border-radius: 10px;
+ border: 1px solid var(--border-soft);
+ border-left: 4px solid var(--border);
+ box-shadow: var(--shadow-sm);
+ position: relative;
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+}
+
+.tz-card.is-local {
+ border-left-color: var(--accent);
+}
+
+.tz-name {
+ font-size: 0.72rem;
+ text-transform: uppercase;
+ letter-spacing: 0.08em;
+ color: var(--muted);
+ font-weight: 600;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+}
+
+.tz-label {
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+
+.tz-offset {
+ color: var(--muted);
+ white-space: nowrap;
+ text-transform: none;
+ letter-spacing: 0;
+ font-variant-numeric: tabular-nums;
+}
+
+.tz-time {
+ font-size: 1.4rem;
+ font-weight: 700;
+ color: var(--text);
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+}
+
+.tz-diff {
+ color: var(--danger);
+ font-size: 0.72rem;
+ font-weight: 600;
+}
+
+.tz-remove {
+ position: absolute;
+ top: 6px;
+ right: 6px;
+ padding: 0;
+ width: 28px;
+ height: 28px;
+ border-radius: 50%;
+ border: none;
+ background: transparent;
+ color: var(--muted);
+ opacity: 0;
+ transition: opacity 0.2s ease;
+}
+
+.tz-card:hover .tz-remove {
+ opacity: 1;
+}
+
+.tz-remove:focus-visible {
+ opacity: 1;
+}
+
+.tz-remove:hover {
+ background: transparent;
+ box-shadow: none;
+}
+
+.tz-empty {
+ margin: 0;
+ font-size: 0.78rem;
+ color: var(--muted);
+}
+
+.panel-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
gap: 16px;
padding: 16px 20px 12px;
border-bottom: 1px solid var(--border);
@@ -924,13 +1063,85 @@ button:disabled {
inset: 0;
display: flex;
align-items: center;
- justify-content: center;
- z-index: 20;
-}
-
-.modal.hidden {
- display: none;
-}
+ justify-content: center;
+ z-index: 20;
+}
+
+.tz-modal {
+ border: none;
+ padding: 0;
+ background: transparent;
+ margin: auto;
+}
+
+.tz-modal::backdrop {
+ background: rgba(32, 33, 36, 0.6);
+}
+
+.tz-modal-card {
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 18px;
+ width: min(420px, 92vw);
+ box-shadow: var(--shadow-md);
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+}
+
+.tz-modal-header {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+}
+
+.tz-results {
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ max-height: 260px;
+ overflow-y: auto;
+}
+
+.tz-result-btn {
+ width: 100%;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 10px;
+ text-align: left;
+ padding: 8px 10px;
+ border-radius: 8px;
+ border: 1px solid var(--border-soft);
+ background: var(--panel-2);
+ font-size: 0.82rem;
+ color: var(--text);
+}
+
+.tz-result-btn:hover {
+ border-color: var(--border);
+}
+
+.tz-result-name {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.tz-result-offset {
+ color: var(--muted);
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+}
+
+.modal.hidden {
+ display: none;
+}
.modal-backdrop {
position: absolute;
@@ -1125,20 +1336,59 @@ button:disabled {
display: none;
}
-.locked-card {
- background: var(--panel);
- border: 1px solid var(--border);
- border-radius: 12px;
- padding: 20px;
+.locked-card {
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ padding: 20px;
text-align: center;
- width: min(320px, 80%);
- box-shadow: var(--shadow-md);
-}
-
-.toast-container {
- position: fixed;
- bottom: 24px;
- right: 24px;
+ width: min(320px, 80%);
+ box-shadow: var(--shadow-md);
+}
+
+.mobile-warning {
+ position: fixed;
+ inset: 0;
+ display: none;
+ align-items: center;
+ justify-content: center;
+ background: rgba(32, 33, 36, 0.45);
+ z-index: 40;
+}
+
+.mobile-warning-card {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 12px;
+ width: min(520px, 92vw);
+ background: var(--panel);
+ border: 1px solid var(--border);
+ border-radius: 12px;
+ box-shadow: var(--shadow-md);
+ padding: 12px 14px;
+}
+
+.mobile-warning-copy {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+}
+
+.mobile-warning-title {
+ font-size: 0.86rem;
+ font-weight: 600;
+}
+
+.mobile-warning-text {
+ font-size: 0.78rem;
+ color: var(--muted);
+}
+
+.toast-container {
+ position: fixed;
+ bottom: 24px;
+ right: 24px;
display: flex;
flex-direction: column;
gap: 10px;
@@ -1167,23 +1417,32 @@ button:disabled {
display: none !important;
}
-@media (max-width: 1024px) {
- .layout {
- grid-template-columns: 1fr;
- }
-
- .side-panel {
- order: 0;
- border-right: none;
- border-bottom: 1px solid var(--border);
- flex-direction: row;
- flex-wrap: wrap;
- }
-
- .side-card {
- flex: 1 1 280px;
- }
-}
+@media (max-width: 1024px) {
+ .layout {
+ grid-template-columns: 1fr;
+ grid-template-areas:
+ "calendar"
+ "side"
+ "tz";
+ }
+
+ .side-panel {
+ order: 0;
+ border-right: none;
+ border-bottom: 1px solid var(--border);
+ flex-direction: row;
+ flex-wrap: wrap;
+ }
+
+ .side-card {
+ flex: 1 1 280px;
+ }
+
+ .tz-sidebar {
+ border-left: none;
+ border-top: 1px solid var(--border);
+ }
+}
@media (max-width: 720px) {
.topbar {
@@ -1258,4 +1517,19 @@ button:disabled {
.agenda-time {
font-size: 0.68rem;
}
+
+ .mobile-warning-card {
+ flex-direction: column;
+ align-items: flex-start;
+ }
+
+ .mobile-warning-card button {
+ align-self: stretch;
+ }
+}
+
+@media (max-width: 1024px) {
+ .mobile-warning {
+ display: flex;
+ }
}