Procházet zdrojové kódy

Can choose shelves. TODO: Everything

Emil před 3 roky
rodič
revize
e6735eaf11
5 změnil soubory, kde provedl 95 přidání a 16 odebrání
  1. 4 0
      css/nav.css
  2. 24 3
      css/spotlight.css
  3. 53 0
      js/spotlight.js
  4. 0 0
      res/spotlights.json
  5. 14 13
      spotlights.html

+ 4 - 0
css/nav.css

@@ -79,4 +79,8 @@ body {
 
 .sideBar a:hover {
     background-color: #252531;
+}
+
+.hidden {
+    display: none !important;
 }

+ 24 - 3
css/spotlight.css

@@ -82,17 +82,38 @@
     border: none;
 }
 
-#spotlightContainer button {
+#makeCluster {
+    grid-row: 1/2;
+    grid-column: 3/4;
+    border: none;
+    padding: 10px;
+    height: min-content;
+    font-size: 1.5vw;
+    color: white;
+    background-color: #252531;
+    border-radius: 10px;
+}
+
+#makeCluster:hover {
+    background-color: #2f2f3d;
+}
+
+.shelfButton {
     background-color: #2c2c36;
+    font-size: 1.5vw;
+    color: white;
+    font-family: 'Raleway', sans-serif;
 }
 
-#spotlightContainer button:hover {
+.shelfButton:hover {
     background-color: #2f2f3d;
     border-radius: 10px;
 }
 
-#selected {
+.selected {
     background-color: #a8a9b4 !important;
+    margin: 5px;
+    border-radius: 10px;
 }
 
 

+ 53 - 0
js/spotlight.js

@@ -1 +1,54 @@
 const shelfGrid = document.getElementById("shelfButtonContainer")
+const makeClusterButton = document.getElementById("makeCluster")
+
+let clusters = Array()
+let chosenShelves = Array()
+
+function getEByID(id) {
+    return document.getElementById(id)
+}
+
+function shelfClick(id) {
+    const clickedShelf = getEByID("b" + id.toString())
+
+    if (!clusters.flat(1).includes(id)) { //If not id in clusters
+        if (chosenShelves.includes(id)) { //If id in chosenShelves
+            chosenShelves = chosenShelves.filter(e => {
+                return e !== id;
+            })
+            clickedShelf.classList.remove("selected")
+            clickedShelf.innerText = ""
+        } else { //Else (if id not in chosenShelves
+            chosenShelves.push(id)
+            clickedShelf.classList.add("selected")
+        }
+    }
+
+    chosenShelves.forEach((id, num) => {
+        getEByID("b" + id.toString()).innerText = (num + 1).toString()
+    })
+
+
+    if (chosenShelves.length > 0) {
+        makeClusterButton.classList.remove("hidden")
+    } else {
+        makeClusterButton.classList.add("hidden")
+    }
+}
+
+
+function unselectAll() {
+    chosenShelves.forEach(id => {
+        getEByID("b" + id.toString()).innerText = ""
+        getEByID("b" + id.toString()).classList.remove("selected")
+    })
+    chosenShelves = Array()
+    makeClusterButton.classList.add("hidden")
+}
+
+window.onkeydown = function(event) {
+    if (event.key === "Escape") {
+        unselectAll()
+    }
+}
+

+ 0 - 0
res/spotlights.json


+ 14 - 13
spotlights.html

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="se">
+<html lang="sv">
 <head>
     <meta charset="UTF-8">
     <title>RGB Hub</title>
@@ -32,16 +32,17 @@
     <div id="spotlightContainer">
         <h2>Spotlight</h2>
         <div id="shelfButtonContainer">
-            <button id="b0"></button>
-            <button id="b1"></button>
-            <button id="b2"></button>
-            <button id="b3"></button>
-            <button id="b4"></button>
-            <button id="b5"></button>
-            <button id="b6"></button>
-            <button id="b7"></button>
-            <button id="b8"></button>
-            <button id="b9"></button>
+            <button id="b0" class="shelfButton" onclick="shelfClick(0)"></button>
+            <button id="b1" class="shelfButton" onclick="shelfClick(1)"></button>
+            <button id="b2" class="shelfButton" onclick="shelfClick(2)"></button>
+            <button id="b3" class="shelfButton" onclick="shelfClick(3)"></button>
+            <button id="b4" class="shelfButton" onclick="shelfClick(4)"></button>
+            <button id="b5" class="shelfButton" onclick="shelfClick(5)"></button>
+            <button id="b6" class="shelfButton" onclick="shelfClick(6)"></button>
+            <button id="b7" class="shelfButton" onclick="shelfClick(7)"></button>
+            <button id="b8" class="shelfButton" onclick="shelfClick(8)"></button>
+            <button id="b9" class="shelfButton" onclick="shelfClick(9)"></button>
+            <button id="makeCluster" class="hidden">Skapa kluster</button>
         </div>
 
         <div id="spotlightSettingsContainer">
@@ -55,11 +56,11 @@
             <input type="number" class="var1Input">
             <p class="var2Input">{var2Name}</p>
             <input type="number" class="var2Input">
-            <p class="speedInput">Speed (MS)</p>
+            <p class="speedInput">Hastighet (MS)</p>
             <input type="number" class="speedInput">
             <button id="deleteCluster"><span class="material-symbols-outlined">delete</span></button>
             <div id="clusters">
-                <button>Sync</button>
+                <button>Synk</button>
             </div>
         </div>