1. aria-current added in button

2. set(): fixed name -> theme in for(){}
This commit is contained in:
2026-06-20 11:38:25 +05:00
parent 33729bc897
commit c0ea3a1e23
2 changed files with 16 additions and 15 deletions
+14 -13
View File
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -15,7 +15,7 @@ class ThemeManager {
stid:'color-scheme', // Селектор CSS: `gpfx + stdid == 'flxd-tm-color-scheme'` stid:'color-scheme', // Селектор CSS: `gpfx + stdid == 'flxd-tm-color-scheme'`
svg:'<svg width="100%" height="100%" viewBox="0 0 135.46666 135.46667"version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><path id="path1" style="opacity:100%;fill:currentColor;fill-opacity:1;stroke:#171717;stroke-width:0" d="M 67.777258,12.777515 A 55,55 0 0 0 12.777515,67.777258 55,55 0 0 0 67.777258,122.77752 55,55 0 0 0 122.77752,67.777258 55,55 0 0 0 67.777258,12.777515 Z m -0.128157,4.95577 V 117.73338 A 50,50 0 0 1 17.733285,67.733333 50,50 0 0 1 67.649101,17.733285 Z"/></svg>', svg:'<svg width="100%" height="100%" viewBox="0 0 135.46666 135.46667"version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg"><path id="path1" style="opacity:100%;fill:currentColor;fill-opacity:1;stroke:#171717;stroke-width:0" d="M 67.777258,12.777515 A 55,55 0 0 0 12.777515,67.777258 55,55 0 0 0 67.777258,122.77752 55,55 0 0 0 122.77752,67.777258 55,55 0 0 0 67.777258,12.777515 Z m -0.128157,4.95577 V 117.73338 A 50,50 0 0 1 17.733285,67.733333 50,50 0 0 1 67.649101,17.733285 Z"/></svg>',
/* */ /* */
};static #cl=document.documentElement.classList;static #b=document.createElement('div');static #i=0;static #t=[];static toggle=()=>{this.#s((this.#i+1)%this.#t.length);};static{let m=this;let c=m.#c;c.gpfx+='-';c.stid=c.gpfx+c.stid;m.#b.id=c.btnid=c.gpfx+c.btnid;m.#b.tabIndex=m.#c.btnti;m.#b.setAttribute('aria-label', 'toggle color scheme');m.#b.addEventListener('click',m.toggle)};static #at=(n,i=null)=>{this.#t.push({n:n,i:i||this.#c.svg,s:`${this.stid}-${n}`});};static #s(i){if(i==this.#i)return;let m=this;if(i&&m.#i)m.#cl.replace(m.#t[m.#i].s,m.#t[i].s);else if(m.#i)m.#cl.remove(m.#t[m.#i].s);else m.#cl.add(m.#t[i].s);m.#sv(m.#i=i);m.#b.innerHTML=m.#t[i].i;};static #sv=(()=>{let m=this;let s=(i)=>{console.error(m.#c.gpfx+'#sv: Can`t save theme id, storages are unreachable.');};try{m.#i=parseInt(localStorage.getItem(m.#c.stid))||0;s=(i)=>{try{localStorage.setItem(m.#c.stid,i);}catch(e){console.error(e);}};}catch(e){console.error(m.#c.gpfx+'#sv-IIFE: localStorage is unreachable, trying cookie.');try{let c=document.cookie.match(`${m.#c.stid}\\s*=\\s*(\\d+)`);m.#i=c?parseInt(c[1])||0:0;s=(i)=>{try{document.cookie=`${m.#c.stid}=${i};max-age=${31536000};path=/`;}catch(e){console.error(e);}};}catch(e){console.error(m.#c.gpfx+`#s-IIFE: All storages are unreachable('localStorage' & 'document.cookie')`);}}return s;})();static{let m=this; };static #cl=document.documentElement.classList;static #b=document.createElement('div');static #i=0;static #t=[];static toggle=()=>{this.#s((this.#i+1)%this.#t.length);};static{let m=this;let c=m.#c;c.gpfx+='-';c.stid=c.gpfx+c.stid;m.#b.id=c.btnid=c.gpfx+c.btnid;m.#b.tabIndex=m.#c.btnti;m.#b.setAttribute('aria-label', 'toggle color scheme');m.#b.addEventListener('click',m.toggle)};static #at=(n,i=null)=>{this.#t.push({n:n,i:i||this.#c.svg,s:`${this.stid}-${n}`});};static #s(i){if(i==this.#i)return;let m=this;if(i&&m.#i)m.#cl.replace(m.#t[m.#i].s,m.#t[i].s);else if(m.#i)m.#cl.remove(m.#t[m.#i].s);else m.#cl.add(m.#t[i].s);m.#sv(m.#i=i);m.#b.innerHTML=m.#t[i].i;m.#b.setAttribute('aria-current',m.#t[i].n);};static #sv=(()=>{let m=this;let s=(i)=>{console.error(m.#c.gpfx+'#sv: Can`t save theme id, storages are unreachable.');};try{m.#i=parseInt(localStorage.getItem(m.#c.stid))||0;s=(i)=>{try{localStorage.setItem(m.#c.stid,i);}catch(e){console.error(e);}};}catch(e){console.error(m.#c.gpfx+'#sv-IIFE: localStorage is unreachable, trying cookie.');try{let c=document.cookie.match(`${m.#c.stid}\\s*=\\s*(\\d+)`);m.#i=c?parseInt(c[1])||0:0;s=(i)=>{try{document.cookie=`${m.#c.stid}=${i};max-age=${31536000};path=/`;}catch(e){console.error(e);}};}catch(e){console.error(m.#c.gpfx+`#s-IIFE: All storages are unreachable('localStorage' & 'document.cookie')`);}}return s;})();static{let m=this;
/** /**
* Add new theme * Add new theme
* @typedef {function} add * @typedef {function} add
@@ -30,5 +30,5 @@ class ThemeManager {
add('old-terminal','<svg width="100%" height="100%" version="1.1" viewBox="0 0 5.2917 5.2917" xmlns="http://www.w3.org/2000/svg"><g style="opacity:1.0;fill:currentColor;" transform="matrix(1.1692 0 0 1.1544 -.44779 -.40842)" stroke-width="0"><path d="m1.0459 1.1457c-0.277 0-0.50023 0.22323-0.50023 0.50023v1.9999c0 0.277 0.22323 0.50023 0.50023 0.50023h3.1998c0.277 0 0.50023-0.22323 0.50023-0.50023v-1.9999c0-0.277-0.22323-0.50023-0.50023-0.50023zm0 0.30024h3.1998c0.1108 0 0.19999 0.089188 0.19999 0.19999v1.9999c0 0.1108-0.089188 0.19999-0.19999 0.19999h-3.1998c-0.1108 0-0.19999-0.089188-0.19999-0.19999v-1.9999c0-0.1108 0.089188-0.19999 0.19999-0.19999z" opacity=".99169"/><rect x="1.0458" y="1.6458" width="3.2" height="2" rx=".17611" ry=".1752" opacity=".99169"/></g></svg>'); add('old-terminal','<svg width="100%" height="100%" version="1.1" viewBox="0 0 5.2917 5.2917" xmlns="http://www.w3.org/2000/svg"><g style="opacity:1.0;fill:currentColor;" transform="matrix(1.1692 0 0 1.1544 -.44779 -.40842)" stroke-width="0"><path d="m1.0459 1.1457c-0.277 0-0.50023 0.22323-0.50023 0.50023v1.9999c0 0.277 0.22323 0.50023 0.50023 0.50023h3.1998c0.277 0 0.50023-0.22323 0.50023-0.50023v-1.9999c0-0.277-0.22323-0.50023-0.50023-0.50023zm0 0.30024h3.1998c0.1108 0 0.19999 0.089188 0.19999 0.19999v1.9999c0 0.1108-0.089188 0.19999-0.19999 0.19999h-3.1998c-0.1108 0-0.19999-0.089188-0.19999-0.19999v-1.9999c0-0.1108 0.089188-0.19999 0.19999-0.19999z" opacity=".99169"/><rect x="1.0458" y="1.6458" width="3.2" height="2" rx=".17611" ry=".1752" opacity=".99169"/></g></svg>');
/* */ /* */
if(m.#i>=m.#t.length||m.#i<0){console.error(`${m.#c.gpfx}bottom-static: Invalid theme index loaded '${m.#i}'`);m.#i=0;}m.#s(m.#i); if(m.#i>=m.#t.length||m.#i<0){console.error(`${m.#c.gpfx}bottom-static: Invalid theme index loaded '${m.#i}'`);m.#i=0;}m.#s(m.#i);
};static set=(theme)=>{let i=-1;for(let j=0;j<this.#t.length;j++){if(this.#t[j].n===name){i=j;break;}}if(i==-1){throw new Error('Invalid color sсheme.');}this.#s(i);};static #_=()=>{window.removeEventListener('DOMContentLoaded',this.#_);document.body.appendChild(this.#b);};static{let m=this;m.#s(m.#i);if(!document.body)window.addEventListener('DOMContentLoaded',this.#_);} };static set=(name)=>{let i=-1;for(let j=0;j<this.#t.length;j++){if(this.#t[j].n===name){i=j;break;}}if(i==-1){throw new Error(`Invalid color sсheme.'${name}'`);}this.#s(i);};static #_=()=>{window.removeEventListener('DOMContentLoaded',this.#_);document.body.appendChild(this.#b);};static{let m=this;m.#s(m.#i);if(!document.body)window.addEventListener('DOMContentLoaded',this.#_);}
}; };