From 9299d194986e4111b3b1f7e26caef7d208a31c3f Mon Sep 17 00:00:00 2001 From: Til Schmitter Date: Mon, 20 Apr 2026 21:49:05 +0200 Subject: [PATCH] accent color input parsing --- copyparty/web/browser.css | 3 +++ copyparty/web/browser.js | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/copyparty/web/browser.css b/copyparty/web/browser.css index 5026888a..76839833 100644 --- a/copyparty/web/browser.css +++ b/copyparty/web/browser.css @@ -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"] { diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 484977fc..6c3e5fed 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -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 = (