From cfd19596dcb5d3ec058b997d5dc90962cdf9d6d9 Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Thu, 3 Jun 2021 09:52:42 +0000 Subject: [PATCH] fhemdoc_modular.js: color the commandref from f18 style (Forum #121437) git-svn-id: https://svn.fhem.de/fhem/trunk@24575 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/www/pgm2/f18.js | 2 ++ fhem/www/pgm2/fhemdoc_modular.js | 27 ++++++++++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/fhem/www/pgm2/f18.js b/fhem/www/pgm2/f18.js index 564e8a060..100247810 100644 --- a/fhem/www/pgm2/f18.js +++ b/fhem/www/pgm2/f18.js @@ -704,6 +704,8 @@ f18_setAttr(name, value, dontSave) var wn = $("body").attr("data-webName"); FW_cmd(FW_root+"?cmd=attr "+wn+" styleData "+ encodeURIComponent(JSON.stringify(f18_sd, undefined, 1))+"&XHR=1"); + // for commandref background coloring + localStorage.setItem("styleData", JSON.stringify(f18_sd.f18)); } function diff --git a/fhem/www/pgm2/fhemdoc_modular.js b/fhem/www/pgm2/fhemdoc_modular.js index 5d209bb4a..f6f267bf7 100644 --- a/fhem/www/pgm2/fhemdoc_modular.js +++ b/fhem/www/pgm2/fhemdoc_modular.js @@ -3,7 +3,7 @@ var fd_loadedHash={}, fd_loadedList=[], fd_all={}, fd_allCnt, fd_progress=0, fd_lang, fd_offsets=[], fd_scrolled=0, fd_modLinks={}, csrfToken="X", - fd_modLangs={}, fd_mode = "FHEM"; + fd_modLangs={}, fd_mode = "FHEM", fd_style; var fd_otherSrc = { "usb":"autocreate", "createlog":"autocreate" }; @@ -218,13 +218,15 @@ fd_csrfRefresh(callback) $(document).ready(function(){ + if(fd_style) { + $("head style#f18_css").remove(); + $("head").append(""); + } var p = location.pathname.split(/[_.]/); fd_lang = (p[1] == "modular" ? p[2] : p[1]); if(fd_lang == "html") fd_lang = "EN"; - if(location.host == "fhem.de" || location.host == "commandref.fhem.de") - fd_mode = "static"; $("div#modLinks").each(function(){ @@ -295,3 +297,22 @@ $(document).ready(function(){ }); $(window).resize(calcOffsets); + +if(location.host == "fhem.de" || location.host == "commandref.fhem.de") + fd_mode = "static"; + +// Set f18 style from the localStorage +var sdAsString = localStorage.getItem("styleData"), sd = {}; +if(sdAsString) + try { sd = JSON.parse(sdAsString) } catch(e) { console.log(e) } +if(sd["cols.bg"]) { + fd_style = ` + body.commandref { + background-color: #${sd["cols.bg"]}; + color: #${sd["cols.fg"]}; + } + a,h2,h3,h4 { color:#${sd["cols.link"]}; } + tr.odd { background-color:#${sd["cols.oddrow"]}; } + table.block { border:0; } + `; +}