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
Add read only mode
Supun Lakmal0a115e85fd3f
diff --git a/index.html b/index.htmlindex c0bd635..f2954b7 100644--- a/index.html+++ b/index.html@@ -111,6 +111,7 @@<button id="copy-link" type="button" data-i18n="btn.copyLink">Copy link</button><button id="share-qr" type="button" data-i18n="btn.shareQr">Share QR</button><button id="lock-btn" type="button" data-i18n="btn.lock">Lock</button>+ <button id="readonly-btn" type="button" data-i18n="btn.readOnly" aria-pressed="false">Read only</button><button id="world-planner-btn" type="button" class="accent-btn" aria-label="Open World Planner"data-i18n-aria-label="btn.worldPlanner"><i class="fa-solid fa-earth-americas"></i> <span data-i18n="btn.worldPlanner">Planner</span>@@ -551,6 +552,9 @@<button id="mobile-theme-toggle" type="button" class="mobile-drawer-item"><i class="fa-solid fa-circle-half-stroke"></i> <span>Theme: Light</span></button>+ <button id="mobile-readonly-btn" type="button" class="mobile-drawer-item" aria-pressed="false">+ <i class="fa-solid fa-pen"></i> <span data-i18n="btn.readOnly">Read only</span>+ </button><div class="mobile-drawer-item mobile-language-picker dropdown-container"><button id="mobile-language-btn" class="dropdown-trigger" type="button" aria-haspopup="listbox"aria-expanded="false"diff --git a/locales/en.js b/locales/en.jsindex 505812b..f85ce9b 100644--- a/locales/en.js+++ b/locales/en.js@@ -20,6 +20,8 @@ export default {"btn.lock": "Lock","btn.unlock": "Unlock","btn.removeLock": "Remove lock",+ "btn.readOnly": "Read only",+ "btn.editMode": "Edit mode","btn.focus": "Focus","btn.exitFocus": "Exit focus","btn.save": "Save",@@ -130,6 +132,9 @@ export default {"toast.lockRemoved": "Lock removed","toast.calendarLocked": "Calendar locked","toast.calendarUnlocked": "Calendar unlocked",+ "toast.readOnlyEnabled": "Read-only mode enabled",+ "toast.editModeEnabled": "Edit mode enabled",+ "toast.readOnlyActive": "Read-only mode is on. Switch back to edit mode to make changes.","toast.incorrectPassword": "Incorrect password","toast.unableToCopyLink": "Unable to copy link","toast.unableToCopyJson": "Unable to copy JSON",diff --git a/locales/it.js b/locales/it.jsindex 6d99753..9dde438 100644--- a/locales/it.js+++ b/locales/it.js@@ -20,6 +20,8 @@ export default {'btn.lock': 'Blocca','btn.unlock': 'Sblocca','btn.removeLock': 'Rimuovi blocco',+ 'btn.readOnly': 'Sola lettura',+ 'btn.editMode': 'Modalita modifica','btn.focus': 'Concentra','btn.exitFocus': 'Esci da Focus','btn.save': 'Salva',@@ -130,6 +132,9 @@ export default {'toast.lockRemoved': 'Blocco rimosso','toast.calendarLocked': 'Calendario bloccato','toast.calendarUnlocked': 'Calendario sbloccato',+ 'toast.readOnlyEnabled': 'Modalita sola lettura attivata',+ 'toast.editModeEnabled': 'Modalita modifica attivata',+ 'toast.readOnlyActive': 'La modalita sola lettura e attiva. Torna alla modalita modifica per fare cambiamenti.','toast.incorrectPassword': 'Password errata','toast.unableToCopyLink': 'Impossibile copiare il link','toast.unableToCopyJson': 'Impossibile copiare il JSON',diff --git a/locales/si.js b/locales/si.jsindex 699c31d..b187a7a 100644--- a/locales/si.js+++ b/locales/si.js@@ -20,6 +20,8 @@ export default {"btn.lock": "අගුළු දමන්න","btn.unlock": "අගුළු අරින්න","btn.removeLock": "අගුළ ඉවත් කරන්න",+ "btn.readOnly": "Read only",+ "btn.editMode": "Edit mode","btn.focus": "නාභිගත වන්න","btn.exitFocus": "නාභිගතයෙන් ඉවත් වන්න","btn.save": "සුරකින්න",@@ -130,6 +132,9 @@ export default {"toast.lockRemoved": "අගුළ ඉවත් කරන ලදී","toast.calendarLocked": "දිනදර්ශනය අගුළු දමන ලදී","toast.calendarUnlocked": "දිනදර්ශනය අගුළු ඇරිණි",+ "toast.readOnlyEnabled": "Read-only mode enabled",+ "toast.editModeEnabled": "Edit mode enabled",+ "toast.readOnlyActive": "Read-only mode is on. Switch back to edit mode to make changes.","toast.incorrectPassword": "වැරදි මුරපදයක්","toast.unableToCopyLink": "සබැඳිය පිටපත් කළ නොහැක","toast.unableToCopyJson": "JSON පිටපත් කළ නොහැක",diff --git a/locales/ta.js b/locales/ta.jsindex 1bb9bb1..af2978a 100644--- a/locales/ta.js+++ b/locales/ta.js@@ -20,6 +20,8 @@ export default {'btn.lock': 'பூட்டு','btn.unlock': 'திற','btn.removeLock': 'பூட்டை அகற்று',+ 'btn.readOnly': 'Read only',+ 'btn.editMode': 'Edit mode','btn.focus': 'கவனம்','btn.exitFocus': 'கவனத்திலிருந்து வெளியேறு','btn.save': 'சேமி',@@ -130,6 +132,9 @@ export default {'toast.lockRemoved': 'பூட்டு அகற்றப்பட்டது','toast.calendarLocked': 'நாட்காட்டி பூட்டப்பட்டது','toast.calendarUnlocked': 'நாட்காட்டி திறக்கப்பட்டது',+ 'toast.readOnlyEnabled': 'Read-only mode enabled',+ 'toast.editModeEnabled': 'Edit mode enabled',+ 'toast.readOnlyActive': 'Read-only mode is on. Switch back to edit mode to make changes.','toast.incorrectPassword': 'தவறான கடவுச்சொல்','toast.unableToCopyLink': 'இணைப்பை நகலெடுக்க முடியவில்லை','toast.unableToCopyJson': 'JSON ஐ நகலெடுக்க முடியவில்லை',diff --git a/script.js b/script.jsindex f5d8d60..4ff38bf 100644--- a/script.js+++ b/script.js@@ -34,15 +34,16 @@ const DEFAULT_STATE = {t: "hash-calendar",c: DEFAULT_COLORS,e: [],- s: {- d: 0,- m: 0,- v: DEFAULT_VIEW,- l: "en",- },- timezones: [],- mp: { h: null, z: [], s: null, d: null },-};+ s: {+ d: 0,+ m: 0,+ v: DEFAULT_VIEW,+ l: "en",+ r: 0,+ },+ timezones: [],+ mp: { h: null, z: [], s: null, d: null },+};const DEBOUNCE_MS = 500;const MAX_TITLE_LENGTH = 60;@@ -62,13 +63,32 @@ let passwordResolver = null;let passwordMode = "unlock";let focusMode = null;let qrManager = null;-let timezoneTimer = null;--const ui = {};--function cloneState(source) {- return JSON.parse(JSON.stringify(source));-}+let timezoneTimer = null;++const ui = {};++function isCalendarLocked() {+ return lockState.encrypted && !lockState.unlocked;+}++function isReadOnlyMode() {+ return !!(state && state.s && state.s.r);+}++function ensureEditable({ silent = false } = {}) {+ if (isCalendarLocked()) return false;+ if (isReadOnlyMode()) {+ if (!silent) {+ showToast(t("toast.readOnlyActive"), "info");+ }+ return false;+ }+ return true;+}++function cloneState(source) {+ return JSON.parse(JSON.stringify(source));+}function createRipple(event) {const button = event.target.closest("button");@@ -198,14 +218,15 @@ 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 (raw.s.l && typeof raw.s.l === "string") {- const allowed = SUPPORTED_LANGUAGES.map((lang) => lang.code);- next.s.l = allowed.includes(raw.s.l) ? raw.s.l : "en";- }+ 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.r = raw.s.r ? 1 : 0;+ next.s.v = getStoredView(raw.s.v);+ if (raw.s.l && typeof raw.s.l === "string") {+ const allowed = SUPPORTED_LANGUAGES.map((lang) => lang.code);+ next.s.l = allowed.includes(raw.s.l) ? raw.s.l : "en";+ }}if (Array.isArray(raw.timezones) || Array.isArray(raw.z) || Array.isArray(raw.tz)) {@@ -234,10 +255,11 @@ function cacheElements() {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.copyLinkBtn = document.getElementById("copy-link");+ ui.shareQrBtn = document.getElementById("share-qr");+ ui.lockBtn = document.getElementById("lock-btn");+ ui.readOnlyBtn = document.getElementById("readonly-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");@@ -340,9 +362,10 @@ function cacheElements() {ui.mobileDrawerViewButtons = Array.from(document.querySelectorAll(".mobile-drawer-view-toggle [data-view]"));- ui.mobileWeekstartToggle = document.getElementById("mobile-weekstart-toggle");- ui.mobileThemeToggle = document.getElementById("mobile-theme-toggle");- ui.mobileLangBtn = document.getElementById("mobile-language-btn");+ ui.mobileWeekstartToggle = document.getElementById("mobile-weekstart-toggle");+ ui.mobileThemeToggle = document.getElementById("mobile-theme-toggle");+ ui.mobileReadOnlyBtn = document.getElementById("mobile-readonly-btn");+ ui.mobileLangBtn = document.getElementById("mobile-language-btn");ui.mobileLangList = document.getElementById("mobile-language-list");ui.mobileCurrentLang = document.getElementById("mobile-current-lang");ui.mobileLangDropdown = document.getElementById("mobile-language-dropdown");@@ -429,10 +452,11 @@ function renderTimezones() {});}-function addTimezone(zoneStr) {- if (!zoneStr || !isValidZone(zoneStr)) return;- const localZone = getLocalZone();- if (zoneStr === localZone) return;+function addTimezone(zoneStr) {+ if (!ensureEditable()) return;+ 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);@@ -440,10 +464,11 @@ function addTimezone(zoneStr) {renderTimezones();}-function removeTimezone(zoneStr) {- if (!Array.isArray(state.timezones) || !zoneStr) return;- state.timezones = state.timezones.filter((zone) => zone !== zoneStr);- scheduleSave();+function removeTimezone(zoneStr) {+ if (!ensureEditable()) return;+ if (!Array.isArray(state.timezones) || !zoneStr) return;+ state.timezones = state.timezones.filter((zone) => zone !== zoneStr);+ scheduleSave();renderTimezones();}@@ -566,9 +591,10 @@ function handleTzSearch() {}}-function openTzModal() {- if (!ui.tzModal) return;- if (ui.tzSearch) ui.tzSearch.value = "";+function openTzModal() {+ if (!ensureEditable()) return;+ if (!ui.tzModal) return;+ if (ui.tzSearch) ui.tzSearch.value = "";if (ui.tzEmpty) {ui.tzEmpty.textContent = TZ_EMPTY_MESSAGE;ui.tzEmpty.classList.add("hidden");@@ -750,25 +776,54 @@ function setView(view) {}}-function updateLockUI() {- const isLocked = lockState.encrypted && !lockState.unlocked;- if (ui.lockBtn) {- if (lockState.encrypted) {- ui.lockBtn.textContent = t(isLocked ? "btn.unlock" : "btn.removeLock");- } else {- ui.lockBtn.textContent = t("btn.lock");- }- }- if (ui.lockedOverlay) {- ui.lockedOverlay.classList.toggle("hidden", !isLocked);- }- const disabled = isLocked;- [ui.addEventBtn, ui.addEventInline, ui.mobileAddEventInline, ui.copyLinkBtn, ui.shareQrBtn].forEach((btn) => {- if (btn) btn.disabled = disabled;- });-- // Mobile lock/unlock button visibility- if (ui.mobileLockBtn && ui.mobileUnlockBtn) {+function updateLockUI() {+ const isLocked = isCalendarLocked();+ const isReadOnly = isReadOnlyMode();+ const editDisabled = isLocked || isReadOnly;++ if (ui.lockBtn) {+ if (lockState.encrypted) {+ ui.lockBtn.textContent = t(isLocked ? "btn.unlock" : "btn.removeLock");+ } else {+ ui.lockBtn.textContent = t("btn.lock");+ }+ }++ if (ui.readOnlyBtn) {+ ui.readOnlyBtn.textContent = t(isReadOnly ? "btn.editMode" : "btn.readOnly");+ ui.readOnlyBtn.setAttribute("aria-pressed", isReadOnly ? "true" : "false");+ ui.readOnlyBtn.classList.toggle("is-active-toggle", isReadOnly);+ ui.readOnlyBtn.disabled = isLocked;+ }++ if (ui.mobileReadOnlyBtn) {+ const span = ui.mobileReadOnlyBtn.querySelector("span");+ if (span) {+ span.textContent = t(isReadOnly ? "btn.editMode" : "btn.readOnly");+ }+ ui.mobileReadOnlyBtn.setAttribute("aria-pressed", isReadOnly ? "true" : "false");+ ui.mobileReadOnlyBtn.classList.toggle("is-active-toggle", isReadOnly);+ ui.mobileReadOnlyBtn.disabled = isLocked;+ }++ if (ui.lockedOverlay) {+ ui.lockedOverlay.classList.toggle("hidden", !isLocked);+ }++ if (ui.titleInput) {+ ui.titleInput.readOnly = editDisabled;+ }++ [ui.addEventBtn, ui.addEventInline, ui.mobileAddEventInline, ui.mobileAddEvent, ui.importIcs, ui.mobileImportIcs, ui.clearAll, ui.mobileClearAll, ui.tzAddBtn, ui.mobileAddTzBtn].forEach((btn) => {+ if (btn) btn.disabled = editDisabled;+ });++ [ui.copyLinkBtn, ui.shareQrBtn, ui.mobileCopyLink, ui.mobileShareQr].forEach((btn) => {+ if (btn) btn.disabled = isLocked;+ });++ // Mobile lock/unlock button visibility+ if (ui.mobileLockBtn && ui.mobileUnlockBtn) {if (lockState.encrypted && lockState.unlocked) {// Show unlock (remove-lock) button, hide lockui.mobileLockBtn.classList.add("hidden");@@ -778,13 +833,17 @@ function updateLockUI() {ui.mobileLockBtn.classList.remove("hidden");ui.mobileUnlockBtn.classList.add("hidden");}- }-- // Disable mobile quick-action buttons when locked- [ui.mobileAddEvent, ui.mobileCopyLink, ui.mobileShareQr].forEach((btn) => {- if (btn) btn.disabled = disabled;- });-}+ }++}++function handleReadOnlyToggle() {+ if (!state || !state.s || isCalendarLocked()) return;+ state.s.r = state.s.r ? 0 : 1;+ updateLockUI();+ scheduleSave();+ showToast(t(state.s.r ? "toast.readOnlyEnabled" : "toast.editModeEnabled"), "success");+}function applyLanguageSelection(langCode) {if (!SUPPORTED_LANGUAGES.some((lang) => lang.code === langCode)) return;@@ -1137,9 +1196,10 @@ function handleSelectDay(date) {render();}-function openEventModal({ index = null, date = null } = {}) {- if (!ui.eventModal) return;- editingIndex = index;+function openEventModal({ index = null, date = null } = {}) {+ if (!ensureEditable()) return;+ if (!ui.eventModal) return;+ editingIndex = index;const isEditing = typeof index === "number";ui.eventModalTitle.textContent = t(isEditing ? "modal.editEvent" : "modal.addEvent");ui.eventDelete.classList.toggle("hidden", !isEditing);@@ -1219,9 +1279,10 @@ function renderColorPalette(activeColor) {});}-function saveEvent(event) {- event.preventDefault();- if (!ui.eventTitle || !ui.eventDate) return;+function saveEvent(event) {+ if (!ensureEditable()) return;+ event.preventDefault();+ if (!ui.eventTitle || !ui.eventDate) return;const title = ui.eventTitle.value.trim() || "Untitled";const dateValue = ui.eventDate.value;if (!dateValue) return;@@ -1263,9 +1324,10 @@ function saveEvent(event) {render();}-function deleteEvent() {- if (typeof editingIndex !== "number") return;- const confirmed = window.confirm(t("confirm.deleteEvent"));+function deleteEvent() {+ if (!ensureEditable()) return;+ if (typeof editingIndex !== "number") return;+ const confirmed = window.confirm(t("confirm.deleteEvent"));if (!confirmed) return;state.e.splice(editingIndex, 1);editingIndex = null;@@ -1412,11 +1474,15 @@ function handleHashChange() {loadStateFromHash().then(render);}-function handleTitleInput() {- if (!ui.titleInput) return;- state.t = ui.titleInput.value.slice(0, MAX_TITLE_LENGTH);- scheduleSave();-}+function handleTitleInput() {+ if (!ui.titleInput) return;+ if (!ensureEditable({ silent: true })) {+ ui.titleInput.value = state.t;+ return;+ }+ state.t = ui.titleInput.value.slice(0, MAX_TITLE_LENGTH);+ scheduleSave();+}function handleThemeToggle() {state.s.d = state.s.d ? 0 : 1;@@ -1562,13 +1628,15 @@ function handleExportJson() {URL.revokeObjectURL(url);}-function handleImportIcsClick() {- if (ui.icsInput) ui.icsInput.click();-}--function handleIcsFile(event) {- const file = event.target.files && event.target.files[0];- if (!file) return;+function handleImportIcsClick() {+ if (!ensureEditable()) return;+ if (ui.icsInput) ui.icsInput.click();+}++function handleIcsFile(event) {+ if (!ensureEditable()) return;+ const file = event.target.files && event.target.files[0];+ if (!file) return;const reader = new FileReader();reader.onload = () => {const text = String(reader.result || "");@@ -1600,10 +1668,11 @@ function handleIcsFile(event) {event.target.value = "";}-function handleClearAll() {- const confirmed = window.confirm(t("confirm.clearAll"));- if (!confirmed) return;- state.e = [];+function handleClearAll() {+ if (!ensureEditable()) return;+ const confirmed = window.confirm(t("confirm.clearAll"));+ if (!confirmed) return;+ state.e = [];scheduleSave();render();}@@ -1620,10 +1689,11 @@ function bindEvents() {}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.copyLinkBtn) ui.copyLinkBtn.addEventListener("click", handleCopyLink);+ if (ui.shareQrBtn) ui.shareQrBtn.addEventListener("click", handleShareQr);+ if (ui.lockBtn) ui.lockBtn.addEventListener("click", handleLockAction);+ if (ui.readOnlyBtn) ui.readOnlyBtn.addEventListener("click", handleReadOnlyToggle);+ if (ui.focusBtn) ui.focusBtn.addEventListener("click", handleFocusToggle);if (ui.weekstartToggle) ui.weekstartToggle.addEventListener("click", handleWeekStartToggle);if (ui.themeToggle) ui.themeToggle.addEventListener("click", handleThemeToggle);initLanguageDropdown();@@ -1754,9 +1824,15 @@ function initResponsiveFeatures() {if (ui.mobileWeekstartToggle) {ui.mobileWeekstartToggle.addEventListener("click", handleWeekStartToggle);}- if (ui.mobileThemeToggle) {- ui.mobileThemeToggle.addEventListener("click", handleThemeToggle);- }+ if (ui.mobileThemeToggle) {+ ui.mobileThemeToggle.addEventListener("click", handleThemeToggle);+ }+ if (ui.mobileReadOnlyBtn) {+ ui.mobileReadOnlyBtn.addEventListener("click", () => {+ handleReadOnlyToggle();+ closeMobileDrawer();+ });+ }// Drawer world planner buttonif (ui.mobileWorldPlannerBtn) {@@ -1881,34 +1957,39 @@ function initWorldPlanner() {ui.wpGrid.addEventListener("click", handleScrubberClick);ui.wpGrid.addEventListener("click", handlePlannerGridClick);}- if (ui.wpDatePicker) {- ui.wpDatePicker.addEventListener("change", (e) => {- if (!state.mp) state.mp = { h: null, z: [], s: null, d: null, f24: false };- state.mp.d = e.target.value;- scheduleSave();+ if (ui.wpDatePicker) {+ ui.wpDatePicker.addEventListener("change", (e) => {+ if (!ensureEditable()) {+ e.target.value = (state.mp && state.mp.d) || new Date().toISOString().split("T")[0];+ return;+ }+ if (!state.mp) state.mp = { h: null, z: [], s: null, d: null, f24: false };+ state.mp.d = e.target.value;+ scheduleSave();renderWorldPlanner();});}// Copy Link removed from UI}-function openWorldPlanner() {- if (!ui.worldPlannerModal) return;-- // Initialize state if empty- if (!state.mp || (!state.mp.h && !state.mp.z.length)) {- const local = getLocalZone();- state.mp = {- h: local,+function openWorldPlanner() {+ if (!ui.worldPlannerModal) return;+ const canEdit = ensureEditable({ silent: true });++ // Initialize state if empty+ if ((!state.mp || (!state.mp.h && !state.mp.z.length)) && canEdit) {+ const local = getLocalZone();+ state.mp = {+ h: local,z: ["UTC", "America/New_York", "Asia/Tokyo", "Europe/London"].filter(z => z !== local).slice(0, 3),s: null,d: new Date().toISOString().split("T")[0],f24: false // Default to 12h};- }-- // Ensure f24 exists for legacy states- if (state.mp.f24 === undefined) state.mp.f24 = false;+ }++ // Ensure f24 exists for legacy states+ if (state.mp.f24 === undefined && canEdit) state.mp.f24 = false;// Set date pickerif (ui.wpDatePicker) {@@ -1921,12 +2002,14 @@ function openWorldPlanner() {renderWorldPlanner();}-function closeWorldPlanner() {- if (ui.worldPlannerModal) {- ui.worldPlannerModal.classList.add("hidden");- }- scheduleSave();-}+function closeWorldPlanner() {+ if (ui.worldPlannerModal) {+ ui.worldPlannerModal.classList.add("hidden");+ }+ if (ensureEditable({ silent: true })) {+ scheduleSave();+ }+}function handleWpTzInput(e) {const term = e.target.value.trim().toLowerCase();@@ -2004,18 +2087,20 @@ function renderWpTzResults(results) {list.classList.remove("hidden");}-function addPlannerZone(zone) {- if (state.mp.h !== zone && !state.mp.z.includes(zone)) {- state.mp.z.push(zone);- scheduleSave();+function addPlannerZone(zone) {+ if (!ensureEditable()) return;+ if (state.mp.h !== zone && !state.mp.z.includes(zone)) {+ state.mp.z.push(zone);+ scheduleSave();renderWorldPlanner();}}-function handlePlannerGridClick(e) {- // Handle remove/promote buttons- const btn = e.target.closest(".wp-control-btn");- if (!btn) return;+function handlePlannerGridClick(e) {+ if (!ensureEditable()) return;+ // Handle remove/promote buttons+ const btn = e.target.closest(".wp-control-btn");+ if (!btn) return;const action = btn.dataset.action;const zone = btn.dataset.zone;@@ -2225,9 +2310,10 @@ function handleScrubberMove(e) {ghost.classList.remove("hidden");}-function handleScrubberClick(e) {- const cell = e.target.closest(".wp-cell");- if (!cell) return;+function handleScrubberClick(e) {+ if (!ensureEditable()) return;+ const cell = e.target.closest(".wp-cell");+ if (!cell) return;const hIndex = Number(cell.dataset.h);const baseDate = getPlannerDate();@@ -2260,9 +2346,10 @@ function updateScrubberPositionFromState() {}}-function togglePlannerFormat() {- if (!state.mp) return;- state.mp.f24 = !state.mp.f24;+function togglePlannerFormat() {+ if (!ensureEditable()) return;+ if (!state.mp) return;+ state.mp.f24 = !state.mp.f24;updatePlannerFormatBtn();scheduleSave();renderWorldPlanner();diff --git a/styles.css b/styles.cssindex 8e1869c..2fda575 100644--- a/styles.css+++ b/styles.css@@ -388,6 +388,13 @@ button.ghost {background: transparent;}+button.is-active-toggle,+.mobile-drawer-item.is-active-toggle {+ background: var(--accent-soft);+ border-color: var(--accent);+ color: var(--accent);+}+button.danger,.danger-btn {background: var(--danger);