|
@@ -1,5 +1,16 @@
|
|
|
let lastPushId = "C"
|
|
let lastPushId = "C"
|
|
|
-const arduionoURL = "http://192.168.1.160"
|
|
|
|
|
|
|
+let arduionoURL
|
|
|
|
|
+let openSlide = "animationsContainer"
|
|
|
|
|
+let data
|
|
|
|
|
+
|
|
|
|
|
+let var_1 = 0
|
|
|
|
|
+let speed = 100
|
|
|
|
|
+
|
|
|
|
|
+readTextFile("./../res/settings.json", function(text){
|
|
|
|
|
+ data = JSON.parse(text);
|
|
|
|
|
+ arduionoURL = data.settings.ip
|
|
|
|
|
+ console.log(data)
|
|
|
|
|
+});
|
|
|
|
|
|
|
|
function buttonPushAnimation(id) {
|
|
function buttonPushAnimation(id) {
|
|
|
if (id !== lastPushId) {
|
|
if (id !== lastPushId) {
|
|
@@ -7,18 +18,79 @@ function buttonPushAnimation(id) {
|
|
|
document.getElementById(lastPushId).style.backgroundColor = "#252531"
|
|
document.getElementById(lastPushId).style.backgroundColor = "#252531"
|
|
|
lastPushId = id
|
|
lastPushId = id
|
|
|
|
|
|
|
|
|
|
+ speed = data.animations[id].speed
|
|
|
|
|
+ var_1 = data.animations[id].var_1
|
|
|
|
|
+ document.getElementById("speed").value = speed
|
|
|
|
|
+ document.getElementById("var_1").value = var_1
|
|
|
httpGetAsync(arduionoURL + "/" + id)
|
|
httpGetAsync(arduionoURL + "/" + id)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-function httpGetAsync(theUrl, callback)
|
|
|
|
|
-{
|
|
|
|
|
- var xmlHttp = new XMLHttpRequest();
|
|
|
|
|
- xmlHttp.onreadystatechange = function() {
|
|
|
|
|
- if (xmlHttp.readyState === 4 && xmlHttp.status === 200)
|
|
|
|
|
- callback(xmlHttp.responseText);
|
|
|
|
|
|
|
+function topBarClick(id) {
|
|
|
|
|
+ if (id !== openSlide) {
|
|
|
|
|
+ document.getElementById(id).classList.toggle("hide")
|
|
|
|
|
+ document.getElementById(openSlide).classList.toggle("hide")
|
|
|
|
|
+ openSlide = id
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+function setSpeed(value) {
|
|
|
|
|
+ if (value != speed) {
|
|
|
|
|
+ speed = value
|
|
|
|
|
+ document.getElementById("speed").value = value
|
|
|
|
|
+ try {
|
|
|
|
|
+ httpGetAsync(arduionoURL + "/y1:" + value + ":;")
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+function setVar_1(value) {
|
|
|
|
|
+ if (value != var_1) {
|
|
|
|
|
+ var_1 = value
|
|
|
|
|
+ document.getElementById("var_1").value = value
|
|
|
|
|
+ try {
|
|
|
|
|
+ httpGetAsync(arduionoURL + "/y2:" + value + ":;")
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+function setSettings() {
|
|
|
|
|
+ var nSpeed = document.getElementById("speed").value
|
|
|
|
|
+ var nVar_1 = document.getElementById("var_1").value
|
|
|
|
|
+ setSpeed(nSpeed)
|
|
|
|
|
+ setVar_1(nVar_1)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+function httpGetAsync(theUrl, callback) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ var xmlHttp = new XMLHttpRequest();
|
|
|
|
|
+
|
|
|
|
|
+ xmlHttp.onreadystatechange = function () {
|
|
|
|
|
+ if (xmlHttp.readyState === 4 && xmlHttp.status === 200)
|
|
|
|
|
+ callback(xmlHttp.responseText);
|
|
|
|
|
+ }
|
|
|
|
|
+ xmlHttp.open("GET", theUrl, true); // true for asynchronous
|
|
|
|
|
+ xmlHttp.send(null);
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ console.log(e)
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+function readTextFile(file, callback) {
|
|
|
|
|
+ var rawFile = new XMLHttpRequest();
|
|
|
|
|
+ rawFile.overrideMimeType("application/json");
|
|
|
|
|
+ rawFile.open("GET", file, true);
|
|
|
|
|
+ rawFile.onreadystatechange = function() {
|
|
|
|
|
+ if (rawFile.readyState === 4 && rawFile.status == "200") {
|
|
|
|
|
+ callback(rawFile.responseText);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- xmlHttp.open("GET", theUrl, true); // true for asynchronous
|
|
|
|
|
- xmlHttp.send(null);
|
|
|
|
|
|
|
+ rawFile.send(null);
|
|
|
}
|
|
}
|