calendar: reload settings after change

master
Erik Andresen 2023-10-19 22:08:28 +02:00
parent 2dec53ae2f
commit 4fcd9dba40
1 changed files with 35 additions and 23 deletions

View File

@ -18,19 +18,18 @@ const red = "#d41706";
const blue = "#0000ff"; const blue = "#0000ff";
const yellow = "#ffff00"; const yellow = "#ffff00";
const cyan = "#00ffff"; const cyan = "#00ffff";
let bgColor = color4; let bgColor;
let bgColorMonth = color1; let bgColorMonth;
let bgColorDow = color2; let bgColorDow;
let bgColorWeekend = color3; let bgColorWeekend;
let fgOtherMonth = gray1; let fgOtherMonth;
let fgSameMonth = white; let fgSameMonth;
let bgEvent = blue; let bgEvent;
let bgOtherEvent = "#ff8800"; let bgOtherEvent;
const eventsPerDay=6; // how much different events per day we can display const eventsPerDay=6; // how much different events per day we can display
const date = new Date(); const date = new Date();
const timeutils = require("time_utils"); const timeutils = require("time_utils");
let settings = require('Storage').readJSON("calendar.json", true) || {};
let startOnSun = ((require("Storage").readJSON("setting.json", true) || {}).firstDayOfWeek || 0) === 0; let startOnSun = ((require("Storage").readJSON("setting.json", true) || {}).firstDayOfWeek || 0) === 0;
let events; let events;
const dowLbls = function() { const dowLbls = function() {
@ -64,10 +63,11 @@ const loadEvents = () => {
}); });
}; };
const loadSettings = () => {
let settings = require('Storage').readJSON("calendar.json", true) || {};
if (settings.ndColors === undefined) { if (settings.ndColors === undefined) {
settings.ndColors = !g.theme.dark; settings.ndColors = !g.theme.dark;
} }
if (settings.ndColors === true) { if (settings.ndColors === true) {
bgColor = white; bgColor = white;
bgColorMonth = blue; bgColorMonth = blue;
@ -77,7 +77,17 @@ if (settings.ndColors === true) {
fgSameMonth = black; fgSameMonth = black;
bgEvent = color2; bgEvent = color2;
bgOtherEvent = cyan; bgOtherEvent = cyan;
} else {
bgColor = color4;
bgColorMonth = color1;
bgColorDow = color2;
bgColorWeekend = color3;
fgOtherMonth = gray1;
fgSameMonth = white;
bgEvent = blue;
bgOtherEvent = "#ff8800";
} }
};
const sameDay = function(d1, d2) { const sameDay = function(d1, d2) {
"jit"; "jit";
@ -274,6 +284,7 @@ const showMenu = function() {
/*LANG*/"Settings": () => { /*LANG*/"Settings": () => {
const appSettings = eval(require('Storage').read('calendar.settings.js')); const appSettings = eval(require('Storage').read('calendar.settings.js'));
appSettings(() => { appSettings(() => {
loadSettings();
loadEvents(); loadEvents();
showMenu(); showMenu();
}); });
@ -345,6 +356,7 @@ const setUI = function() {
}); });
}; };
loadSettings();
loadEvents(); loadEvents();
Bangle.loadWidgets(); Bangle.loadWidgets();
require("Font8x12").add(Graphics); require("Font8x12").add(Graphics);