Weitere Optionen
Ghost (Diskussion | Beiträge) KKeine Bearbeitungszusammenfassung |
Ghost (Diskussion | Beiträge) KKeine Bearbeitungszusammenfassung |
||
| Zeile 606: | Zeile 606: | ||
} | } | ||
} | } | ||
} | |||
//Import-Skript zum Auslagern großer Scripte | |||
function importScript(page) { | |||
// TODO: might want to introduce a utility function to match wfUrlencode() in PHP | |||
var uri = wgScript + '?title=' + | |||
encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') + | |||
'&action=raw&ctype=text/javascript'; | |||
return importScriptURI(uri); | |||
} | |||
var loadedScripts = {}; // included-scripts tracker | |||
function importScriptURI(url) { | |||
if (loadedScripts[url]) { | |||
return null; | |||
} | |||
loadedScripts[url] = true; | |||
var s = document.createElement('script'); | |||
s.setAttribute('src',url); | |||
s.setAttribute('type','text/javascript'); | |||
document.getElementsByTagName('head')[0].appendChild(s); | |||
return s; | |||
} | } | ||