summaryrefslogtreecommitdiff
path: root/js/common.js
blob: 560f63dcb3c58f28f320db6d3c1012189861e727 (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
var data,
    ui_type;


/*
 * 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;
}

/*
 *
 *
 */
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(/^\s+|\s+$/g, '');
}

/*
 * cross-site request
 *
 */
function CreateCORSRequest(method, url)
{
  var xhr = new XMLHttpRequest();
  if ("withCredentials" in xhr) {
    xhr.open(method, url, true);
  } else {
    xhr = null;
  }

  return xhr;
}