Projet

Général

Profil

Télécharger (1,4 ko) Statistiques
| Branche: | Tag: | Révision:

root / mandaye / static / js / toolbar.js @ 1453fab5

1
function load(url, on_success_callback) {
2
  var httpReq;
3

    
4
  var versions = ["MSXML2.XmlHttp.5.0",
5
      "MSXML2.XmlHttp.4.0",
6
      "MSXML2.XmlHttp.3.0",
7
      "MSXML2.XmlHttp.2.0",
8
      "Microsoft.XmlHttp"];
9

    
10
  if (window.XMLHttpRequest) {
11
    //  For Mozilla, Safari (non IE browsers)
12
    httpReq = new XMLHttpRequest();
13
  } else if (window.ActiveXObject) {
14
    //  For IE browsers
15
    for (var i = 0, n=versions.length; i < n; i++) {
16
      try {
17
        httpReq = new ActiveXObject(versions[i]);
18
      } catch(e) {   }
19
    }
20
  }
21

    
22
  if (!httpReq) {
23
    console.log('Cannot create an XMLHTTP instance');
24
    return false;
25
  }
26

    
27
  httpReq.onreadystatechange = function() {
28
    if (httpReq.readyState === 4) {
29
      if (httpReq.status === 200) {
30
        on_success_callback(httpReq.responseText);
31
      }
32
      else {
33
        console.log('Request error');
34
        return false;
35
      }
36
    }
37
  };
38

    
39
  httpReq.open('GET', url);
40
  httpReq.send();
41
}
42

    
43
function disassociate_logout(account, id)
44
{
45
  var r = confirm("Etes-vous sûr de vouloir désassocier le compte " + account + " ?");
46
  if (r == true)
47
  {
48
    window.location = "${urls['disassociate_url']}?id=" + id + "&logout=1";
49
  }
50
}
51

    
52
res = load('/mandaye/toolbar', function(response) {
53
  var body = document.body || document.getElementsByTagName('body')[0];
54
  var div = document.createElement('div');
55
  div.innerHTML = response;
56
  body.insertBefore(div, body.childNodes[0]);
57
});
58

    
    (1-1/1)