calendar: drop settings.ndColors, fixes widgets
parent
404ceca0b2
commit
107468bcdc
|
|
@ -16,3 +16,5 @@
|
||||||
0.14: Add support for holidays
|
0.14: Add support for holidays
|
||||||
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
|
||||||
|
Drop "B2 Colors" setting, use theme dark indicator instead
|
||||||
|
Display Widgets in menus
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
# Calendar
|
# Calendar
|
||||||
|
|
||||||
Basic calendar
|
Monthly calendar, displays holidays uploaded from the web interface and scheduled events.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
|
@ -11,7 +11,3 @@ Basic calendar
|
||||||
- Touch to display events for current month
|
- Touch to display events for current month
|
||||||
- Press the button (button 3 on Bangle.js 1) to exit
|
- Press the button (button 3 on Bangle.js 1) to exit
|
||||||
- Holidays have same color as weekends and can be edited with the 'Download'-interface, e.g. by uploading an iCalendar file.
|
- Holidays have same color as weekends and can be edited with the 'Download'-interface, e.g. by uploading an iCalendar file.
|
||||||
|
|
||||||
## Settings
|
|
||||||
|
|
||||||
- B2 Colors: use non-dithering colors (default, recommended for Bangle 2) or the original color scheme.
|
|
||||||
|
|
|
||||||
|
|
@ -32,30 +32,30 @@ const date = new Date();
|
||||||
const timeutils = require("time_utils");
|
const timeutils = require("time_utils");
|
||||||
let settings = require('Storage').readJSON("calendar.json", true) || {};
|
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;
|
||||||
// all alarms that run on a specific date
|
let events;
|
||||||
const events = (require("Storage").readJSON("sched.json",1) || []).filter(a => a.on && a.date).map(a => {
|
|
||||||
const date = new Date(a.date);
|
|
||||||
const time = timeutils.decodeTime(a.t);
|
|
||||||
date.setHours(time.h);
|
|
||||||
date.setMinutes(time.m);
|
|
||||||
date.setSeconds(time.s);
|
|
||||||
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);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (settings.ndColors === undefined) {
|
const loadEvents = () => {
|
||||||
settings.ndColors = !g.theme.dark;
|
// all alarms that run on a specific date
|
||||||
}
|
events = (require("Storage").readJSON("sched.json",1) || []).filter(a => a.on && a.date).map(a => {
|
||||||
|
const date = new Date(a.date);
|
||||||
|
const time = timeutils.decodeTime(a.t);
|
||||||
|
date.setHours(time.h);
|
||||||
|
date.setMinutes(time.m);
|
||||||
|
date.setSeconds(time.s);
|
||||||
|
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);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (settings.ndColors === true) {
|
if (!g.theme.dark) {
|
||||||
bgColor = white;
|
bgColor = white;
|
||||||
bgColorMonth = blue;
|
bgColorMonth = blue;
|
||||||
bgColorDow = black;
|
bgColorDow = black;
|
||||||
|
|
@ -249,26 +249,30 @@ const showMenu = function() {
|
||||||
"< Back": () => {
|
"< Back": () => {
|
||||||
require("widget_utils").hide();
|
require("widget_utils").hide();
|
||||||
E.showMenu();
|
E.showMenu();
|
||||||
drawCalendar(date);
|
|
||||||
setUI();
|
setUI();
|
||||||
},
|
},
|
||||||
|
/*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'));
|
||||||
appSettings(showMenu);
|
appSettings(() => {
|
||||||
|
loadEvents();
|
||||||
|
showMenu();
|
||||||
|
});
|
||||||
},
|
},
|
||||||
/*LANG*/"Launch Alarms": () => {
|
|
||||||
load("alarm.app.js");
|
|
||||||
},
|
|
||||||
/*LANG*/"Exit": () => load(),
|
|
||||||
};
|
};
|
||||||
if (!require("Storage").read("alarm.app.js")) {
|
if (require("Storage").read("alarm.app.js")) {
|
||||||
delete menu[/*LANG*/"Launch Alarms"];
|
menu[/*LANG*/"Launch Alarms"] = () => {
|
||||||
|
load("alarm.app.js");
|
||||||
|
};
|
||||||
}
|
}
|
||||||
require("widget_utils").show();
|
require("widget_utils").show();
|
||||||
E.showMenu(menu);
|
E.showMenu(menu);
|
||||||
};
|
};
|
||||||
|
|
||||||
const setUI = function() {
|
const setUI = function() {
|
||||||
|
require("widget_utils").hide(); // No space for widgets!
|
||||||
|
drawCalendar(date);
|
||||||
|
|
||||||
Bangle.setUI({
|
Bangle.setUI({
|
||||||
mode : "custom",
|
mode : "custom",
|
||||||
swipe: (dirLR, dirUD) => {
|
swipe: (dirLR, dirUD) => {
|
||||||
|
|
@ -314,7 +318,6 @@ const setUI = function() {
|
||||||
menu["< Back"] = () => {
|
menu["< Back"] = () => {
|
||||||
require("widget_utils").hide();
|
require("widget_utils").hide();
|
||||||
E.showMenu();
|
E.showMenu();
|
||||||
drawCalendar(date);
|
|
||||||
setUI();
|
setUI();
|
||||||
};
|
};
|
||||||
require("widget_utils").show();
|
require("widget_utils").show();
|
||||||
|
|
@ -323,9 +326,8 @@ const setUI = function() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
require("Font8x12").add(Graphics);
|
loadEvents();
|
||||||
drawCalendar(date);
|
|
||||||
setUI();
|
|
||||||
Bangle.loadWidgets();
|
Bangle.loadWidgets();
|
||||||
require("widget_utils").hide(); // No space for widgets!
|
require("Font8x12").add(Graphics);
|
||||||
|
setUI();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
"id": "calendar",
|
"id": "calendar",
|
||||||
"name": "Calendar",
|
"name": "Calendar",
|
||||||
"version": "0.16",
|
"version": "0.16",
|
||||||
"description": "Simple calendar",
|
"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"}],
|
||||||
"tags": "calendar,tool",
|
"tags": "calendar,tool",
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
var FILE = "calendar.json";
|
var FILE = "calendar.json";
|
||||||
const HOLIDAY_FILE = "calendar.days.json";
|
const HOLIDAY_FILE = "calendar.days.json";
|
||||||
var settings = require('Storage').readJSON(FILE, true) || {};
|
var settings = require('Storage').readJSON(FILE, true) || {};
|
||||||
if (settings.ndColors === undefined)
|
|
||||||
if (process.env.HWVERSION == 2) {
|
|
||||||
settings.ndColors = true;
|
|
||||||
} else {
|
|
||||||
settings.ndColors = false;
|
|
||||||
}
|
|
||||||
const holidays = require("Storage").readJSON(HOLIDAY_FILE,1).sort((a,b) => new Date(a.date) - new Date(b.date)) || [];
|
const holidays = require("Storage").readJSON(HOLIDAY_FILE,1).sort((a,b) => new Date(a.date) - new Date(b.date)) || [];
|
||||||
|
|
||||||
function writeSettings() {
|
function writeSettings() {
|
||||||
|
|
@ -132,13 +126,6 @@
|
||||||
E.showMenu({
|
E.showMenu({
|
||||||
"": { "title": "Calendar" },
|
"": { "title": "Calendar" },
|
||||||
"< Back": () => back(),
|
"< Back": () => back(),
|
||||||
'B2 Colors': {
|
|
||||||
value: settings.ndColors,
|
|
||||||
onchange: v => {
|
|
||||||
settings.ndColors = v;
|
|
||||||
writeSettings();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/*LANG*/"Edit Holidays": () => editdates(),
|
/*LANG*/"Edit Holidays": () => editdates(),
|
||||||
/*LANG*/"Add Holiday": () => {
|
/*LANG*/"Add Holiday": () => {
|
||||||
holidays.push({
|
holidays.push({
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue