diff --git a/apps/shadowclk/settings.js b/apps/shadowclk/settings.js index 63d730d6e..40a01713d 100644 --- a/apps/shadowclk/settings.js +++ b/apps/shadowclk/settings.js @@ -1,21 +1,21 @@ (function (back) { - - - let teletextColors = ["#000", "#f00", "#0f0", "#ff0", "#00f", "#f0f", "#0ff", "#fff"]; - let teletextColorNames = ["Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White"]; + const LOC = "shadowclk.json"; + const SYS = "setting.json"; + const teletextColors = ["#000", "#f00", "#0f0", "#ff0", "#00f", "#f0f", "#0ff", "#fff"]; + const teletextColorNames = ["Black", "Red", "Green", "Yellow", "Blue", "Magenta", "Cyan", "White"]; // Load and set default settings let appSettings = Object.assign({ color: teletextColors[6], theme: 'light', - }, require('Storage').readJSON(shadowclk.json, true) || {}); + }, require('Storage').readJSON(LOC, true) || {}); // Save settings to storage function writeSettings() { - require('Storage').writeJSON(shadowclk.json, appSettings); + require('Storage').writeJSON(LOC, appSettings); } - // Colors from 'Light BW' and 'Dark BW' themes + // Colors from 'Ligh BW' and 'Dark BW' themes function createThemeColors(mode) { const cl = x => g.setColor(x).getColor(); return mode ? { @@ -28,9 +28,9 @@ // Switch theme and save to storage function switchTheme(mode) { if (mode === g.theme.dark) return; - let s = require("Storage").readJSON(setting.json, 1) || {}; + let s = require("Storage").readJSON(SYS, 1) || {}; s.theme = createThemeColors(mode); - require("Storage").writeJSON(setting.json, s); + require("Storage").writeJSON(SYS, s); updateTheme(mode); } @@ -51,7 +51,7 @@ // Read the current system theme function getCurrentTheme() { - let s = require("Storage").readJSON(setting.json, 1) || {}; + let s = require("Storage").readJSON(SYS, 1) || {}; return s.theme.dark ? 'dark' : 'light'; }