From 37f393d8e4fcb6be9334d7ee9fea3d3539f88a99 Mon Sep 17 00:00:00 2001 From: Til Schmitter Date: Sat, 20 Jun 2026 20:29:01 +0200 Subject: [PATCH] fix tcolor link to accent color --- copyparty/web/browser.html | 1 - copyparty/web/browser.js | 23 ----------------------- copyparty/web/util.js | 29 +++++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/copyparty/web/browser.html b/copyparty/web/browser.html index 14792e08..9ce3aaeb 100644 --- a/copyparty/web/browser.html +++ b/copyparty/web/browser.html @@ -296,7 +296,6 @@ CGV = {{ cgv|tojson }}, TS = "{{ ts }}", dtheme = "{{ dtheme }}", - tcolor = "#{{ tcolor }}" lang = "{{ lang }}", dfavico = "{{ favico }}", have_tags_idx = {{ have_tags_idx }}, diff --git a/copyparty/web/browser.js b/copyparty/web/browser.js index 4a7e583b..c29aea67 100644 --- a/copyparty/web/browser.js +++ b/copyparty/web/browser.js @@ -1480,21 +1480,6 @@ if(sread('cfg_lgcy') == 'true') ebi('reloc_cfg').click(); // accent color -function parseColor (strColor) { - var s = new Option().style; - s.color = strColor; - return s.color !== '' ? s.color : ''; -} -function setColor (color) { - accent = color; - swrite('accent', accent); - var a = accent || ''; - console.log('accent color set to: ' + a); - document.documentElement.style.setProperty('--a', a); - pbar.drawbuf(); - pbar.drawpos(); - vbar.draw(); -} ebi('accent').oninput = ebi('accent_picker').oninput = function () { var validcolor = parseColor(this.value); console.log(this.value); @@ -1516,14 +1501,6 @@ ebi('accent').oninput = ebi('accent_picker').oninput = function () { setColor(validcolor); }, 100); } -var accent = sread('accent'); -if(!accent || accent.length <= 3) - accent = window.tcolor; -if(accent && accent.length > 3){ - console.log('read accent color from settings: ' + accent); - document.documentElement.style.setProperty('--a', parseColor(accent)); - ebi('accent').value = ebi('accent_picker').value = accent; -} // corner radius ebi('radius').oninput = function () { diff --git a/copyparty/web/util.js b/copyparty/web/util.js index 5a6c24be..ee6fa110 100644 --- a/copyparty/web/util.js +++ b/copyparty/web/util.js @@ -2346,6 +2346,35 @@ function cprop(name) { return getComputedStyle(document.documentElement).getPropertyValue(name); } +// read accent / theme color +function parseColor (strColor) { + var s = new Option().style; + s.color = strColor; + return s.color !== '' ? s.color : ''; +} +function setColor (color) { + accent = color; + swrite('accent', accent); + var a = accent || ''; + console.log('accent color set to: ' + a); + document.documentElement.style.setProperty('--a', a); + pbar.drawbuf(); + pbar.drawpos(); + vbar.draw(); +} +var accent = sread('accent'); +var tcolor = QS('meta[name=theme-color]'); +if(tcolor) + tcolor = tcolor.content; +if((!accent || accent.length <= 3) && tcolor != "#333333") + accent = tcolor; +var thing = QS('meta[name=theme-color]'); +if(accent && accent.length > 3){ + console.log('read accent color from settings: ' + accent); + document.documentElement.style.setProperty('--a', parseColor(accent)); + if(ebi('accent')) + ebi('accent').value = ebi('accent_picker').value = accent; +} function bchrome() { var v, o = QS('meta[name=theme-color]');