calendar: Load holidays before events
Previously events were loaded and as result painted first and a following draw on a holiday would overwrite the event indicatormaster
parent
932d2c0d9d
commit
8b7ee2390d
|
|
@ -17,3 +17,4 @@
|
||||||
0.15: Edit holidays on device in settings
|
0.15: Edit holidays on device in settings
|
||||||
0.16: Add menu to fast open settings to edit holidays
|
0.16: Add menu to fast open settings to edit holidays
|
||||||
Display Widgets in menus
|
Display Widgets in menus
|
||||||
|
0.17: Load holidays before events so the latter is not overpainted
|
||||||
|
|
|
||||||
|
|
@ -43,24 +43,24 @@ const dowLbls = function() {
|
||||||
}();
|
}();
|
||||||
|
|
||||||
const loadEvents = () => {
|
const loadEvents = () => {
|
||||||
|
// add holidays & other events
|
||||||
|
events = (require("Storage").readJSON("calendar.days.json",1) || []).map(d => {
|
||||||
|
const date = new Date(d.date);
|
||||||
|
const o = {date: date, msg: d.name, type: d.type};
|
||||||
|
if (d.repeat) {
|
||||||
|
o.repeat = d.repeat;
|
||||||
|
}
|
||||||
|
return o;
|
||||||
|
});
|
||||||
// all alarms that run on a specific date
|
// all alarms that run on a specific date
|
||||||
events = (require("Storage").readJSON("sched.json",1) || []).filter(a => a.on && a.date).map(a => {
|
events = events.concat((require("Storage").readJSON("sched.json",1) || []).filter(a => a.on && a.date).map(a => {
|
||||||
const date = new Date(a.date);
|
const date = new Date(a.date);
|
||||||
const time = timeutils.decodeTime(a.t);
|
const time = timeutils.decodeTime(a.t);
|
||||||
date.setHours(time.h);
|
date.setHours(time.h);
|
||||||
date.setMinutes(time.m);
|
date.setMinutes(time.m);
|
||||||
date.setSeconds(time.s);
|
date.setSeconds(time.s);
|
||||||
return {date: date, msg: a.msg, type: "e"};
|
return {date: date, msg: a.msg, type: "e"};
|
||||||
});
|
}));
|
||||||
// add holidays & other events
|
|
||||||
(require("Storage").readJSON("calendar.days.json",1) || []).forEach(d => {
|
|
||||||
const date = new Date(d.date);
|
|
||||||
const o = {date: date, msg: d.name, type: d.type};
|
|
||||||
if (d.repeat) {
|
|
||||||
o.repeat = d.repeat;
|
|
||||||
}
|
|
||||||
events.push(o);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadSettings = () => {
|
const loadSettings = () => {
|
||||||
|
|
@ -141,6 +141,7 @@ const calcDays = (month, monthMaxDayMap, dowNorm) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const drawCalendar = function(date) {
|
const drawCalendar = function(date) {
|
||||||
|
d1 = new Date();
|
||||||
g.setBgColor(bgColor);
|
g.setBgColor(bgColor);
|
||||||
g.clearRect(0, 0, maxX, maxY);
|
g.clearRect(0, 0, maxX, maxY);
|
||||||
g.setBgColor(bgColorMonth);
|
g.setBgColor(bgColorMonth);
|
||||||
|
|
@ -281,7 +282,11 @@ const showMenu = function() {
|
||||||
},
|
},
|
||||||
/*LANG*/"Exit": () => load(),
|
/*LANG*/"Exit": () => load(),
|
||||||
/*LANG*/"Settings": () => {
|
/*LANG*/"Settings": () => {
|
||||||
const appSettings = eval(require('Storage').read('calendar.settings.js'));
|
const appSettings = () => eval(require('Storage').read('calendar.settings.js'))(() => {
|
||||||
|
loadSettings();
|
||||||
|
loadEvents();
|
||||||
|
showMenu();
|
||||||
|
});
|
||||||
appSettings(() => {
|
appSettings(() => {
|
||||||
loadSettings();
|
loadSettings();
|
||||||
loadEvents();
|
loadEvents();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"id": "calendar",
|
"id": "calendar",
|
||||||
"name": "Calendar",
|
"name": "Calendar",
|
||||||
"version": "0.16",
|
"version": "0.17",
|
||||||
"description": "Monthly calendar, displays holidays uploaded from the web interface and scheduled events.",
|
"description": "Monthly calendar, displays holidays uploaded from the web interface and scheduled events.",
|
||||||
"icon": "calendar.png",
|
"icon": "calendar.png",
|
||||||
"screenshots": [{"url":"screenshot_calendar.png"}],
|
"screenshots": [{"url":"screenshot_calendar.png"}],
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue