LED.js 689 B

123456789101112131415161718192021222324
  1. let lastPushId = "C"
  2. const arduionoURL = "http://192.168.1.160"
  3. function buttonPushAnimation(id) {
  4. if (id !== lastPushId) {
  5. document.getElementById(id).style.backgroundColor = "#2c2c36"
  6. document.getElementById(lastPushId).style.backgroundColor = "#252531"
  7. lastPushId = id
  8. httpGetAsync(arduionoURL + "/" + id)
  9. }
  10. }
  11. function httpGetAsync(theUrl, callback)
  12. {
  13. var xmlHttp = new XMLHttpRequest();
  14. xmlHttp.onreadystatechange = function() {
  15. if (xmlHttp.readyState === 4 && xmlHttp.status === 200)
  16. callback(xmlHttp.responseText);
  17. }
  18. xmlHttp.open("GET", theUrl, true); // true for asynchronous
  19. xmlHttp.send(null);
  20. }