Révision 8585d3d5
Ajouté par Jérôme Schneider il y a plus de 9 ans
mandaye/static/js/toolbar.js | ||
---|---|---|
1 |
function mandaye_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 | 1 |
function mandaye_disassociate_logout(url, account, id) |
44 | 2 |
{ |
45 | 3 |
var r = confirm("Etes-vous sûr de vouloir désassocier le compte " + account + " ?"); |
... | ... | |
49 | 7 |
} |
50 | 8 |
} |
51 | 9 |
|
52 |
window.onload = function () { |
|
53 |
mandaye_load('/mandaye/toolbar', function(response) { |
|
54 |
var body = document.body || document.getElementsByTagName('body')[0]; |
|
55 |
var div = document.createElement('div'); |
|
56 |
div.innerHTML = response; |
|
57 |
body.insertBefore(div, body.childNodes[0]); |
|
58 |
}); |
|
59 |
} |
|
60 |
|
|
10 |
(function( $ ) { |
|
11 |
$(function() { |
|
12 |
$.get("/mandaye/toolbar", function(data) { |
|
13 |
$("body").prepend(data); |
|
14 |
}); |
|
15 |
}); |
|
16 |
})(mjQuery); |
Formats disponibles : Unified diff
toolbar: now using jquery to load the bar