ajout de fichiers manquants pour mon precedent commit
[auf_savoirs_en_partage_django.git] / auf_savoirs_en_partage / 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 if (index >= len){
7 onComplete();
8 return;
9 }
10
11 try {
12 testOk = js_files[index].test();
13 } catch (e) {
14 // with certain browsers like opera the above test can fail
15 // because of undefined variables...
16 testOk = true;
17 }
18
19 if (testOk) {
20 var s = document.createElement('script');
21 s.src = js_files[index].src;
22 s.type = 'text/javascript';
23 head.appendChild(s);
24
25 s.onload = function(){
26 loadScript(index+1);
27 }
28 } else {
29 loadScript(index+1);
30 }
31 }
32
33 loadScript(0);
34 }