MediaWiki:Common.js

From Mine Blocks Wiki
Revision as of 14:51, 27 December 2018 by Zanzlanz (talk | contribs) (Added rainbow color changer)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
If you find a typo, inconsistency, or error, please sign up and help out the wiki! We can't do it without your help! :D Thank you!

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. */

// Make the rainbow color change like it does in Mine Blocks
var rainbowDivs = document.getElementsByClassName("rainbow-color");
if(rainbowDivs.length > 0) {
	setInterval(function() {
		var dateTime = (((new Date()).getTime()/1000)%1000)*25;
		var rgb = Math.floor((Math.sin(dateTime/19)/2+.5)*255)*0x10000
				+ Math.floor((Math.sin(dateTime/25)/2+.5)*255)*0x100
				+ Math.floor((Math.sin(dateTime/16)/2+.5)*255)*0x1;
		rgb = rgb.toString(16);
		while(rgb.length < 6) rgb = "0" + rgb;
		rgb = "#"+rgb;
		
		for (var i = 0, max = rainbowDivs.length; i < max; i++) {
			rainbowDivs[i].style.backgroundColor = rgb;
		}
	}, 100);
}