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/android-chrome-192x192.png | Bin 1609 -> 1592 bytes static/android-chrome-512x512.png | Bin 3937 -> 3885 bytes static/apple-touch-icon.png | Bin 1542 -> 1537 bytes static/banner.png | Bin 4582 -> 4536 bytes static/favicon-32x32.png | Bin 397 -> 395 bytes 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 ++-- static/maskable-x128.png | Bin 816 -> 811 bytes static/maskable-x192.png | Bin 1086 -> 1085 bytes static/maskable-x384.png | Bin 1765 -> 1752 bytes static/maskable-x48.png | Bin 397 -> 394 bytes static/maskable-x512.png | Bin 2618 -> 2564 bytes static/maskable-x72.png | Bin 566 -> 519 bytes static/maskable-x96.png | Bin 671 -> 615 bytes static/maskable_x1024.png | Bin 5454 -> 5144 bytes static/mstile-150x150.png | Bin 1202 -> 1200 bytes static/sw.js | 4 ++-- static/sw.min.js | 2 +- 21 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 static/js/abridge-nosearch.min.js create mode 100644 static/js/abridge_nosearch.min.js (limited to 'static') diff --git a/static/android-chrome-192x192.png b/static/android-chrome-192x192.png index 3a075c3..33bf405 100644 Binary files a/static/android-chrome-192x192.png and b/static/android-chrome-192x192.png differ diff --git a/static/android-chrome-512x512.png b/static/android-chrome-512x512.png index b671d86..665a714 100644 Binary files a/static/android-chrome-512x512.png and b/static/android-chrome-512x512.png differ diff --git a/static/apple-touch-icon.png b/static/apple-touch-icon.png index 2923e41..48a8788 100644 Binary files a/static/apple-touch-icon.png and b/static/apple-touch-icon.png differ diff --git a/static/banner.png b/static/banner.png index a4a46d5..b80b8e9 100644 Binary files a/static/banner.png and b/static/banner.png differ diff --git a/static/favicon-32x32.png b/static/favicon-32x32.png index df65fe1..5d795a8 100644 Binary files a/static/favicon-32x32.png and b/static/favicon-32x32.png differ 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'); }); diff --git a/static/maskable-x128.png b/static/maskable-x128.png index a9ea7b0..428f863 100644 Binary files a/static/maskable-x128.png and b/static/maskable-x128.png differ diff --git a/static/maskable-x192.png b/static/maskable-x192.png index 6b17a50..0983cd8 100644 Binary files a/static/maskable-x192.png and b/static/maskable-x192.png differ diff --git a/static/maskable-x384.png b/static/maskable-x384.png index d1fa562..5909ebb 100644 Binary files a/static/maskable-x384.png and b/static/maskable-x384.png differ diff --git a/static/maskable-x48.png b/static/maskable-x48.png index b29fc5d..e7136b4 100644 Binary files a/static/maskable-x48.png and b/static/maskable-x48.png differ diff --git a/static/maskable-x512.png b/static/maskable-x512.png index dbd35cf..21daff2 100644 Binary files a/static/maskable-x512.png and b/static/maskable-x512.png differ diff --git a/static/maskable-x72.png b/static/maskable-x72.png index 1a9c0ca..763db52 100644 Binary files a/static/maskable-x72.png and b/static/maskable-x72.png differ diff --git a/static/maskable-x96.png b/static/maskable-x96.png index 22edaa1..7089028 100644 Binary files a/static/maskable-x96.png and b/static/maskable-x96.png differ diff --git a/static/maskable_x1024.png b/static/maskable_x1024.png index 35aa01e..f733670 100644 Binary files a/static/maskable_x1024.png and b/static/maskable_x1024.png differ diff --git a/static/mstile-150x150.png b/static/mstile-150x150.png index 7a18d2b..8abea88 100644 Binary files a/static/mstile-150x150.png and b/static/mstile-150x150.png differ diff --git a/static/sw.js b/static/sw.js index 7d07a13..130188b 100644 --- a/static/sw.js +++ b/static/sw.js @@ -7,7 +7,7 @@ class Pwa { //this.BASE_CACHE_FILES=['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json']; this.BASE_CACHE_FILES = ['/js/theme.min.js','/js/theme_light.min.js','/abridge.css','/js/abridge.min.js','/','/404.html','/offline/','/manifest.json']; this.host = `${self.location.protocol}//${self.location.host}`; - console.info(`Host: ${this.host}`); + //console.info(`Host: ${this.host}`); this.OFFLINE_PAGE = '/offline/'; this.NOT_FOUND_PAGE = '/404.html'; this.CACHE_NAME = `content-v${this.CACHE_VERSION}`; @@ -116,7 +116,7 @@ class Pwa { this.installServiceWorker(), this.scope.skipWaiting(), ])); - console.info('SW Installed'); + //console.info('SW Installed'); }); this.scope.addEventListener('activate', event => { diff --git a/static/sw.min.js b/static/sw.min.js index f8700c9..89738c1 100644 --- a/static/sw.min.js +++ b/static/sw.min.js @@ -1 +1 @@ -class Pwa{constructor(t){this.scope=t;var e=new URL(location).searchParams.get("v");this.CACHE_VERSION=e,this.BASE_CACHE_FILES=["/js/theme.min.js","/js/theme_light.min.js","/abridge.css","/js/abridge.min.js","/","/404.html","/offline/","/manifest.json"],this.host=t.location.protocol+"//"+t.location.host,console.info("Host: "+this.host),this.OFFLINE_PAGE="/offline/",this.NOT_FOUND_PAGE="/404.html",this.CACHE_NAME="content-v"+this.CACHE_VERSION,this.NORM_TTL=86400,this.LONG_TTL=604800,this.TTL_NORM=["sw.min.js","sw_load.min.js"],this.TTL_LONG=["js","css"],this.TTL_EXEMPT=["jpg","jpeg","png","gif","webp","avif","ico","svg","otf","eot","ttf","woff","woff2","xml","xsl","txt","mp4","webm","mp3","ogg"]}canCache(t){return!t.startsWith("http://localhost")&&t.toString().startsWith(this.host)}getFileExtension(t){t=t.split(".").reverse()[0].split("?")[0];return t.endsWith("/")?"/":t}getFileName(t){t=t.substring(t.lastIndexOf("/")+1).split("?")[0];return t.endsWith("/")?"/":t}getTTL(t){var e;return"string"==typeof t?(e=this.getFileExtension(t),t=this.getFileName(t),-1t.addAll(this.BASE_CACHE_FILES),t=>console.error("Error with "+this.CACHE_NAME,t)),this.scope.skipWaiting()}catch(t){return console.error("Error with installation: ",t)}}cleanupLegacyCache(){const i=[this.CACHE_NAME];return new Promise((e,s)=>{caches.keys().then(t=>t.filter(t=>!~i.indexOf(t))).then(t=>{t.length?Promise.all(t.map(t=>caches.delete(t))).then(()=>e()).catch(t=>{console.error("Error in legacy cleanup: ",t),s(t)}):e()}).catch(t=>{console.error("Error in legacy cleanup: ",t),s(t)})})}async preCacheUrl(e){const s=await caches.open(this.CACHE_NAME);return await s.match(e)?null:fetch(e).then(t=>s.put(e,t.clone()))}register(){this.scope.addEventListener("install",t=>{t.waitUntil(Promise.all([this.installServiceWorker(),this.scope.skipWaiting()])),console.info("SW Installed")}),this.scope.addEventListener("activate",e=>{e.waitUntil(Promise.all([this.cleanupLegacyCache(),this.scope.clients.claim(),this.scope.skipWaiting()]).catch(t=>{console.error("Activation error: ",t),e.skipWaiting()}))}),this.scope.addEventListener("fetch",a=>{a.respondWith(caches.open(this.CACHE_NAME).then(async e=>{if(!this.canCache(a.request.url))return fetch(a.request);const s=await e.match(a.request);if(s){var i;let t=null;for(i of s.headers.entries())if("date"===i[0]){t=new Date(i[1]);break}if(!t)return s;var n=parseInt((((new Date).getTime()-t.getTime())/1e3).toString()),r=this.getTTL(a.request.url);if(null===r||r&&nt.status<400?(this.canCache(a.request.url)&&e.put(a.request,t.clone()),t):e.match(this.NOT_FOUND_PAGE)).catch(t=>s||(console.error(`Error fetching ${a.request.url} resulted in offline`,t),e.match(this.OFFLINE_PAGE)))}))})}}const pwa=new Pwa(self);pwa.register(); \ No newline at end of file +class Pwa{constructor(t){this.scope=t;var e=new URL(location).searchParams.get("v");this.CACHE_VERSION=e,this.BASE_CACHE_FILES=["/js/theme.min.js","/js/theme_light.min.js","/abridge.css","/js/abridge.min.js","/","/404.html","/offline/","/manifest.json"],this.host=t.location.protocol+"//"+t.location.host,this.OFFLINE_PAGE="/offline/",this.NOT_FOUND_PAGE="/404.html",this.CACHE_NAME="content-v"+this.CACHE_VERSION,this.NORM_TTL=86400,this.LONG_TTL=604800,this.TTL_NORM=["sw.min.js","sw_load.min.js"],this.TTL_LONG=["js","css"],this.TTL_EXEMPT=["jpg","jpeg","png","gif","webp","avif","ico","svg","otf","eot","ttf","woff","woff2","xml","xsl","txt","mp4","webm","mp3","ogg"]}canCache(t){return!t.startsWith("http://localhost")&&t.toString().startsWith(this.host)}getFileExtension(t){t=t.split(".").reverse()[0].split("?")[0];return t.endsWith("/")?"/":t}getFileName(t){t=t.substring(t.lastIndexOf("/")+1).split("?")[0];return t.endsWith("/")?"/":t}getTTL(t){var e;return"string"==typeof t?(e=this.getFileExtension(t),t=this.getFileName(t),-1t.addAll(this.BASE_CACHE_FILES),t=>console.error("Error with "+this.CACHE_NAME,t)),this.scope.skipWaiting()}catch(t){return console.error("Error with installation: ",t)}}cleanupLegacyCache(){const i=[this.CACHE_NAME];return new Promise((e,s)=>{caches.keys().then(t=>t.filter(t=>!~i.indexOf(t))).then(t=>{t.length?Promise.all(t.map(t=>caches.delete(t))).then(()=>e()).catch(t=>{console.error("Error in legacy cleanup: ",t),s(t)}):e()}).catch(t=>{console.error("Error in legacy cleanup: ",t),s(t)})})}async preCacheUrl(e){const s=await caches.open(this.CACHE_NAME);return await s.match(e)?null:fetch(e).then(t=>s.put(e,t.clone()))}register(){this.scope.addEventListener("install",t=>{t.waitUntil(Promise.all([this.installServiceWorker(),this.scope.skipWaiting()]))}),this.scope.addEventListener("activate",e=>{e.waitUntil(Promise.all([this.cleanupLegacyCache(),this.scope.clients.claim(),this.scope.skipWaiting()]).catch(t=>{console.error("Activation error: ",t),e.skipWaiting()}))}),this.scope.addEventListener("fetch",a=>{a.respondWith(caches.open(this.CACHE_NAME).then(async e=>{if(!this.canCache(a.request.url))return fetch(a.request);const s=await e.match(a.request);if(s){var i;let t=null;for(i of s.headers.entries())if("date"===i[0]){t=new Date(i[1]);break}if(!t)return s;var r=parseInt((((new Date).getTime()-t.getTime())/1e3).toString()),n=this.getTTL(a.request.url);if(null===n||n&&rt.status<400?(this.canCache(a.request.url)&&e.put(a.request,t.clone()),t):e.match(this.NOT_FOUND_PAGE)).catch(t=>s||(console.error(`Error fetching ${a.request.url} resulted in offline`,t),e.match(this.OFFLINE_PAGE)))}))})}}const pwa=new Pwa(self);pwa.register(); \ No newline at end of file -- cgit v1.3.1