Update widget.js

Load settings from file and obey 'hide' setting
pull/1029/head
Marco H 2021-12-08 10:23:48 +01:00 committed by GitHub
parent ccd1cd1f3c
commit 92d3164029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 1 deletions

View File

@ -26,10 +26,26 @@
dirty = false;
}
});
let settings;
function loadSettings() {
const d = require('Storage').readJSON('weather.json', 1) || {};
settings = d.settings || {};
}
function setting(key) {
if (!settings) { loadSettings(); }
const DEFAULTS = {
'expiry': 2*3600000,
'hide': false
};
return (key in settings) ? settings[key] : DEFAULTS[key];
}
WIDGETS["weather"] = {
area: "tl",
width: weather.get() ? 20 : 0,
width: weather.get() && !setting('hide') ? 20 : 0,
draw: function() {
const w = weather.get();
if (!w) return;