MediaWiki:Common.js
Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */ // Function to streamline element creation var $e = function (tag, text, classes, id) { var d = document.createElement(tag), cl = d.classList; if (classes !== undefined) { classes.forEach( function(c) { cl.add(c); }); } if(id) { d.id = id; } d.textContent = (text || ""); return d; }, // Function to streamline getElementById $i = function (id, top) { if(top === undefined) { top = document; } return top.getElementById(id); }; // Function to streamline querySelector var $q = function (query, top) { if(top === undefined) { top = document; } return top.querySelector(query); }; // Function to streamline querySelectorAll var $a = function (query, top) { if(top === undefined) { top = document; } return top.querySelectorAll(query); }; // Function to look up a CSS variable (not needed) /*var $v = function (variable) { return window.getComputedStyle(document.documentElement).getPropertyValue(variable).trim(); };*/ // Function to set CSS variables var $sv = function (variable, value) { document.documentElement.style.setProperty(variable, value); }; // Look for a Div that indicates we're a lexicon page var lexiconInfo = $i("lexiconInfo"); // Swappers have these two attributes. var swapperNexus = $a("input[data-swapper][data-swap-interval]"); // // TEXT SWAP-OUT ANIMATION // if(swapperNexus.length) { // Check each swapper separately. swapperNexus.forEach(function(nex) { // Define variables inside here to hold stuff for the setInterval loop. var overlord = $i("swap-override"); // A checkbox to pause ALL swapping on a page var inverter = $i("swap-inverter"); // A checkbox to invert ALL animations (check to animate) var ds = nex.dataset; var ident = ds.swapper; // Name var rep = parseInt(ds.swapInterval); // Duration (in milliseconds) setInterval(function(){ var x = nex.checked; if(!overlord.checked && (inverter.checked ? x : !x) ) { // Pause when checked $a("[data-swap-nexus=\"" + ident + "\"]").forEach(function(d) { // Rotate out the text! var swap = d.dataset.swap.split(" "); var newText = swap.shift(); swap.push(newText); d.textContent = newText; d.dataset.swap = swap.join(" "); }); } }, rep); }); }