Creation.js – MediaWiki
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
/*****************************************************************************************
* JavaScript here will be loaded by MediaWiki:Common.js when "creation" is detected.
*
*****************************************************************************************/
(function() { // BEGIN WRAPPER
/*****************************************************************************************
* Function adding a UI feature that if used, preloads templates
* helpful during certain page creations.
* Maintainer: Lou Montana from Fred Gandt
*/
function offerCreationPreload(type) {
var existingButton = document.getElementById("ca-edit"),
newButton = existingButton.cloneNode(true),
link = newButton.getElementsByTagName("a")[0];
link.removeAttribute("accesskey");
link.setAttribute("title", "Use Template:Preload/" + type);
link.setAttribute("href", link.getAttribute("href") + "&preload=Template:Preload/" + type);
link.innerHTML = "Use a preload template";
existingButton.after(newButton);
}
var namespace = mw.config.get("wgCanonicalNamespace");
var pageTitle = mw.config.get("wgTitle");
switch (namespace)
{
case "":
if (pageTitle.indexOf("BIS fnc ") === 0 ||
pageTitle.indexOf("BIN fnc ") === 0) {
offerCreationPreload("Function");
} else {
offerCreationPreload("Command");
}
return;
case "Category":
if (pageTitle.indexOf("Introduced with ") === 0) {
offerCreationPreload("IntroductionCategory");
}
return;
case "Template":
offerCreationPreload("Template");
return;
case "User":
var index = pageTitle.indexOf("/Sandbox");
if (index > -1 && index === pageTitle.length - 8) {
offerCreationPreload("Sandbox");
return;
}
if (pageTitle.indexOf("/") === -1) {
offerCreationPreload("User");
return;
}
return;
default:
return;
}
/*****************************************************************************************/
}()); // END WRAPPER