Introduce a Node build system for minified CSS/JS with content hashes, add PWA support, i18n helpers, accessibility improvements, and more translatable strings. Move theme configuration from bookmarks to localStorage, add Playwright tests, and set up CI workflows.
This commit is contained in:
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(){"use strict";const e="shaarit_themes_config";function t(){try{const t=localStorage.getItem(e);if(!t)return null;const n=JSON.parse(t);return n&&"object"==typeof n?n:null}catch(e){return null}}window.ShaaritThemeConfig={save:function(n){const o=t()||{},r=Object.assign({version:2,themes:[],default:"DEFAULT",mode:"dark"},o,n||{}),a=function(t){try{return localStorage.setItem(e,JSON.stringify(t)),!0}catch(e){return!1}}(r);return Promise.resolve({ok:a,config:r})},load:function(){return Promise.resolve(t())},findCandidates:function(){return Promise.resolve([])}}}(),document.addEventListener("DOMContentLoaded",()=>{"use strict";const e=document.getElementById("theme-toggle-checkbox"),t=document.getElementById("theme-icon-light"),n=document.querySelector(".theme-toggle-label span"),o=window.ShaarliProI18n||{t:function(e){return e}};function r(){const e=localStorage.getItem("shaarit_theme_id")||"DEFAULT";return-1!==["LINEAR","SPOTIFY","NOTION","DISCORD","DRACULA","ONE_DARK_PRO","TOKYO_NIGHT","NORD","NIGHT_OWL","ANTHRACITE","CYBERPUNK","NAVY_ELEGANCE","EARTHY"].indexOf(e)}function a(a){r()&&(a="dark"),document.documentElement.setAttribute("data-theme",a),localStorage.setItem("theme",a),e&&(e.checked="dark"===a,e.disabled=r(),e.closest(".theme-switch").style.opacity=e.disabled?"0.5":"1"),t&&(t.className="dark"===a?"mdi mdi-weather-night":"mdi mdi-weather-sunny"),n&&(n.textContent="dark"===a?o.t("Dark Mode"):o.t("Light Mode"))}window.addEventListener("themeChanged",()=>{a(localStorage.getItem("theme")||"dark")});a(localStorage.getItem("theme")||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")),e&&e.addEventListener("change",()=>{if(r())return;const t=e.checked?"dark":"light";a(t),async function(e){try{if(!window.ShaaritThemeConfig)return;await window.ShaaritThemeConfig.save({mode:e})}catch(e){console.error("[shaarit] Failed to sync mode to bookmark",e)}}(t)})});
|
||||
Reference in New Issue
Block a user