accent color input parsing

This commit is contained in:
Til Schmitter 2026-04-20 21:49:05 +02:00
parent ee7b700b61
commit 9299d19498
2 changed files with 17 additions and 5 deletions

View file

@ -2148,6 +2148,9 @@ html.y #tree.nowrap .ntree a+a:hover {
#rui td input[type="text"] {
width: 100%;
}
input[type="text"].invalid {
border-color: var(--err-b1);
}
#rui #rn_n_d,
#rui #rn_n_s,
#shui td.exs input[type="text"] {

View file

@ -1275,18 +1275,27 @@ ebi('op_cfg').innerHTML = (
})();
// accent color
function parseColor (strColor) {
const s = new Option().style;
s.color = strColor;
return s.color !== '' ? s.color : '';
}
ebi('accent').oninput = function () {
if(this.value == accent)
var validcolor = parseColor(this.value);
clmod(ebi('accent'), 'invalid', this.value.length != 0 && validcolor.length == 0);
if(validcolor == accent)
return;
accent = this.value;
accent = validcolor;
swrite('accent', accent);
var a = accent || '#fc0';
console.log('accent color set to: ' + a);
document.documentElement.style.setProperty('--a', a);
}
var accent = ebi('accent').value = sread('accent') || '';
if(accent)
document.documentElement.style.setProperty('--a', accent);
var accent = ebi('accent').value = sread('accent');
if(accent){
document.documentElement.style.setProperty('--a', parseColor(accent));
}
// navpane
ebi('tree').innerHTML = (