Create settings.js

master
RKBoss6 2025-06-19 18:46:24 -04:00 committed by GitHub
parent 88877b3a10
commit 8459c3f7b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,53 @@
(function(back) {
var FILE = "chargeAnimSettings.json";
// Load settings
var settings = Object.assign({
// default values
showBatPercent: true,
showTime: true,
keepScreenOn:false,
}, require('Storage').readJSON(FILE, true) || {});
function writeSettings() {
require('Storage').writeJSON(FILE, settings);
}
// Show the menu
E.showMenu({
"" : { "title" : "Charge Animation" },
"< Back" : () => back(),
'Show Percent Charged': {
value: !!settings.showBatPercent, // !! converts undefined to false
onchange: v => {
settings.showBatPercent = 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
},
'Show Time': {
value: !!settings.showTime, // !! converts undefined to false
onchange: v => {
settings.showTime = 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
},
'Keep Backlight On': {
value: !!settings.keepScreenOn, // !! converts undefined to false
onchange: v => {
settings.keepScreenOn = 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
},
});
})