| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- let lastPushId = ""
- 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) {
- if (id !== lastPushId) {
- document.getElementById(id).style.backgroundColor = "#2c2c36"
- if (lastPushId !== "") {
- document.getElementById(lastPushId).style.backgroundColor = "#252531"
- }
- 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)
- }
- }
- 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);
- }
- }
- rawFile.send(null);
- }
|