Creation.js – MediaWiki

From Bohemia Interactive Community
Categories:
(Created for conditional import by MediaWiki:Common.js)
 
m (Refresh preload button)
Line 6: Line 6:
(function() { // BEGIN WRAPPER
(function() { // BEGIN WRAPPER
   
   
/*****************************************************************************************
/*****************************************************************************************
* 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.
*  helpful during certain page creations.
* Maintainer: BIKI User:Fred Gandt
* Maintainer: Lou Montana from Fred Gandt
*/
*/
 
function offerCreationPreload(pl) {
function offerCreationPreload(type) {
var cb = document.getElementById("ca-edit"),
var createBar = document.getElementById("ca-edit"),
cbc = cb.getElementsByTagName("span")[0].cloneNode(true),
button = createBar.getElementsByTagName("span")[0].cloneNode(true),
cbca = cbc.getElementsByTagName("a")[0];
link = button.getElementsByTagName("a")[0];
cbca.removeAttribute("accesskey");
link.removeAttribute("accesskey");
cbca.setAttribute("title", "Preload a " + pl + " guide for this creation");
link.setAttribute("title", "Preload a " + type + " guide for this creation");
cbca.setAttribute("href", cbca.getAttribute("href") + "&preload=Template:" + pl + "/preload");
link.setAttribute("href", link.getAttribute("href") + "&preload=Template:" + type + "/preload");
cbca.innerHTML = "Preload (<i style='color:green'>experimental</i>)";
link.innerHTML = "Preload " + type + " template";
cb.appendChild(cbc);
createBar.appendChild(button);
}
if (mw.config.get("wgCanonicalNamespace") === "Template") {
offerCreationPreload("Template");
} else if (mw.config.get("wgCanonicalNamespace") === "") {
if (mw.config.get("wgTitle").indexOf("BIS fnc ") === 0) {
offerCreationPreload("Function");
} else {
offerCreationPreload("Command");
}
}
}
if (mw.config.get("wgCanonicalNamespace") === "Template") {
offerCreationPreload("Template");
/*****************************************************************************************/
} else if (mw.config.get("wgCanonicalNamespace") === "") {
if (mw.config.get("wgTitle").indexOf("BIS fnc ") === 0 ||
/*****************************************************************************************
mw.config.get("wgTitle").indexOf("BIN fnc ")) {
* Next ***
offerCreationPreload("Function");
*/
} else {
offerCreationPreload("Command");
// code code code
}
}
/*****************************************************************************************/
/*****************************************************************************************/
 
}()); // END WRAPPER
}()); // END WRAPPER

Revision as of 06:43, 26 December 2020

/*****************************************************************************************
 * 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:" + type + "/preload");
			link.innerHTML = "Preload " + type + " template";
			createBar.appendChild(button);
		}
		if (mw.config.get("wgCanonicalNamespace") === "Template") {
			offerCreationPreload("Template");
		} else if (mw.config.get("wgCanonicalNamespace") === "") {
			if (mw.config.get("wgTitle").indexOf("BIS fnc ") === 0 ||
				mw.config.get("wgTitle").indexOf("BIN fnc ")) {
				offerCreationPreload("Function");
			} else {
				offerCreationPreload("Command");
			}
		}
	/*****************************************************************************************/
	
	}()); // END WRAPPER