2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 06:39:11 +00:00

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
This commit is contained in:
rudolfkoenig 2021-06-03 09:52:42 +00:00
parent ea80818b7a
commit cfd19596dc
2 changed files with 26 additions and 3 deletions

View File

@ -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

View File

@ -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("<style id='f18_css'>"+fd_style+"</style>");
}
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; }
`;
}