Update settings.js

master
stweedo 2023-05-07 21:28:56 -05:00 committed by GitHub
parent d6184765c1
commit bfeaa5219f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 9 deletions

View File

@ -1,18 +1,16 @@
(function (back) {
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"];
let teletextColors = ["#000", "#f00", "#0f0", "#ff0", "#00f", "#f0f", "#0ff", "#fff"];
let 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(LOC, true) || {});
}, require('Storage').readJSON(shadowclk.json, true) || {});
// Save settings to storage
function writeSettings() {
require('Storage').writeJSON(LOC, appSettings);
require('Storage').writeJSON(shadowclk.json, appSettings);
}
// Colors from 'Light BW' and 'Dark BW' themes
@ -28,9 +26,9 @@
// Switch theme and save to storage
function switchTheme(mode) {
if (mode === g.theme.dark) return;
let s = require("Storage").readJSON(SYS, 1) || {};
let s = require("Storage").readJSON(setting.json, 1) || {};
s.theme = createThemeColors(mode);
require("Storage").writeJSON(SYS, s);
require("Storage").writeJSON(setting.json, s);
updateTheme(mode);
}
@ -51,7 +49,7 @@
// Read the current system theme
function getCurrentTheme() {
let s = require("Storage").readJSON(SYS, 1) || {};
let s = require("Storage").readJSON(setting.json, 1) || {};
return s.theme.dark ? 'dark' : 'light';
}