MediaWiki:Common.js

/* Any JavaScript here will be loaded for all users on every page load. */

/* MediaWiki:All.js */ mw.loader.load('//splatoonwiki.org/wiki/MediaWiki:All.js?action=raw&ctype=text/javascript');

// ================================================================================ // Pikan -- the analyzer on the edit page // ================================================================================ $.getScript('//www.pikminwiki.com/index.php?title=User:Espyo/pikan-core.js' + '&action=raw&ctype=text/javascript', function {  mw.loader.load('//splatoonwiki.org/w/index.php?title=User:Espyo/pikan-inkipedia.js' + '&action=raw&ctype=text/javascript'); });

// ================================================================================ // Injection into Upload Wizard for custom licensing and categories // ================================================================================ //https://commons.wikimedia.org/wiki/Commons:Upload_Wizard/Editing#License_options //https://www.mediawiki.org/wiki/Extension:UploadWizard/CustomWikiTextLicenseFeature

if ("UploadWizard" === mw.config.get('wgCanonicalSpecialPageName')) { mw.loader.using('ext.uploadWizard', function {    try {      var autoAdd = mw.config.get('UploadWizardConfig').autoAdd;      // Add a custom category to all my upload wizard uploads      // autoAdd.categories.push("Images");

// Add a custom license tag to all my files uploaded using the sorcerer autoAdd.wikitext += ""; } catch (ex) { mw.log("Injecting custom-category into UploadWizard failed.", ex); } }); }

/////////////////////////////////////////////////////////////////////////////// //                              Gobbler Class                               // ///////////////////////////////////////////////////////////////////////////////

// Folds all infoboxes into a single, tabbed element

// Object constructor var Gobbler = function {

// Check for a gobbler object in the document this.element = document.getElementById("gobbler"); if (!this.element) return;

// Gobble all of the infoboxes on the page var elements = document.getElementsByClassName("tagInfobox"); var tabs    = []; for (var x = 0; x < elements.length; x++) tabs.push(this.gobble(elements[x])); this.onTab(tabs[tabs.length - 1]);

// Add the infoboxes and tab buttons to the gobbler element var tabStrip = document.createElement("div"); tabStrip.style.textAlign = "left"; if (tabs.length > 1) this.element.appendChild(tabStrip); for (var x = 0; x < tabs.length; x++) { tabStrip.appendChild(tabs[x].button); this.element.appendChild(tabs[x].element); }

};

// Process an infobox Gobbler.prototype.gobble = function(element) {

// Retrieve the infobox's hidden tab button element var button = element.getElementsByClassName("tagTab")[0];

// Create a tab object using the contents of the element var tab = { button:       button, colorInactive: button.style.backgroundColor, colorActive:  button.style.outlineColor, element:      element, cssText:      element.style.cssText };

// Configure element properties var that = this; element.style.cssText = "width: 100%; height: 100%; display: none;"; button.style.display = "inline"; button.onmousedown   = function(e) { if (e.button == 0) that.onTab(tab); };   return tab; };

// Event handler for when a tab is selected/clicked Gobbler.prototype.onTab = function(tab) {

// Deselect the previous infobox if (this.current) { this.current.button.style.fontWeight     = "normal"; this.current.button.style.backgroundColor = this.current.colorInactive; this.current.element.style.display       = "none"; }

// Select the new infobox this.element.style.cssText      = tab.cssText; tab.button.style.fontWeight     = "bold"; tab.element.style.display       = "inline"; tab.button.style.backgroundColor = tab.colorActive; this.current                    = tab; };

window.addEventListener("load", function { new Gobbler; });

// ================================================================================ // Warning message in console to help prevent scams // ================================================================================ setTimeout(function {    console.log("%cHold up squiddo!", "color:rgb(170, 220, 0);font-family:Splatoon2, sans-serif;font-size:40px")   console.log("%cIf someone told you to paste something here, there is a 99% chance you're getting scammed!", "font-family:Splatoon2, sans-serif;font-size:15px")   console.log("%cPasting anything here could give scammers access to your account", "color:red;font-family:Splatoon2, sans-serif;font-size:15px")   console.log("%cUnless you know what you're doing, don't paste anything here!", "font-family:Splatoon2, sans-serif;font-size:25px") }, 1500)