-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
69 lines (67 loc) · 2.3 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
const { to, set, from, fromTo } = gsap
const getVar = (key, elem = document.documentElement) => getComputedStyle(elem).getPropertyValue(key)
let toggled = false;
function button(color){
if (toggled) {
alert("test");
} else {
setColor(color);
}
}
async function setColor(color){
fetch("https://192.168.1.168:8882/color?color=" + color).then(function (response) {
return response.json();
}).then(function (data) {
document.body.style.backgroundColor = data[0];
});
}
document.querySelector('#btn7').onclick = function(){
if(toggled) {
document.getElementById("1").innerHTML = "Cyan";
document.getElementById("2").innerHTML = "Gelb";
document.getElementById("3").innerHTML = "Pink";
document.getElementById("4").innerHTML = "Rot";
document.getElementById("5").innerHTML = "Grün";
document.getElementById("6").innerHTML = "Blau";
document.getElementById("7").innerHTML = "Monopoly";
} else {
document.getElementById("1").innerHTML = "haha";
document.getElementById("2").innerHTML = "haha";
document.getElementById("3").innerHTML = "haha";
document.getElementById("4").innerHTML = "haha";
document.getElementById("5").innerHTML = "haha";
document.getElementById("6").innerHTML = "haha";
document.getElementById("7").innerHTML = "Colors";
}
toggled = !toggled;
}
let pressing1 = false;
let pressing2 = false;
document.addEventListener('keydown', function(event) {
if (event.key == "F1") {
pressing1 = true;
pressing2 = true;
fetch('https://192.168.1.168:8882/sdk?mode=up&amount=10&getColor=true').then(function (response) {
return response.json();
}).then(function (data) {
document.body.style.backgroundColor = data[0];
});
}
});
function updateBg(){
if(!pressing1 && !pressing2) {
fetch('https://192.168.1.168:8882/sdk?mode=getCurrentColor').then(function (response) {
return response.json();
}).then(function (data) {
document.body.style.backgroundColor = data[0];
})
}
}
setInterval(updateBg, 1000);
setInterval(function() {
if(pressing1) {
pressing1 = false;
} else if(pressing2) {
pressing2 = false;
}
}, 1000);