/
main.js
79 lines (72 loc) · 1.95 KB
/
main.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
function getHTTPObject() {
var xmlhttp;
/*@cc_on
@if (@_jscript_version >= 5)
try {
xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
} catch (e) {
try {
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
} catch (E) {
xmlhttp = false;
}
}
@else
xmlhttp = false;
@end @*/
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
}
var http = getHTTPObject();
var httpMapGet = getHTTPObject();
var httpUsersGet = getHTTPObject();
var httpItemsGet = getHTTPObject();
var httpActions = getHTTPObject();
var httpActions2 = getHTTPObject();
var httpPlayerUpdate = getHTTPObject();
var httpCounter = 0;
function setStyle(element, text) {
if (window.ActiveXObject) {
element.style.setAttribute('cssText', text, 0);
} else {
element.setAttribute('style', text, 0);
}
}
function stripSpaces(text) {
var newText = text;
while (newText.indexOf(' ') == 0) {
newText = newText.substring(1);
}
while (newText.lastIndexOf(' ') == (newText.length - 1)) {
newText = newText.substring(0, newText.length - 1);
}
return newText;
}
function replaceAll(string, finder, replacer) {
var newstr = string;
while (newstr.indexOf(finder) != -1) {
newstr = newstr.replace(finder, replacer);
}
return newstr;
}
function getElementsByClass(searchClass, node, tag) {
var classElements = new Array();
if (node == null) node = document;
if (tag == null) tag = '*';
var els = node.getElementsByTagName(tag);
var elsLen = els.length;
var pattern = new RegExp("(^|\\s)" + searchClass + "(\\s|$)");
for (i = 0, j = 0; i < elsLen; i++) {
if (pattern.test(els[i].className)) {
classElements[j] = els[i];
j++;
}
}
return classElements;
}