|
@@ -1,4 +1,3 @@
|
|
|
-const shelfGrid = document.getElementById("shelfButtonContainer")
|
|
|
|
|
const makeClusterButton = document.getElementById("makeCluster")
|
|
const makeClusterButton = document.getElementById("makeCluster")
|
|
|
|
|
|
|
|
let clusters = Array()
|
|
let clusters = Array()
|
|
@@ -46,9 +45,38 @@ function unselectAll() {
|
|
|
makeClusterButton.classList.add("hidden")
|
|
makeClusterButton.classList.add("hidden")
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+function createCluster() {
|
|
|
|
|
+ const shelves = JSON.stringify(chosenShelves)
|
|
|
|
|
+ const numLights = chosenShelves.length
|
|
|
|
|
+ const sendDict = {["numLights"]: numLights,
|
|
|
|
|
+ ["lights"]: shelves}
|
|
|
|
|
+ console.log(JSON.stringify(sendDict))
|
|
|
|
|
+ sendWebRequest("http://192.168.1.170/api/create_cluster", JSON.stringify(sendDict), "POST")
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
window.onkeydown = function(event) {
|
|
window.onkeydown = function(event) {
|
|
|
if (event.key === "Escape") {
|
|
if (event.key === "Escape") {
|
|
|
unselectAll()
|
|
unselectAll()
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+function sendWebRequest(url, data, method) {
|
|
|
|
|
+ const Http = new XMLHttpRequest()
|
|
|
|
|
+ Http.open(method, url)
|
|
|
|
|
+ Http.setRequestHeader("data", data)
|
|
|
|
|
+ Http.send()
|
|
|
|
|
+
|
|
|
|
|
+ Http.onreadystatechange = (e) => {
|
|
|
|
|
+ console.log(Http.responseText)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function updateConfig() {
|
|
|
|
|
+ fetch("http://192.168.1.170/api/get_config")
|
|
|
|
|
+ .then(response => response.json())
|
|
|
|
|
+ .then(data => console.log(data))
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+updateConfig()
|