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 URL hash state management with compression and encryption, add language persistence, and make the GitHub link clickable.
Supun Lakmal890fe5d9e5ef
diff --git a/index.html b/index.htmlindex da2e265..7e2ed92 100644--- a/index.html+++ b/index.html@@ -129,8 +129,9 @@<div class="action-divider desktop-only"></div>- <i class="fa-brands fa-github" aria-hidden="true"></i>- <span>GitHub</span>+ <a href="https://github.com/supunlakmal/hash-calendar" class="action-link" target="_blank" rel="noopener">+ <i class="fa-brands fa-github" aria-hidden="true"></i>+ <span>GitHub</span></a></div></div>diff --git a/modules/hashcalUrlManager.js b/modules/hashcalUrlManager.jsindex ae0787d..377d7f6 100644--- a/modules/hashcalUrlManager.js+++ b/modules/hashcalUrlManager.js@@ -45,7 +45,8 @@ function compactState(state) {if (state.s) {const hasView = typeof state.s.v === "string" && state.s.v !== DEFAULT_SETTINGS.v;- if (state.s.d !== DEFAULT_SETTINGS.d || state.s.m !== DEFAULT_SETTINGS.m || hasView) {+ const hasLang = typeof state.s.l === "string" && state.s.l !== "en";+ if (state.s.d !== DEFAULT_SETTINGS.d || state.s.m !== DEFAULT_SETTINGS.m || hasView || hasLang) {out.s = state.s;}}diff --git a/script.js b/script.jsindex ccfec0e..0a978a9 100644--- a/script.js+++ b/script.js@@ -37,6 +37,7 @@ const DEFAULT_STATE = {d: 0,m: 0,v: DEFAULT_VIEW,+ l: "en",},timezones: [],mp: { h: null, z: [], s: null, d: null },@@ -200,6 +201,9 @@ function normalizeState(raw) {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") {+ next.s.l = raw.s.l === "si" ? "si" : "en";+ }}if (Array.isArray(raw.timezones) || Array.isArray(raw.z) || Array.isArray(raw.tz)) {@@ -718,6 +722,8 @@ function initLanguageDropdown() {`;li.addEventListener("click", () => {setLanguage(lang.code);+ state.s.l = lang.code;+ scheduleSave();updateLanguageUI();closeLanguageDropdown();});@@ -1209,6 +1215,7 @@ async function attemptUnlock() {password = value;lockState = { encrypted: true, unlocked: true };state = normalizeState(loaded);+ if (state.s.l) setLanguage(state.s.l);applyStoredView();render();showToast(t("toast.calendarUnlocked"), "success");@@ -1222,6 +1229,8 @@ async function attemptUnlock() {async function loadStateFromHash() {if (!window.location.hash) {state = cloneState(DEFAULT_STATE);+ // Initialize language from local storage if no hash+ state.s.l = getCurrentLanguage();applyStoredView();return;}@@ -1236,6 +1245,7 @@ async function loadStateFromHash() {try {const loaded = await readStateFromHash();state = normalizeState(loaded);+ if (state.s.l) setLanguage(state.s.l);} catch (error) {state = cloneState(DEFAULT_STATE);}