Create settings.js

master
RKBoss6 2025-07-24 15:36:48 -04:00 committed by GitHub
parent 9081a02c04
commit 746351da9a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
(function(back) {
var FILE = "smartbatt.settings.json";
// Load settings
var settings = Object.assign({
//Record Interval stored in ms
doLogging:false
}, require('Storage').readJSON(FILE, true) || {});
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
// Show the menu
E.showMenu({
"" : { "title" : "Smart Day Battery" },
"< Back" : () => back(),
'Clear Data': function () {
E.showPrompt("Are you sure you want to delete all learned data?", {title:"Confirm"})
.then(function(v) {
if (v) {
require("smartbatt").deleteData();
E.showMessage("Successfully cleared data!","Cleared");
} else {
eval(require("Storage").read("smartbatt.settings.js"))(()=>load());
}
});
},
'Log Battery': {
value: !!settings.doLogging, // !! converts undefined to false
onchange: v => {
settings.doLogging = v;
writeSettings();
}
// format: ... may be specified as a function which converts the value to a string
// if the value is a boolean, showMenu() will convert this automatically, which
// keeps settings menus consistent
},
});
})