Fix settings variable conflict and updated version

master
Zach Dixon 2022-05-09 22:30:20 -07:00
parent 5f147027aa
commit 7822c4489d
4 changed files with 14 additions and 13 deletions

View File

@ -2,4 +2,5 @@
0.02: Fix typo to Purple
0.03: Added dependancy on Pedometer Widget
0.04: Fixed icon and png to 48x48 pixels
0.05: added charging icon
0.05: added charging icon
0.06: Add 12h support and autocycle control

View File

@ -2,7 +2,7 @@
"id": "rebble",
"name": "Rebble Clock",
"shortName": "Rebble",
"version": "0.05",
"version": "0.06",
"description": "A Pebble style clock, with configurable background, three sidebars including steps, day, date, sunrise, sunset, long live the rebellion",
"readme": "README.md",
"icon": "rebble.png",

View File

@ -35,7 +35,7 @@ function loadLocation() {
}
function loadSettings() {
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green'};
settings = require("Storage").readJSON(SETTINGS_FILE,1)|| {'bg': '#0f0', 'color': 'Green', 'autoCycle': true};
is12Hour = (require("Storage").readJSON(GLOBAL_SETTINGS, 1) || {})["12hour"] || false;
}

View File

@ -2,19 +2,19 @@
const SETTINGS_FILE = "rebble.json";
// initialize with default settings...
let s = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true}
let localSettings = {'bg': '#0f0', 'color': 'Green', 'autoCycle': true}
// ...and overwrite them with any saved values
// This way saved values are preserved if a new version adds more settings
const storage = require('Storage')
let settings = storage.readJSON(SETTINGS_FILE, 1) || s;
let settings = storage.readJSON(SETTINGS_FILE, 1) || localSettings;
const saved = settings || {}
for (const key in saved) {
s[key] = saved[key]
localSettings[key] = saved[key]
}
function save() {
settings = s
settings = localSettings
storage.write(SETTINGS_FILE, settings)
}
@ -25,20 +25,20 @@
'': { 'title': 'Rebble Clock' },
'< Back': back,
'Colour': {
value: 0 | color_options.indexOf(s.color),
value: 0 | color_options.indexOf(localSettings.color),
min: 0, max: 5,
format: v => color_options[v],
onchange: v => {
s.color = color_options[v];
s.bg = bg_code[v];
localSettings.color = color_options[v];
localSettings.bg = bg_code[v];
save();
},
},
'Auto Cycle': {
value: "autoCycle" in s ? s.autoCycle : true,
format: () => (s.autoCycle ? 'Yes' : 'No'),
value: "autoCycle" in localSettings ? localSettings.autoCycle : true,
format: () => (localSettings.autoCycle ? 'Yes' : 'No'),
onchange: () => {
s.autoCycle = !s.autoCycle;
localSettings.autoCycle = !localSettings.autoCycle;
save();
}
}