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
Update html
Supun Lakmalc05741b7a310
diff --git a/index.html b/index.htmlindex 2952507..11900d6 100644--- a/index.html+++ b/index.html@@ -96,6 +96,14 @@</head><body>+ <div id="splash-loader" role="status" aria-label="Loading hash-calendar">+ <img src="logo.png" alt="" class="splash-logo">+ <div class="splash-title">hash-calendar</div>+ <div class="splash-dots">+ <span></span><span></span><span></span>+ </div>+ </div>+<div class="app"><header class="topbar"><div class="topbar-left">@@ -283,6 +291,9 @@<button id="mobile-share-qr" type="button" class="quick-action-btn" aria-label="Share QR"><i class="fa-solid fa-share-nodes"></i></button>+ <button id="mobile-embed-widget" type="button" class="quick-action-btn" aria-label="Embed widget">+ <i class="fa-solid fa-code"></i>+ </button><button id="mobile-lock-btn" type="button" class="quick-action-btn" aria-label="Lock"><i class="fa-solid fa-lock"></i></button>@@ -380,6 +391,9 @@<button id="share-qr" type="button" class="ghost w-100" data-i18n="btn.shareQr"><i class="fa-solid fa-qrcode"></i> <span>Share QR</span></button>+ <button id="embed-widget" type="button" class="ghost w-100" aria-label="Embed widget">+ <i class="fa-solid fa-code"></i> <span>Embed widget</span>+ </button></div><div class="side-card">@@ -725,6 +739,38 @@</div></div>+ <div id="embed-modal" class="modal hidden" role="dialog" aria-modal="true" aria-labelledby="embed-modal-title">+ <div class="modal-backdrop"></div>+ <div class="modal-card embed-modal-card">+ <header class="modal-header">+ <h3 id="embed-modal-title">Embed on your website</h3>+ <button id="embed-close" type="button" class="icon-btn" aria-label="Close">x</button>+ </header>+ <div class="modal-body">+ <p class="embed-helper">Copy this code and paste it into your website HTML. Tip: enable read-only mode first if+ you do not want viewers to edit.</p>+ <div class="field">+ <label for="embed-width">Width</label>+ <input id="embed-width" type="text" value="100%" placeholder="e.g. 100%, 600px">+ </div>+ <div class="field">+ <label for="embed-height">Height</label>+ <input id="embed-height" type="text" value="600px" placeholder="e.g. 600px, 80vh">+ </div>+ <div class="field">+ <label for="embed-code">Embed code</label>+ <textarea id="embed-code" class="embed-code-textarea" readonly rows="4"></textarea>+ </div>+ </div>+ <div class="modal-actions">+ <span></span>+ <button id="embed-copy" type="button" class="primary">+ <i class="fa-solid fa-copy"></i> Copy embed code+ </button>+ </div>+ </div>+ </div>+<div id="app-launcher-modal" class="modal hidden" role="dialog" aria-modal="true"aria-labelledby="app-launcher-modal-title"><div class="modal-backdrop"></div>@@ -917,6 +963,10 @@<i class="fa-solid fa-images" aria-hidden="true"></i><span class="stacked-action-label" data-i18n="btn.templateGallery">Template gallery</span></button>+ <button id="mobile-drawer-embed-widget" type="button" class="ghost" aria-label="Embed widget">+ <i class="fa-solid fa-code" aria-hidden="true"></i>+ <span class="stacked-action-label">Embed widget</span>+ </button></div></div></div>diff --git a/modules/i18n.js b/modules/i18n.jsindex 427320a..864b0b1 100644--- a/modules/i18n.js+++ b/modules/i18n.js@@ -2,9 +2,9 @@ import en from "../locales/en.js";import si from "../locales/si.js";import ta from "../locales/ta.js";import it from "../locales/it.js";-import it from "../locales/fr.js";+import fr from "../locales/fr.js";-const translations = { en, si, ta, it };+const translations = { en, si, ta, it, fr };export const SUPPORTED_LANGUAGES = [{ code: "en", nameKey: "lang.en" },{ code: "si", nameKey: "lang.si" },diff --git a/script.js b/script.jsindex 5066026..9892297 100644--- a/script.js+++ b/script.js@@ -77,6 +77,7 @@ let eventSearchController = null;let eventFiltersController = null;let eventCrudController = null;let commandPaletteController = null;+let embedWidgetController = null;const notifiedOccurrences = new Map();const COMMAND_PALETTE_MAX_RESULTS = 18;const EVENT_SEARCH_MAX_RESULTS = 30;@@ -95,6 +96,7 @@ const TIMELINE_RECURRING_WINDOW_DAYS = 365;const TIMELINE_PADDING_DAYS = 14;let timelineZoomLevel = DEFAULT_TIMELINE_ZOOM_LEVEL;const APP_READY_ATTRIBUTE = "data-app-ready";+const APP_READY_FAILSAFE_MS = 9000;function setAppReady(isReady) {document.documentElement.setAttribute(APP_READY_ATTRIBUTE, isReady ? "1" : "0");@@ -2097,6 +2099,91 @@ function handleShareQr() {}}+function initEmbedWidgetController() {+ const modal = document.getElementById("embed-modal");+ if (!modal) return null;++ const openButtons = [+ document.getElementById("embed-widget"),+ document.getElementById("mobile-embed-widget"),+ document.getElementById("mobile-drawer-embed-widget"),+ ].filter(Boolean);+ const closeButton = document.getElementById("embed-close");+ const copyButton = document.getElementById("embed-copy");+ const widthInput = document.getElementById("embed-width");+ const heightInput = document.getElementById("embed-height");+ const codeArea = document.getElementById("embed-code");+ const backdrop = modal.querySelector(".modal-backdrop");++ const normalizeSize = (value, fallback) => {+ const cleaned = String(value || "").trim().replace(/[<>"']/g, "");+ if (!cleaned) return fallback;+ return cleaned.slice(0, 64);+ };++ const buildEmbedCode = () => {+ if (!codeArea) return;+ const width = normalizeSize(widthInput ? widthInput.value : "", "100%");+ const height = normalizeSize(heightInput ? heightInput.value : "", "600px");+ codeArea.value = `<iframe src="${window.location.href}" width="${width}" height="${height}" style="border:none;" loading="lazy" allowfullscreen></iframe>`;+ };++ const open = async (event) => {+ if (event) event.preventDefault();+ try {+ await persistStateToHash();+ } catch (error) {+ // If hash persistence fails, still allow embed code generation.+ }+ buildEmbedCode();+ modal.classList.remove(CSS_CLASSES.HIDDEN);+ };++ const close = () => {+ modal.classList.add(CSS_CLASSES.HIDDEN);+ };++ const isOpen = () => !modal.classList.contains(CSS_CLASSES.HIDDEN);++ const copyCode = async () => {+ if (!codeArea || !copyButton) return;+ buildEmbedCode();+ const content = codeArea.value;++ if (navigator.clipboard && navigator.clipboard.writeText) {+ try {+ await navigator.clipboard.writeText(content);+ } catch (error) {+ codeArea.focus();+ codeArea.select();+ fallbackCopyText(content);+ }+ } else {+ codeArea.focus();+ codeArea.select();+ fallbackCopyText(content);+ }++ const originalLabel = copyButton.innerHTML;+ copyButton.innerHTML = "<i class=\"fa-solid fa-check\"></i> Copied";+ showToast("Embed code copied", "success");+ setTimeout(() => {+ copyButton.innerHTML = originalLabel;+ }, 1200);+ };++ openButtons.forEach((button) => {+ button.addEventListener("click", open);+ });+ if (closeButton) closeButton.addEventListener("click", close);+ if (backdrop) backdrop.addEventListener("click", close);+ if (copyButton) copyButton.addEventListener("click", copyCode);+ if (widthInput) widthInput.addEventListener("input", buildEmbedCode);+ if (heightInput) heightInput.addEventListener("input", buildEmbedCode);++ return { open, close, isOpen };+}+function handleFocusToggle() {if (!focusMode) return;if (focusMode.isActive()) {@@ -2194,6 +2281,12 @@ function handleGlobalKeydown(event) {return;}+ if (embedWidgetController && embedWidgetController.isOpen()) {+ event.preventDefault();+ embedWidgetController.close();+ return;+ }+if (isOpenModalElement(ui.eventModal)) {event.preventDefault();if (eventCrudController) {@@ -2450,6 +2543,9 @@ function initResponsiveFeatures() {}async function init() {+ const appReadyFailsafe = window.setTimeout(() => {+ setAppReady(true);+ }, APP_READY_FAILSAFE_MS);setAppReady(false);cacheElements(ui);responsiveFeaturesController = createResponsiveFeaturesController({@@ -2596,6 +2692,7 @@ async function init() {onCopyLink: handleCopyLink,showToast,});+ embedWidgetController = initEmbedWidgetController();focusMode = new FocusMode({getState: () => state,fallbackColors: DEFAULT_COLORS,@@ -2646,6 +2743,7 @@ async function init() {attemptUnlock();}+ window.clearTimeout(appReadyFailsafe);setAppReady(true);}diff --git a/styles.css b/styles.cssindex cdadd11..0139e6c 100644--- a/styles.css+++ b/styles.css@@ -62,6 +62,120 @@ body[data-theme="dark"] {--shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);}+/* Splash / Loading Screen */+#splash-loader {+ position: fixed;+ inset: 0;+ z-index: 99999;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ background: var(--bg);+ transition: opacity 0.5s ease, visibility 0.5s ease;+}++html[data-app-ready="1"] #splash-loader {+ opacity: 0;+ visibility: hidden;+ pointer-events: none;+}++#splash-loader .splash-logo {+ width: 72px;+ height: 72px;+ animation: splash-pulse 1.6s ease-in-out infinite;+}++#splash-loader .splash-title {+ margin-top: 16px;+ font-family: var(--font-display);+ font-size: 1.5rem;+ font-weight: 600;+ color: var(--text);+}++#splash-loader .splash-dots {+ margin-top: 24px;+ display: flex;+ gap: 6px;+}++#splash-loader .splash-dots span {+ width: 8px;+ height: 8px;+ border-radius: 50%;+ background: var(--accent);+ animation: splash-dot 1.4s ease-in-out infinite;+}++#splash-loader .splash-dots span:nth-child(2) {+ animation-delay: 0.2s;+}++#splash-loader .splash-dots span:nth-child(3) {+ animation-delay: 0.4s;+}++@keyframes splash-pulse {+ 0%,+ 100% {+ transform: scale(1);+ opacity: 1;+ }++ 50% {+ transform: scale(1.06);+ opacity: 0.85;+ }+}++@keyframes splash-dot {+ 0%,+ 80%,+ 100% {+ transform: scale(0.4);+ opacity: 0.3;+ }++ 40% {+ transform: scale(1);+ opacity: 1;+ }+}++.embed-modal-card {+ width: min(520px, 94vw);+}++.embed-helper {+ margin: 0;+ color: var(--muted);+ font-size: 0.86rem;+ line-height: 1.45;+}++.embed-code-textarea {+ width: 100%;+ min-height: 110px;+ resize: vertical;+ font-family: "SFMono-Regular", "Menlo", "Consolas", "Liberation Mono", monospace;+ font-size: 0.8rem;+ line-height: 1.35;+ white-space: pre;+}++@media (max-width: 480px) {+ #splash-loader .splash-logo {+ width: 56px;+ height: 56px;+ }++ #splash-loader .splash-title {+ font-size: 1.2rem;+ }+}+* {box-sizing: border-box;}