From 225af74c76f89efab7d16e249801c8e4a6190884 Mon Sep 17 00:00:00 2001 From: TJCgames Date: Sun, 10 Mar 2024 20:01:42 +0000 Subject: [PATCH] As it turns out, you don't need to have the `themes` array, you can get it from `Object.keys(colors)` --- js/utils/save.js | 2 +- js/utils/themes.js | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/js/utils/save.js b/js/utils/save.js index b362c3b..02756ec 100644 --- a/js/utils/save.js +++ b/js/utils/save.js @@ -222,7 +222,7 @@ function loadOptions() { options = Object.assign(getStartOptions(), JSON.parse(decodeURIComponent(escape(atob(get2))))); else options = getStartOptions() - if (themes.indexOf(options.theme) < 0) theme = "default" + if (Object.keys(colors).indexOf(options.theme) < 0) theme = "default" fixData(options, getStartOptions()) } diff --git a/js/utils/themes.js b/js/utils/themes.js index e8eda64..93aa4db 100644 --- a/js/utils/themes.js +++ b/js/utils/themes.js @@ -1,6 +1,4 @@ // ************ Themes ************ -var themes = ["default", "aqua", "verdant"] - var colors = { default: { 1: "#ffffff",//Branch color 1 @@ -47,13 +45,13 @@ function getThemeName() { } function switchTheme() { - let index = themes.indexOf(options.theme) - if (options.theme === null || index >= themes.length-1 || index < 0) { - options.theme = themes[0]; + let index = Object.keys(colors).indexOf(options.theme) + if (options.theme === null || index >= Object.keys(colors).length-1 || index < 0) { + options.theme = Object.keys(colors)[0]; } else { index ++; - options.theme = themes[index]; + options.theme = Object.keys(colors)[index]; } changeTheme(); resizeCanvas();