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.
/**
* For language wikis, use
* <code> mw.loader.load("https://picayunedreams.wiki.gg/load.php?lang=en&modules=site&only=scripts&skin=vector"); </code>
* as the content of common.js to import from this script.
*
*/
mw.loader.getScript( 'https://commons.wiki.gg/index.php?title=MediaWiki:Common-base.js&action=raw&ctype=text/javascript' ).then(function(){
////////////////////////////////////////////////////////////////////////////////
/**
* image size fix for <gallery>
*/
$(function(){
$(".mw-gallery-traditional .thumb").each(function(){
var $this = $(this);
/* $this.css('display', 'flex'); // do this in common.css: .mw-gallery-traditional .thumb{ display: flex; } */
$this.css('height', $this.height()+'px').find('>div').css('margin', 'auto');
var $img = $this.find('img').first();
if(!$img.length){
return;
}
var $width = $img.attr('width') - 0; //cast to number.
var $filewidth = $img.attr('data-file-width') - 0;
if($filewidth < $width){
var $fileheight = $img.attr('data-file-height');
if( $filewidth * 2 > $width){
$img.attr({'width': $filewidth, 'height': $fileheight});
}else{
$img.attr({'width': $filewidth*2, 'height': $fileheight*2});
}
}
});
});
////////////////////////////////////////////////////////////////////////////////
/*end of mw.loader.getScript().then callback*/ });
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//if this easter egg ends up breaking something and I have to take it out i'll be sad
var horrorMusic = new Audio('https://picayunedreams.wiki.gg/images/6/6c/Accretion.ogg');
var horrorState = false;
if(document.getElementById('horrorDiv')){
document.getElementById('horrorDiv').addEventListener('click', function horrorToggle() {
var bd = document.body;
bd.classList.toggle("horror-mode");
if(horrorState == false){
document.documentElement.style.setProperty('--theme-border-color', '#7f0505');
document.documentElement.style.setProperty('--theme-box-border-color', '#cd2f2f');
document.documentElement.style.setProperty('--theme-navbar-tab-border-color', '#771b1b');
document.documentElement.style.setProperty('--theme-navbar-tab-selected-border-color', '#7f0505');
document.documentElement.style.setProperty('--theme-heading-color', '#cd2f2f');
document.documentElement.style.setProperty('--theme-navbar-inner-shadow', 'linear-gradient(to top,#7f0505,#7f0505 1px,transparent 1px,transparent)');
horrorMusic.play();
horrorState = true;
} else {
document.documentElement.style.setProperty('--theme-border-color', '#057f10');
document.documentElement.style.setProperty('--theme-box-border-color', '#4bcd2f');
document.documentElement.style.setProperty('--theme-navbar-tab-border-color', '#2c771b');
document.documentElement.style.setProperty('--theme-navbar-tab-selected-border-color', '#057f10');
document.documentElement.style.setProperty('--theme-heading-color', '#4bcd2f');
document.documentElement.style.setProperty('--theme-navbar-inner-shadow', 'linear-gradient(to top,#057f10,#057f10 1px,transparent 1px,transparent)');
horrorMusic.pause();
horrorState = false;
}
});
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////