2022-03-05 10:46:56 +00:00
|
|
|
(function (back) {
|
|
|
|
var FILE = "clockcal.json";
|
2024-04-04 21:17:01 +00:00
|
|
|
const defaults={
|
2022-03-05 10:46:56 +00:00
|
|
|
CAL_ROWS: 4, //number of calendar rows.(weeks) Shouldn't exceed 5 when using widgets.
|
|
|
|
BUZZ_ON_BT: true, //2x slow buzz on disconnect, 2x fast buzz on connect. Will be extra widget eventually
|
|
|
|
MODE24: true, //24h mode vs 12h mode
|
|
|
|
FIRSTDAY: 6, //First day of the week: mo, tu, we, th, fr, sa, su
|
|
|
|
REDSUN: true, // Use red color for sunday?
|
|
|
|
REDSAT: true, // Use red color for saturday?
|
2022-03-23 13:38:42 +00:00
|
|
|
DRAGDOWN: "[AI:messg]",
|
|
|
|
DRAGRIGHT: "[AI:music]",
|
2024-03-23 05:02:30 +00:00
|
|
|
DRAGLEFT: "[AI:agenda]",
|
2022-03-23 13:38:42 +00:00
|
|
|
DRAGUP: "[calend.]"
|
|
|
|
};
|
2024-04-04 21:17:01 +00:00
|
|
|
let settings = Object.assign(defaults, require('Storage').readJSON(FILE, true) || {});
|
2022-03-05 08:26:40 +00:00
|
|
|
|
2024-04-04 21:17:01 +00:00
|
|
|
let actions = ["[ignore]","[calend.]","[AI:music]","[AI:messg]","[AI:agenda]"];
|
2022-03-23 13:38:42 +00:00
|
|
|
require("Storage").list(RegExp(".app.js")).forEach(element => actions.push(element.replace(".app.js","")));
|
2023-02-23 11:46:49 +00:00
|
|
|
|
2022-03-05 10:46:56 +00:00
|
|
|
function writeSettings() {
|
|
|
|
require('Storage').writeJSON(FILE, settings);
|
|
|
|
}
|
2022-03-05 08:26:40 +00:00
|
|
|
|
2024-04-04 21:17:01 +00:00
|
|
|
const menu = {
|
2022-03-05 10:46:56 +00:00
|
|
|
"": { "title": "Clock & Calendar" },
|
|
|
|
"< Back": () => back(),
|
|
|
|
'Buzz(dis)conn.?': {
|
|
|
|
value: settings.BUZZ_ON_BT,
|
|
|
|
onchange: v => {
|
|
|
|
settings.BUZZ_ON_BT = v;
|
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'#Calendar Rows': {
|
|
|
|
value: settings.CAL_ROWS,
|
|
|
|
min: 0, max: 6,
|
|
|
|
onchange: v => {
|
|
|
|
settings.CAL_ROWS = v;
|
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Clock mode': {
|
|
|
|
value: settings.MODE24,
|
|
|
|
format: v => v ? "24h" : "12h",
|
|
|
|
onchange: v => {
|
|
|
|
settings.MODE24 = v;
|
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'First Day': {
|
|
|
|
value: settings.FIRSTDAY,
|
|
|
|
min: 0, max: 6,
|
|
|
|
format: v => ["Sun", "Sat", "Fri", "Thu", "Wed", "Tue", "Mon"][v],
|
|
|
|
onchange: v => {
|
|
|
|
settings.FIRSTDAY = v;
|
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Red Saturday?': {
|
|
|
|
value: settings.REDSAT,
|
|
|
|
onchange: v => {
|
|
|
|
settings.REDSAT = v;
|
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Red Sunday?': {
|
|
|
|
value: settings.REDSUN,
|
|
|
|
onchange: v => {
|
|
|
|
settings.REDSUN = v;
|
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
2022-03-23 13:38:42 +00:00
|
|
|
'Drag Up ': {
|
|
|
|
min:0, max:actions.length-1,
|
|
|
|
value: actions.indexOf(settings.DRAGUP),
|
|
|
|
format: v => actions[v],
|
2022-03-14 08:03:37 +00:00
|
|
|
onchange: v => {
|
2022-03-23 13:38:42 +00:00
|
|
|
settings.DRAGUP = actions[v];
|
2022-03-14 08:03:37 +00:00
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
2022-03-23 13:38:42 +00:00
|
|
|
'Drag Right': {
|
|
|
|
min:0, max:actions.length-1,
|
|
|
|
value: actions.indexOf(settings.DRAGRIGHT),
|
|
|
|
format: v => actions[v],
|
2022-03-14 08:03:37 +00:00
|
|
|
onchange: v => {
|
2022-03-23 13:38:42 +00:00
|
|
|
settings.DRAGRIGHT = actions[v];
|
2022-03-14 08:03:37 +00:00
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
2022-03-23 13:38:42 +00:00
|
|
|
'Drag Down': {
|
|
|
|
min:0, max:actions.length-1,
|
|
|
|
value: actions.indexOf(settings.DRAGDOWN),
|
|
|
|
format: v => actions[v],
|
|
|
|
onchange: v => {
|
2023-03-06 14:40:11 +00:00
|
|
|
settings.DRAGDOWN = actions[v];
|
2022-03-23 13:38:42 +00:00
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
'Drag Left': {
|
|
|
|
min:0, max:actions.length-1,
|
|
|
|
value: actions.indexOf(settings.DRAGLEFT),
|
|
|
|
format: v => actions[v],
|
2022-03-14 08:03:37 +00:00
|
|
|
onchange: v => {
|
2022-03-23 13:38:42 +00:00
|
|
|
settings.DRAGLEFT = actions[v];
|
2022-03-14 08:03:37 +00:00
|
|
|
writeSettings();
|
|
|
|
}
|
|
|
|
},
|
2023-02-23 11:46:49 +00:00
|
|
|
'Load defaults': () => {
|
|
|
|
settings = defaults;
|
|
|
|
writeSettings();
|
|
|
|
load();
|
|
|
|
}
|
2022-03-14 08:03:37 +00:00
|
|
|
};
|
2022-03-05 10:46:56 +00:00
|
|
|
// Show the menu
|
|
|
|
E.showMenu(menu);
|
2022-03-14 08:03:37 +00:00
|
|
|
});
|