}
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','/').replace('%3A',':') +
+ encodeURIComponent(page.replace(/ /g,'_')).replace(/%2F/ig,'/').replace(/%3A/ig,':') +
'&action=raw&ctype=text/javascript';
return importScriptURI(uri);
}
// Uses DOM calls to avoid document.write + XHTML issues
var linkHolder = document.getElementById('toctitle');
- if (!linkHolder) {
+ var existingLink = document.getElementById('togglelink');
+ if (!linkHolder || existingLink) {
+ // Don't add the toggle link twice
return;
}