From 1513b34da06164f805b2f526fe4f8e8661b40cd5 Mon Sep 17 00:00:00 2001 From: "Jill \"oatmealine\" Monoids" Date: Tue, 19 Oct 2021 21:11:10 +0300 Subject: [PATCH] light theme support --- public/index.html | 228 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 176 insertions(+), 52 deletions(-) diff --git a/public/index.html b/public/index.html index 63f9bb0..3eb4454 100644 --- a/public/index.html +++ b/public/index.html @@ -34,6 +34,23 @@ function formatTime(s) { return Math.floor(s / 60).toString().padStart(2, '0') + ':' + (s % 60).toString().padStart(2, '0'); } + function setTheme(theme) { + Array.from(document.styleSheets).map(e => { + try { + return Array.from(e.cssRules) + } catch (e) { + return [] + } + }).flat().map(e => { + if (e.constructor != CSSMediaRule) return; + if (e.originalConditionText) e.conditionText = e.originalConditionText; + else e.originalConditionText = e.conditionText + if (theme == "system") return + let match = e.conditionText.match(/prefers-color-scheme:\s*(light|dark)/i) + if (!match) return; + e.conditionText = e.conditionText.replace(match[0], (match[1].toLowerCase() == theme ? 'min' : 'max') + '-width: 0') + }) + } const search = document.getElementById('album-search'); search.setAttribute('placeholder', placeholders[Math.floor(Math.random() * placeholders.length)]); @@ -87,9 +104,166 @@ };