Update settings.js

Reverting back to 10905e98cc
master
stweedo 2023-05-07 21:14:18 -05:00 committed by GitHub
parent 2389371aa4
commit f8f5405795
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 10 deletions

View File

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