multitimer: restore json & sw default
parent
145b983b23
commit
4a35b30bb0
|
|
@ -328,21 +328,22 @@ function editTimer(idx, a) {
|
||||||
setUI();
|
setUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
function readAndConvJson() {
|
function readJson() {
|
||||||
let json = require("Storage").readJSON("multitimer.json", true);
|
let json = require("Storage").readJSON("multitimer.json", true) || {};
|
||||||
|
|
||||||
if (Array.isArray(json)) {
|
if (Array.isArray(json)) {
|
||||||
// old format, convert
|
// old format, convert
|
||||||
json = { sw: json };
|
json = { sw: json };
|
||||||
require("Storage").writeJSON("multitimer.json", json);
|
require("Storage").writeJSON("multitimer.json", json);
|
||||||
}
|
}
|
||||||
|
if (!json.sw) json.sw = [];
|
||||||
|
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drawSw() {
|
function drawSw() {
|
||||||
layer = 1;
|
layer = 1;
|
||||||
const sw = readAndConvJson().sw;
|
const sw = readJson().sw;
|
||||||
|
|
||||||
function updateTimers(idx) {
|
function updateTimers(idx) {
|
||||||
if (!timerInt1[idx]) timerInt1[idx] = setTimeout(function() {
|
if (!timerInt1[idx]) timerInt1[idx] = setTimeout(function() {
|
||||||
|
|
@ -394,8 +395,7 @@ function drawSw() {
|
||||||
|
|
||||||
function swMenu(idx, a) {
|
function swMenu(idx, a) {
|
||||||
layer = -1;
|
layer = -1;
|
||||||
const json = require("Storage").readJSON("multitimer.json", true) || {};
|
const json = readJson();
|
||||||
json.sw = json.sw || [];
|
|
||||||
const sw = json.sw;
|
const sw = json.sw;
|
||||||
if (sw[idx]) a = sw[idx];
|
if (sw[idx]) a = sw[idx];
|
||||||
else {
|
else {
|
||||||
|
|
@ -721,7 +721,7 @@ function onDrag(e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (readAndConvJson().initialScreen) {
|
switch (readJson().initialScreen) {
|
||||||
case 1:
|
case 1:
|
||||||
drawSw();
|
drawSw();
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue