-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcore.js
55 lines (49 loc) · 923 Bytes
/
core.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
function Errors(a, b, c) {
alert("Cannot connect to server! It's probably closed :(");
}
//Fetch events
var FetchingEvents = false;
function GetEvents() {
if (FetchingEvents) {
return
}
FetchingEvents = true;
$.ajax({
url: "/events",
success: HandleEvents,
error: Errors,
dataType: "json",
type: "GET"
});
}
function HandleEvents(evtobjs) {
FetchingEvents = false
if (evtobjs.error != undefined) {
alert(k.error);
return
}
for (i=0; i<evtobjs.length;i++) {
handleEvent(evtobjs[i]);
}
}
function handleEvent(evt) {
eval(evt.Javascript);
if (evt.Reply) {
$.ajax({
url: "/reply",
error: Errors,
type: "GET",
data: {"Id":evt.Id, "Reply": String(reply)}
});
}
}
function callHandler(id) {
$.ajax({
url: "/handler?id="+id,
error: Errors,
});
}
window.setInterval("GetEvents()", 10)
window.onbeforeunload = function() {
return "Are you sure you want to quit?";
};