MediaWiki:Common.js

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Revision as of 03:30, 8 February 2023 by Vish (talk | contribs)
Jump to navigation Jump to search

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.
window.hotcat_use_category_links = false;

/**
 * @source https://www.mediawiki.org/wiki/Snippets/Open_specific_links_in_new_window
 * @version 2018-09-15
 */
$( function () {
	$( '#mw-content-text' ).on( 'click', '.newwin > a', function () {
		var otherWindow = window.open();
		otherWindow.opener = null;
		otherWindow.location = this;
		return false;
	} );
} );

/*
setTimeout(function(){0===document.documentElement.scrollTop&&0===document.body.scrollTop||function(){if(document.getElementById("div-gpt-ad-jjw-1").hasChildNodes() == false){var e=document.getElementById("sidepic");e.style.backgroundImage="url('https://static.jojowiki.com/customizations/SpeedwagonMsg.png')",e.style.backgroundRepeat="no-repeat",e.style.height="600px"}}()},4800);

setTimeout(function(){0===document.documentElement.scrollTop&&0===document.body.scrollTop||function(){if(document.getElementById("div-gpt-ad-jjw-3").hasChildNodes()  == false){var e=document.getElementById("bottomthree");e.style.backgroundImage="url('https://static.jojowiki.com/customizations/JotaroJosukeMsg.png')",e.style.backgroundRepeat="no-repeat",e.style.height="280px",e.style.backgroundPosition="center"}}()},12800);
*/

// Move language dropdown to the right if title is long
var heading = document.getElementById("firstHeading");
if (heading.textContent.length > 56 && heading.textContent.length < 61) {
	document.querySelector('.la-dropdown').style.right = "-25px";
}

// Highlighting for tabs on game pages
var selfLink = document.getElementsByClassName("mw-selflink");
if (selfLink.length > 2) {
	if (selfLink[1].firstChild.nodeName=='SPAN') {
		selfLink[1].firstChild.classList.add(selfLink[1].firstChild.classList[2].replace('2', ''));
		selfLink[1].firstChild.classList.remove(selfLink[1].firstChild.classList[2]);
	}
}

var gameTab = document.getElementsByClassName('mcbutton');
var headers = document.getElementsByClassName('mw-headline');

function compareText(item1, item2) {
	if (item1 == item2) {
		return true;
	}
}

function highlightTab(item) {
	item.classList.add(item.classList[2].replace('2', ''));
	item.classList.remove(item.classList[2]);
}


for (var i = 0; i < headers.length; i++) {
	if (typeof headers[i].firstChild.text !== 'undefined') {
	for (var j = 0; j < gameTab.length; j++) {
		if (compareText(headers[i].firstChild.text, gameTab[j].textContent)) {
			highlightTab(gameTab[j]);
		}
	}
	}
}

/* Icon Random Color When Hovering */
var iconHoverColors = ['45', '90', '120', '150', '170', '190', '240', '290', '320'];
var randomColor = iconHoverColors[Math.floor(Math.random() * iconHoverColors.length)];

$(".mw-indicator").hover(function(){
  $(this).css("filter", "hue-rotate(" + randomColor + "deg)");
}, function(){
  $(this).css("filter", "none");
});