forked from ethersex/ethersex
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscr.js
141 lines (125 loc) · 3.23 KB
/
scr.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
var isIE/*@cc_on = true@*/;
function $(id) {
if (document.getElementById)
return document.getElementById(id);
if (document.all)
return document.all[id];
if (document.layers)
return document.layers[id];
return null;
}
function _(id, value) {
var obj = $(id);
if (obj) obj.innerHTML = value;
}
function returnObjById(id) {
return $(id);
}
var AjaxQueue = new Array();
var AjaxQueueLock = new Object();
AjaxQueueLock.locked = false;
var ArrAjax = new Object();
ArrAjax.aufruf = function (address, handler, method, data) {
if (AjaxQueueLock.locked) {
// if (AjaxQueue.length > 20) return;
var request = new Object;
request.address = address;
request.handler = handler;
request.method = method;
request.data = data;
AjaxQueue.push(request);
return;
} else {
AjaxQueueLock.locked = true;
}
var xmlHttp = null;
if (!method)
method = "GET";
// Mozilla, Opera, Safari sowie Internet Explorer 7
if (typeof XMLHttpRequest != 'undefined')
xmlHttp = new XMLHttpRequest();
if (!xmlHttp) {
// Internet Explorer 6 und älter
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch(e) {
xmlHttp = null;
}
}
}
if (!xmlHttp) {
alert('No Ajax support possible');
throw Exception("No Ajax support");
return;
}
xmlHttp.open(method, address, true);
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
try {
if (handler)
handler(xmlHttp, data);
} catch(e) {}
if (AjaxQueue.length > 0) {
var next = AjaxQueue.shift();
AjaxQueueLock.locked = false;
ArrAjax.aufruf(next.address, next.handler, next.method, next.data);
} else {
AjaxQueueLock.locked = false;
}
}
}
xmlHttp.send(null);
return xmlHttp;
}
ArrAjax.ecmd = function (address, handler, method, data) {
return ArrAjax.aufruf('/ecmd?' + address, handler, method, data);
}
//logging
function log_get_lines() {
return $('logconsole').getElementsByTagName('div').length;
}
function log_clean(bottom) {
var loglines = 25;
if (log_get_lines() > loglines) {
var logconsole = $('logconsole');
var nodes = logconsole.getElementsByTagName('div');
while (nodes.length > loglines) {
logconsole.removeChild(nodes[(bottom) ? 0 : loglines]);
}
}
}
function logger(code, text, bottom) {
var logconsole = $('logconsole');
logconsole.style.visibility = "visible";
var jetzt = new Date();
var Std = jetzt.getHours();
var Min = jetzt.getMinutes();
var Stdtext = (Std < 10) ? "0" + Std : Std;
var Mintext = (Min < 10) ? "0" + Min : Min;
var text = Stdtext + ":" + Mintext + " " + text;
var neuText = document.createElement("div");
var attr = (isIE) ? "className" : "class";
if (code == '0') {
neuText.setAttribute(attr, "lognotice");
neuText.innerHTML = text;
} else if (code == 'notice') {
neuText.setAttribute(attr, "logerror");
neuText.innerHTML = text;
} else {
neuText.setAttribute(attr, "logerror");
neuText.innerHTML = 'Fehler: ' + text;
}
if (bottom)
logconsole.appendChild(neuText);
else
logconsole.insertBefore(neuText, logconsole.firstChild);
log_clean(bottom);
}
function ecmd_error(response) {
if (!response)
return true;
return (response.responseText.indexOf("parse error") != -1);
}