MediaWiki:Common.js
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";
}
/* 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)];
$(document).ready(function(){
$(".mw-indicator").not("#mw-indicator-999-lang").hover(function(){
$(this).css("filter", "hue-rotate(" + randomColor + "deg)");
}, function(){
$(this).css("filter", "none");
})
});
/* Palette Hex Codes */
$(document).ready(function() {
$('.palette2').click(function() {
var color = $(this).data('color');
var tempInput = document.createElement("input");
tempInput.style = "position: absolute; left: -1000px; top: -1000px";
tempInput.value = color;
document.body.appendChild(tempInput);
tempInput.select();
document.execCommand("copy");
document.body.removeChild(tempInput);
// Remove any existing notifications
$('.color-notification').remove();
// Create notification
var notification = $('<div class="color-notification">Copied color code: ' + color + '</div>');
notification.css({
'position': 'absolute',
'background-color': 'var(--jjbe3)',
'color': 'white',
'padding': '10px',
'border-radius': '5px',
'z-index': '1000'
});
// Position notification near the clicked color box
var position = $(this).position();
position.top -= $(this).height();
notification.css(position);
$(this).parent().append(notification);
// Fade out and remove notification after 3 seconds
setTimeout(function() {
notification.fadeOut('slow', function() {
notification.remove();
});
}, 3000);
});
});
$(document).ready(function() {
// Get the anchor hash from the URL
var anchorHash = window.location.hash.substring(1);
// Find the matching collapsible element
var collapsibleElement = document.getElementById(anchorHash);
if (collapsibleElement) {
// Remove the "mw-collapsed" class
collapsibleElement.classList.remove("mw-collapsed");
// Change the class of the nested span to "mw-collapsible-toggle-expanded"
var nestedSpan = collapsibleElement.querySelector(".mw-collapsible-toggle");
if (nestedSpan) {
nestedSpan.classList.remove("mw-collapsible-toggle-collapsed");
nestedSpan.classList.add("mw-collapsible-toggle-expanded");
nestedSpan.querySelector("a.mw-collapsible-text").textContent = "Collapse";
nestedSpan.setAttribute("aria-expanded", "true");
}
// Display the collapsible content
var collapsibleContent = collapsibleElement.querySelector(".note-bottom");
if (collapsibleContent) {
collapsibleContent.style.display = "block";
}
}
});