1
0
Fork 0
BangleApps/apps/suw/settings.js

44 lines
1.0 KiB
JavaScript
Raw Normal View History

2022-08-19 07:17:40 +00:00
(function(back) {
var FILE = "suw.json";
// Load settings
var settings = Object.assign({
nextTideHour: 0,
nextTideMin: 0,
nextTideType: "high",
2022-08-19 07:17:40 +00:00
}, require('Storage').readJSON(FILE, true) || {});
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
// Show the menu
E.showMenu({
"" : { "title" : "Seaside Watch" },
"< Back" : () => back(),
2022-08-19 16:48:05 +00:00
'Tide type': {
value: "high"|settings.nextTideType, // !! converts undefined to false
2022-08-19 07:17:40 +00:00
format: v => v?"high":"low ",
onchange: v => {
settings.nextTideType = v;
writeSettings();
}
},
2022-08-19 16:48:05 +00:00
'Hour': {
2022-08-19 07:17:40 +00:00
value: 0|settings.nextTideHour, // 0| converts undefined to 0
min: 0, max: 23,
onchange: v => {
settings.nextTideHour = v;
writeSettings();
2022-08-19 16:15:28 +00:00
}
2022-08-19 16:48:05 +00:00
},
'Minutes': {
2022-08-19 07:17:40 +00:00
value: 0|settings.nextTideMin, // 0| converts undefined to 0
min: 0, max: 59,
onchange: v => {
settings.nextTideMin = v;
writeSettings();
}
},
2022-08-19 16:15:28 +00:00
});
2022-08-19 10:26:25 +00:00
});