-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathigor.js
71 lines (62 loc) · 1.94 KB
/
igor.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
70
71
var sayTimer;
var progressInterval;
function say(event){
s = document.getElementById("sentence")
if (event.innerHTML == "SPACE"){s.innerHTML = s.innerHTML + " ";}
else if(event.innerHTML == "BACKSPACE"){s.innerHTML = s.innerHTML.substring(0, s.innerHTML.length-1);}
else {s.innerHTML = s.innerHTML + event.innerHTML;}
clearTimeout(sayTimer);
clearInterval(progressInterval)
document.getElementById("timeleft").value = "100"; //Reset the countdown
progressInterval = setInterval(function(){
countdown = document.getElementById("timeleft");
if(countdown.value == 5){
countdown.value = 100;
}
else{
countdown.value = countdown.value - 5
}
}, 99);
sayTimer = setTimeout(function(){
clearInterval(progressInterval); //Remove the countdown interval
s = document.getElementById("sentence"); //Remove the said sentence
gobbelz(s.innerHTML)
s.innerHTML = ""
}, 2100);
}
function gobbelz(text){
var lightRequest = new XMLHttpRequest();
lightRequest.open("POST", "http://gobbelz.shack/say/", true);
lightRequest.setRequestHeader("Content-type","application/json");
lightRequest.send(JSON.stringify({"text": text}));
}
var psi = false;
function startPsi(value){
console.log(value)
if(value > 70 && psi==false){
psi = true;
console.log("Playing PSI sound")
new Audio('./psi_alarm.mp3').play(); //Play sound
}
}
var attila = false;
function startAttila(value){
console.log(value)
if(value > 70 && attila==false){
attila = true;
console.log("Playing Attila sound")
new Audio('./Attila.mp3').play(); //Play sound
}
}
function generateExcuse(){
var listRequest = new XMLHttpRequest();
listRequest.open("GET", "http://localhost:8080/excuse.lst", true);
listRequest.onreadystatechange=function(){
if(listRequest.readyState==4 && listRequest.status==200){
var excuses = listRequest.responseText.split("\n");
var excuse = excuses[Math.floor(Math.random()*excuses.length)];
gobbelz(excuse);
}
}
listRequest.send();
}