From 009d3f90b1881530bd28003abe83cfc3735882be Mon Sep 17 00:00:00 2001 From: Jieiku Date: Fri, 25 Aug 2023 01:44:50 -0700 Subject: Refactor Documentation, PWA Fix, image shortcodes fix, simplify js script loading --- static/js/abridge-nosearch.min.js | 1 - static/js/abridge_nosearch.min.js | 1 + static/js/sw_load.js | 6 +++--- static/js/sw_load.min.js | 2 +- static/js/theme_button.js | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) delete mode 100644 static/js/abridge-nosearch.min.js create mode 100644 static/js/abridge_nosearch.min.js (limited to 'static/js') diff --git a/static/js/abridge-nosearch.min.js b/static/js/abridge-nosearch.min.js deleted file mode 100644 index 7ae9810..0000000 --- a/static/js/abridge-nosearch.min.js +++ /dev/null @@ -1 +0,0 @@ -const items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),!function(){for(var e=document.getElementsByClassName("m-protected"),t=0;t{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{const t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}); \ No newline at end of file diff --git a/static/js/abridge_nosearch.min.js b/static/js/abridge_nosearch.min.js new file mode 100644 index 0000000..7ae9810 --- /dev/null +++ b/static/js/abridge_nosearch.min.js @@ -0,0 +1 @@ +const items=document.querySelectorAll(".preStyle"),changeIcon=(items.forEach(e=>{e.rel="stylesheet"}),document.getElementById("mode")&&document.getElementById("mode").addEventListener("click",()=>{document.documentElement.classList.toggle("switch"),localStorage.setItem("theme",document.documentElement.classList.contains("switch")?"switch":"default")}),!function(){for(var e=document.getElementsByClassName("m-protected"),t=0;t{e.classList.add(t),setTimeout(()=>e.classList.remove(t),2500)}),copyCodeAndChangeIcon=async(t,e)=>{e=(e.querySelector("table")?getTableCode:getNonTableCode)(e);try{await navigator.clipboard.writeText(e),changeIcon(t,"yes")}catch(e){changeIcon(t,"err")}},getNonTableCode=e=>[...e.querySelectorAll("code")].map(e=>e.textContent).join(""),getTableCode=e=>[...e.querySelectorAll("tr")].map(e=>e.querySelector("td:last-child")?.innerText??"").join("");document.querySelectorAll("pre").forEach(e=>{const t=document.createElement("div");t.className="cc svgs svgh copy",t.innerHTML=" ",e.prepend(t),t.addEventListener("click",()=>copyCodeAndChangeIcon(t,e))}); \ No newline at end of file diff --git a/static/js/sw_load.js b/static/js/sw_load.js index 9c10723..8c72944 100644 --- a/static/js/sw_load.js +++ b/static/js/sw_load.js @@ -1,13 +1,13 @@ if ("serviceWorker" in navigator) { navigator.serviceWorker - .register("/sw.min.js?v=3.7.8", { scope: "/" }) + .register("/sw.min.js?v=3.8.0", { scope: "/" }) .then(() => { - console.info("SW Loaded"); + //console.info("SW Loaded"); }, err => console.error("SW error: ", err)); navigator.serviceWorker .ready .then(() => { - console.info("SW Ready"); + //console.info("SW Ready"); }); } diff --git a/static/js/sw_load.min.js b/static/js/sw_load.min.js index 2bc0802..e991797 100644 --- a/static/js/sw_load.min.js +++ b/static/js/sw_load.min.js @@ -1 +1 @@ -"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.7.8",{scope:"/"}).then(()=>{console.info("SW Loaded")},e=>console.error("SW error: ",e)),navigator.serviceWorker.ready.then(()=>{console.info("SW Ready")})); \ No newline at end of file +"serviceWorker"in navigator&&(navigator.serviceWorker.register("/sw.min.js?v=3.8.0",{scope:"/"}).then(()=>{},r=>console.error("SW error: ",r)),navigator.serviceWorker.ready.then(()=>{})); \ No newline at end of file diff --git a/static/js/theme_button.js b/static/js/theme_button.js index b03f17f..b60f85e 100644 --- a/static/js/theme_button.js +++ b/static/js/theme_button.js @@ -1,6 +1,6 @@ -// Set lightmode +// switch theme mode if (document.getElementById('mode')) { - document.getElementById('mode').addEventListener('click', () => { + document.getElementById('mode').addEventListener('click', () => { document.documentElement.classList.toggle('switch'); localStorage.setItem('theme', document.documentElement.classList.contains('switch') ? 'switch' : 'default'); }); -- cgit v1.3.1