build
[semainetech_django.git] / project / media / admin_tools / js / utils.js
1 var loadScripts = function(js_files, onComplete){
2 var len = js_files.length;
3 var head = document.getElementsByTagName('head')[0];
4
5 function loadScript(index){
6 var testOk;
7
8 if (index >= len){
9 onComplete();
10 return;
11 }
12
13 try {
14 testOk = js_files[index].test();
15 } catch (e) {
16 // with certain browsers like opera the above test can fail
17 // because of undefined variables...
18 testOk = true;
19 }
20
21 if (testOk) {
22 var s = document.createElement('script');
23 s.src = js_files[index].src;
24 s.type = 'text/javascript';
25 head.appendChild(s);
26
27 s.onload = function(){
28 loadScript(index+1);
29 }
30 } else {
31 loadScript(index+1);
32 }
33 }
34
35 loadScript(0);
36 }