MediaWiki:Common.js: Difference between revisions
From Tardis Wiki, the free Doctor Who reference
(Created page with '→Any JavaScript here will be loaded for all users on every page load.: importScriptPage('ShowHide/code.js', 'dev');') |
(adding some of the contents of starwars:MediaWiki:Common.js so as to facilitate new preload system.) |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ | ||
importScriptPage('ShowHide/code.js', 'dev'); | importScriptPage('ShowHide/code.js', 'dev'); | ||
/*This comes from [[starwars:User:Sikon/preload.js]] and implements the preloadable template system at bottom of input page*/ | |||
document.write('<script type="text/javascript" src="' | |||
+ '/index.php?title=MediaWiki:Functions.js&action=raw&ctype=text/javascript"></script>'); | |||
function fillPreloads() | |||
{ | |||
var div = document.getElementById("lf-preload"); | |||
if(div == null) | |||
return; | |||
div.style.display = 'block'; | |||
var span = document.getElementById('lf-preload-cbox'); | |||
var comboString = "<select id='stdPreloads' onchange='onPreloadChange()'>"; | |||
comboString += "</select>"; | |||
span.innerHTML = comboString; | |||
span = document.getElementById('lf-preload-pagename'); | |||
span.innerHTML = '<input type="text" class="textbox" />'; | |||
span = document.getElementById('lf-preload-button'); | |||
span.innerHTML = '<input type="button" class="button" value="Insert" onclick="doCustomPreload()" />'; | |||
requestComboFill('stdPreloads', "Template:Stdpreloads"); | |||
} | |||
function doCustomPreload() | |||
{ | |||
doPreload(document.getElementById('lf-preload-pagename').getElementsByTagName('input')[0].value); | |||
} | |||
function onPreloadChange() | |||
{ | |||
var combo = document.getElementById("stdPreloads"); | |||
var value = combo.options[combo.selectedIndex].value; | |||
if(value == "") | |||
return; | |||
value = "Template:" + value + "/preload"; | |||
value = value.replace(" ", "_"); | |||
doPreload(value); | |||
} | |||
addOnloadHook(fillPreloads); | |||
/* Preload system ends */ |
Revision as of 18:33, 6 February 2011
/* Any JavaScript here will be loaded for all users on every page load. */
importScriptPage('ShowHide/code.js', 'dev');
/*This comes from [[starwars:User:Sikon/preload.js]] and implements the preloadable template system at bottom of input page*/
document.write('<script type="text/javascript" src="'
+ '/index.php?title=MediaWiki:Functions.js&action=raw&ctype=text/javascript"></script>');
function fillPreloads()
{
var div = document.getElementById("lf-preload");
if(div == null)
return;
div.style.display = 'block';
var span = document.getElementById('lf-preload-cbox');
var comboString = "<select id='stdPreloads' onchange='onPreloadChange()'>";
comboString += "</select>";
span.innerHTML = comboString;
span = document.getElementById('lf-preload-pagename');
span.innerHTML = '<input type="text" class="textbox" />';
span = document.getElementById('lf-preload-button');
span.innerHTML = '<input type="button" class="button" value="Insert" onclick="doCustomPreload()" />';
requestComboFill('stdPreloads', "Template:Stdpreloads");
}
function doCustomPreload()
{
doPreload(document.getElementById('lf-preload-pagename').getElementsByTagName('input')[0].value);
}
function onPreloadChange()
{
var combo = document.getElementById("stdPreloads");
var value = combo.options[combo.selectedIndex].value;
if(value == "")
return;
value = "Template:" + value + "/preload";
value = value.replace(" ", "_");
doPreload(value);
}
addOnloadHook(fillPreloads);
/* Preload system ends */