« get me outta code hell

refactor FG -> Color - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
diff options
context:
space:
mode:
author(quasar) nebula <towerofnix@gmail.com>2021-02-02 17:10:13 -0400
committer(quasar) nebula <towerofnix@gmail.com>2021-02-02 17:10:13 -0400
commitde8b3e3343c8a27920f75af9faace3c830e1cacc (patch)
treec2548ec485fe7b39f44adaeb7e2b33103fd86263
parent32a6e8b5ddb79f4141c51530732e0923f21ac71a (diff)
refactor FG -> Color
-rwxr-xr-xupd8.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/upd8.js b/upd8.js
index 01a3cb2..8395859 100755
--- a/upd8.js
+++ b/upd8.js
@@ -686,7 +686,10 @@ async function processAlbumDataFile(file) {
         return {error: `The album "${album.name}" is missing the "Cover Art" field.`};
     }
 
-    album.color = getBasicField(albumSection, 'FG') || '#0088ff';
+    album.color = (
+        getBasicField(albumSection, 'Color') ||
+        getBasicField(albumSection, 'FG')
+    );
 
     if (!album.name) {
         return {error: 'Expected "Album" (name) field!'};
@@ -735,7 +738,11 @@ async function processAlbumDataFile(file) {
         const groupName = getBasicField(section, 'Group');
         if (groupName) {
             group = groupName;
-            groupColor = getBasicField(section, 'FG') || album.color;
+            groupColor = (
+                getBasicField(section, 'Color') ||
+                getBasicField(section, 'FG') ||
+                album.color
+            );
             album.usesGroups = true;
             continue;
         }
@@ -885,7 +892,10 @@ async function processFlashDataFile(file) {
     return sections.map(section => {
         if (getBasicField(section, 'ACT')) {
             act = getBasicField(section, 'ACT');
-            color = getBasicField(section, 'FG');
+            color = (
+                getBasicField(section, 'Color') ||
+                getBasicField(section, 'FG')
+            );
             const anchor = getBasicField(section, 'Anchor');
             const jump = getBasicField(section, 'Jump');
             const jumpColor = getBasicField(section, 'Jump Color') || color;
@@ -3361,6 +3371,10 @@ function rgb2hsl(r,g,b) {
 }
 
 function getColorVariables(color) {
+    if (!color) {
+        color = wikiInfo.color;
+    }
+
     const [ r, g, b ] = color.slice(1)
         .match(/[0-9a-fA-F]{2,2}/g)
         .slice(0, 3)