From c39b2e4166fb334b4d40b44d317ca53776d27e91 Mon Sep 17 00:00:00 2001 From: deimios666 <deimios666@gmail.com> Date: Tue, 24 Jul 2018 11:30:47 -0700 Subject: [PATCH] Mirrored flip color theme into twine JS.txt --- devNotes/twine JS.txt | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/devNotes/twine JS.txt b/devNotes/twine JS.txt index e66f11d93b0..f8bdc1f30fc 100644 --- a/devNotes/twine JS.txt +++ b/devNotes/twine JS.txt @@ -11600,26 +11600,21 @@ window.HSM = function() { /*:: colorModeJS [script]*/ window.setColors = function(colorMap){ + let props = ["color","backgroundColor","backgroundImage"]; let styleSheetArray = Array.from(document.styleSheets); styleSheetArray.forEach( styleSheet => { let cssRules = Array.from(styleSheet.cssRules); cssRules.forEach( cssRule => { if ( cssRule.type === 1 ){ - let color = cssRule.style.color; - let bgcolor = cssRule.style.backgroundColor; - if ( - color != "" && - color != "inherit" ){ - cssRule.style.color = colorMap[color] || color; - console.log('color: ',color); - } - if ( - bgcolor != "" && - bgcolor != "inherit" && - bgcolor != "transparent" ){ - cssRule.style.backgroundColor = colorMap[bgcolor] || bgcolor; - console.log('color: ',color); - } + props.forEach( propName => { + let currentValue = cssRule.style[propName]; + if ( + currentValue != "" && + currentValue != "inherit" && + currentValue != "transparent"){ + cssRule.style[propName] = colorMap[currentValue] || currentValue; + } + }) } }); }); -- GitLab