X-Git-Url: https://scm.cri.ensmp.fr/git/Plinn.git/blobdiff_plain/3c4367d8e03450e9a73e61f4247145d2b6c86a33..959d888c17d1403d2eeecc19bc4b5e2c8d1debf6:/skins/ajax_scripts/plinn_script_loader.js diff --git a/skins/ajax_scripts/plinn_script_loader.js b/skins/ajax_scripts/plinn_script_loader.js deleted file mode 100644 index d78ff6c..0000000 --- a/skins/ajax_scripts/plinn_script_loader.js +++ /dev/null @@ -1,78 +0,0 @@ -// (c) Benoît PIN 2006-2007 -// http://plinn.org -// Licence GPL -// -// - - -function ScriptRegistry() { - this.loadedScripts = new Object(); - this.pendingScripts = new Array(); - this.HEAD = document.getElementsByTagName('head')[0]; - this.isLoading = false; -} - -ScriptRegistry.prototype.loadScript = function(scriptOb) { - var scriptUrl; - if (typeof(scriptOb) == 'string') - scriptUrl = scriptOb; - else - scriptUrl = scriptOb.getAttribute('src'); - - if (scriptUrl) { - if (!this.loadedScripts[scriptUrl]) - this.pendingScripts.push(['url', scriptUrl]); - } - else { - this.pendingScripts.push(['code', scriptOb]); - } - if(!this.isLoading && this.pendingScripts.length) - this._loadNextScript(); -} - -ScriptRegistry.prototype._loadNextScript = function() { - var firstScript = this.pendingScripts[0]; - - switch (firstScript[0]) { - case 'url': - var script = document.createElement( "script" ); - script.type = "text/javascript"; - script.src = firstScript[1]; - this.HEAD.appendChild(script); - this.loadedScripts[script.src] = true; - this.isLoading = true; - var thisRegistry = this; - if (browser.isIE) - script.onreadystatechange = function(){ - if (script.readyState == 'complete' || script.readyState == 'loaded') - thisRegistry._removeScriptAfterLoad(); - }; - else - script.onload = function(){ thisRegistry._removeScriptAfterLoad(); }; - break; - case 'code' : - try { - eval(firstScript[1].text); - } - catch(e) { - if (window.console) { - console.group('Embedded script error'); - console.error(e); - console.info(firstScript[1]); - console.groupEnd(); - } - } - this._removeScriptAfterLoad(); - break; - }; -} - -ScriptRegistry.prototype._removeScriptAfterLoad = function() { - this.pendingScripts.shift(); - if(this.pendingScripts.length) - this._loadNextScript() - else - this.isLoading = false; -} - -globalScriptRegistry = new ScriptRegistry(); \ No newline at end of file