-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js.cpp
64 lines (57 loc) · 1.45 KB
/
main.js.cpp
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
/*
* =====================================================================================
*
* Filename: main.js.cpp
*
* Description: kissblower - landing page javascript
*
* Version: 1.0
* Created: 22/12/2018 19:26:31
* Revision: none
* Compiler: gcc-avr
*
* Author: Sebastien Chassot (sinux), seba.ptl@sinux.net
* pliski, info@pli.ski
* Company: Post Tenebras Lab (Geneva's Hackerspace)
*
* =====================================================================================
*/
#include <pgmspace.h>
char main_js[] PROGMEM = R"=====(
window.addEventListener('load', setup);
var refreshId = window.setInterval(setup, 2000);
window.addEventListener
function stopInterval(){
window.clearInterval(refreshId);
}
function submitVal(name, val) {
var xhttp = new XMLHttpRequest();
xhttp.open('GET', 'set?' + name + '=' + val, true);
xhttp.send();
}
function getMousePos(can, evt) {
r = can.getBoundingClientRect();
return {
x: evt.clientX - r.left,
y: evt.clientY - r.top
};
}
function getTemperature(){
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("temperature").innerHTML = this.responseText;
}
};
xhttp.open('GET', 'temp', true);
xhttp.send();
}
function setup(){
try{
getTemperature();
}
catch(e) {
stopInterval();
}
}
)=====";