mirror of
https://github.com/KevinMidboe/fanController.git
synced 2025-10-29 17:40:22 +00:00
Moved style and js to seperate files.
This commit is contained in:
22
public/main.js
Normal file
22
public/main.js
Normal file
@@ -0,0 +1,22 @@
|
||||
function UserAction(state) {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("POST", state, false);
|
||||
xhttp.setRequestHeader("Content-type", "application/text");
|
||||
xhttp.send();
|
||||
console.log(xhttp.status)
|
||||
if (xhttp.status == "200" && xhttp.responseText != 'none') {
|
||||
var stateDisplay = document.getElementById('state');
|
||||
stateDisplay.innerText = xhttp.responseText.toUpperCase();
|
||||
}
|
||||
}
|
||||
|
||||
window.onload = function() {
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.open("GET", "state", false);
|
||||
xhttp.send();
|
||||
|
||||
if (xhttp.status == "200") {
|
||||
var stateDisplay = document.getElementById('state');
|
||||
stateDisplay.innerText = xhttp.responseText.toUpperCase();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user