MediaWiki

Gadget-editButton.js

From Dogcraft Wiki

Revision as of 00:53, 6 September 2024 by Domino (talk | contribs)

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.
$( function () {
	var namespace = mw.config.get('wgNamespaceNumber');
	
	var wikiEdit = document.createElement("a");
	wikiEdit.setAttribute("id", "wikiEdit");
	wikiEdit.setAttribute("class", "button");
	
	if (namespace === 14 || namespace === 3004 || namespace == 2 || namespace == 0)
		wikiEdit.setAttribute("href", "/wiki/index.php?title=" + mw.config.get('wgPageName') + "&veaction=edit")
	else
		wikiEdit.setAttribute("href", "/wiki/index.php?title=" + mw.config.get('wgPageName') + "&action=edit")
		
	var wikiEditButton = document.createElement("button");
	wikiEdit.appendChild(wikiEditButton);
	
	var wikiEditButtonIcon = document.createElement("i");
	if (namespace === 14 || namespace === 3004 || namespace == 2 || namespace == 0)
		wikiEditButtonIcon.setAttribute("class", "fas fa-pencil");
	else 
		wikiEditButtonIcon.setAttribute("class", "fas fa-code");
	wikiEditButton.appendChild(wikiEditButtonIcon);
	
	var wikiEditButtonLabel = document.createElement("span");
	if (namespace === 14 || namespace === 3004 || namespace == 2 || namespace == 0)
		wikiEditButtonLabel.innerText = " Edit";
	else 
		wikiEditButtonLabel.innerText = " Edit source";
	wikiEditButton.appendChild(wikiEditButtonLabel);
	
	document.getElementById("wikiActions").before(wikiEdit);
})
This page was last modified on 6 September 2024, at 00:53. (2 months ago)
Background SRN Opening by Montenator