Explorar o código

Add stardust and 0c support for inputs

Emil %!s(int64=3) %!d(string=hai) anos
pai
achega
bf3b4545b8
Modificáronse 3 ficheiros con 20 adicións e 2 borrados
  1. 12 2
      js/spotlight.js
  2. 7 0
      res/spotlights.json
  3. 1 0
      spotlights.html

+ 12 - 2
js/spotlight.js

@@ -86,13 +86,23 @@ function changeAnimation(animId) {
 function changeVar(value, setting) {
     let sendValue = 0
 
-    if (value.substring(0,3) === "0x") {
+    if (value.substring(0,2) === "0x") {
         sendValue = parseInt(value, 16);
+    } else if (value.substring(0,2) === "0c") {
+        const r = parseInt(value.substring(2, 5));
+        const g = parseInt(value.substring(5, 8));
+        const b = parseInt(value.substring(8, 11));
+        const w = parseInt(value.substring(11, 15));
+        //console.log(r, g, b, w)
+        sendValue = ((r << 24) + (g << 16) + (b << 8) + w) >>>0
+        //console.log(sendValue)
+        //console.log((sendValue >>> 0).toString(2))
     } else {
         sendValue = Number(value)
     }
 
-    if (!isNaN(sendValue)) {
+
+    if (!isNaN(sendValue) && sendValue >= 0) {
         const sendDict = {
             ["targetCluster"]: chosenCluster,
             ["newValue"]: sendValue,

+ 7 - 0
res/spotlights.json

@@ -14,6 +14,13 @@
       "var2name": "Färg max",
       "var3name": "Tick min",
       "var4name": "Tick max"
+    },
+    "3": {
+      "name": "Stardust",
+      "var1Name": "Cooldown min",
+      "var2name": "Cooldown max",
+      "var3name": "Fade down tid",
+      "var4name": "Fade up tid"
     }
   }
 }

+ 1 - 0
spotlights.html

@@ -54,6 +54,7 @@
                 <button id="a0" onclick="changeAnimation(0)">Off</button>
                 <button id="a1" onclick="changeAnimation(1)">Rainbow</button>
                 <button id="a2" onclick="changeAnimation(2)">Random Colors</button>
+                <button id="a3" onclick="changeAnimation(3)">Stardust</button>
             </div>
             <p class="var1Input">{var1Name}</p>
             <input class="var1Input" onblur="changeVar(this.value, 'animationSetting1')">