diff --git a/apps/chargeanim/settings.js b/apps/chargeanim/settings.js new file mode 100644 index 000000000..7380fc0c0 --- /dev/null +++ b/apps/chargeanim/settings.js @@ -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 + }, + + }); +})