Creation.js – MediaWiki
Categories:
Lou Montana (talk | contribs) m (Remove from here) |
Lou Montana (talk | contribs) (Add Introduction Category preload) |
||
| Line 8: | Line 8: | ||
/***************************************************************************************** | /***************************************************************************************** | ||
* Function adding a UI feature that if used, preloads templates | * Function adding a UI feature that if used, preloads templates | ||
* | * helpful during certain page creations. | ||
* Maintainer: Lou Montana from Fred Gandt | * Maintainer: Lou Montana from Fred Gandt | ||
*/ | */ | ||
| Line 18: | Line 18: | ||
link.removeAttribute("accesskey"); | link.removeAttribute("accesskey"); | ||
link.setAttribute("title", "Preload a " + type + " guide for this creation"); | link.setAttribute("title", "Preload a " + type + " guide for this creation"); | ||
link.setAttribute("href", link.getAttribute("href") + "&preload=Template:" + type | link.setAttribute("href", link.getAttribute("href") + "&preload=Template:Preload/" + type); | ||
link.innerHTML = "Preload " + type + " template"; | link.innerHTML = "Preload " + type + " template"; | ||
createBar.appendChild(button); | createBar.appendChild(button); | ||
} | } | ||
switch (mw.config.get("wgCanonicalNamespace").toLower()) | |||
{ | |||
if (mw.config.get("wgTitle").indexOf("BIS fnc ") === 0 || | case "Template": | ||
offerCreationPreload("Template"); | |||
return; | |||
case "Category": | |||
if (mw.config.get("wgTitle").startsWith("Introduced with ")) { | |||
offerCreationPreload("IntroductionCategory"); | |||
} | |||
return; | |||
default: | |||
if (mw.config.get("wgTitle").indexOf("BIS fnc ") === 0 || | |||
mw.config.get("wgTitle").indexOf("BIN fnc ") === 0) { | |||
offerCreationPreload("Function"); | |||
} else { | |||
offerCreationPreload("Command"); | |||
} | |||
return; | |||
} | } | ||
Revision as of 04:37, 2 January 2021
/*****************************************************************************************
* 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 createBar = document.getElementById("ca-edit"),
button = createBar.getElementsByTagName("span")[0].cloneNode(true),
link = button.getElementsByTagName("a")[0];
link.removeAttribute("accesskey");
link.setAttribute("title", "Preload a " + type + " guide for this creation");
link.setAttribute("href", link.getAttribute("href") + "&preload=Template:Preload/" + type);
link.innerHTML = "Preload " + type + " template";
createBar.appendChild(button);
}
switch (mw.config.get("wgCanonicalNamespace").toLower())
{
case "Template":
offerCreationPreload("Template");
return;
case "Category":
if (mw.config.get("wgTitle").startsWith("Introduced with ")) {
offerCreationPreload("IntroductionCategory");
}
return;
default:
if (mw.config.get("wgTitle").indexOf("BIS fnc ") === 0 ||
mw.config.get("wgTitle").indexOf("BIN fnc ") === 0) {
offerCreationPreload("Function");
} else {
offerCreationPreload("Command");
}
return;
}
/*****************************************************************************************/
}()); // END WRAPPER