blob: 4af7cd00b4a2631a878dc392037f63fb3a107f26 (
plain)
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
|
/*
* (common) global vars
*
*/
var data, // data (from JSON)
ui_type; // 't' (text) or 'g' (graphical)
/*
* hacky way to remove class from node
*
*/
function removeClass(node, className)
{
node.className =
node.className.replace(" "+className,'');
node.className =
node.className.replace(" "+className,''); // ???
return false;
}
/*
* toggle display of element (by id)
*
*/
function toggleDisplay(id)
{
node = $(id);
if (node.style.display=='none') {
node.fadeIn();
} else {
node.fadeOut();
}
return false;
}
/*
* trim string
*
*/
function trim(s)
{
return s.replace(/(\||\n|\t)/g, " ").replace(/^\s+|\s+$/g, '').replace(/\s+/g, " ");
}
/*
* cross-site request
*
*/
function CreateCORSRequest(method, url)
{
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
xhr.open(method, url, true);
xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded; charset=UTF-8');
} else {
xhr = null;
}
return xhr;
}
|