MediaWiki:Common.js

From Brickipedia, the LEGO Wiki
Revision as of 11:02, 19 August 2017 by NovaHawk (talk | contribs)

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 / Edge: 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.
/* Make each box in a row on the main page the same height as others on the same row */
if ( $( '#Row1BoxLeft' ).height() > $( '#Row1BoxRight' ).height() ) {
	$( '#Row1BoxRight' ).css( {'height':( $( '#Row1BoxLeft' ).height() )+'px'} );
} else {
	$( '#Row1BoxLeft' ).css( {'height':( $( '#Row1BoxRight' ).height() )+'px'} );
}
 
if ( $( '#Row2BoxLeft' ).height() > $( '#Row2BoxMiddle' ).height() ) {
	if ( $( '#Row2BoxLeft' ).height() > $( '#Row2BoxRight' ).height() ) {
		$( '#Row2BoxRight' ).css( {'height':( $( '#Row2BoxLeft' ).height() )+'px'} );
		$( '#Row2BoxMiddle' ).css( {'height':( $( '#Row2BoxLeft' ).height() )+'px'} );
	}
	else{
		$( '#Row2BoxMiddle' ).css( {'height':( $( '#Row2BoxRight' ).height() )+'px'} );
		$( '#Row2BoxLeft' ).css( {'height':( $( '#Row2BoxRight' ).height() )+'px'} );
	}
}
else{
	if ( $( '#Row2BoxMiddle' ).height() > $( '#Row2BoxRight' ).height() ) {
		$( '#Row2BoxRight' ).css( {'height':( $( '#Row2BoxMiddle' ).height() )+'px'} );
		$( '#Row2BoxLeft' ).css( {'height':( $( '#Row2BoxMiddle' ).height() )+'px'} );
	}
	else{
		$( '#Row2BoxMiddle' ).css( {'height':( $( '#Row2BoxRight' ).height() )+'px'} );
		$( '#Row2BoxLeft' ).css( {'height':( $( '#Row2BoxRight' ).height() )+'px'} );
	}
}
 
if ( $( '#Row3BoxLeft' ).height() > $( '#Row3BoxRight' ).height() ) {
	$( '#Row3BoxRight' ).css( {
		'height':( $( '#Row3BoxLeft' ).height() )+'px'
	} );
} else {
	$( '#Row3BoxLeft' ).css( {
		'height':( $( '#Row3BoxRight' ).height() )+'px'
	} );
}

/* Hide "standard" rating text in articles */
$(".mw-rating-about-link:contains('Standard')").hide();
$(".ns--1 .mw-rating-about-link:contains('Standard')").show();



/* Shows your user groups when using Template:USERGROUPS */
function showUserGroups() {
	$( '.userGroups' ).html( mw.config.get( 'wgUserGroups' ).toString() );
}
$(showUserGroups);

/* Shows a box for news reporters on Brickipedia News:Home so they can easily create new reports */
function showNewsReporterBox(){
	if ( (mw.config.get( 'wgUserGroups' ).toString().indexOf( 'newsreporter' ) != -1) || ( mw.config.get( 'wgUserGroups' ).toString().indexOf( 'sysop' ) != -1 ) ) {
		$( '#newsBox' ).load( 'http://en.brickimedia.org/wiki/Brickipedia_News:NRBox #nBox' );
	}
}
$( showNewsReporterBox );

/* Rating template positioning/styling */
if ( screen.width > 600 ) {
	if ( $( 'body' ).hasClass( 'skin-refreshed' ) ) {
		$( '.ratingTemplate' ).appendTo( '#maintitle' );
		$( '.mw-rating-tag' ).appendTo( '#maintitle' );
		$( '#maintitle h1' ).css( {
			'padding-right':'125px'
		} );
		$( '.ratingTemplate' ).css( {
			'float':'right',
			'margin-top':'-45px',
			'margin-right':'10px',
			'background-color':'#fff'
		} );
		$( '.mw-rating-tag' ).css( {
			'float':'right',
			'margin-top':'-45px',
			'margin-right':'10px',
			'background-color':'#fff'
		} );
	} else {
		$( '.ratingTemplate' ).appendTo( '#firstHeading' );
		$( '.mw-rating-tag' ).appendTo( '#firstHeading' );
		$( '#firstHeading h1' ).css( {
			'padding-right':'110px'
		} );
		$( '.ratingTemplate' ).css( {
			'float':'right',
			'font-size':'50%'
		} );
		$( '.mw-rating-tag' ).css( {
			'float':'right',
			'font-size':'50%'
		} );
	}
} else {
	if ( $( 'body' ).hasClass( 'skin-refreshed' ) ) {
		$( '.ratingTemplate' ).appendTo( '#small-toolbox-wrapper' );
		$( '.mw-rating-tag' ).appendTo( '#small-toolbox-wrapper' );
		$( '.ratingTemplate' ).css( {
			'float':'right',
			'margin-top':'15px',
			'margin-right':'10px',
			'background-color':'#fff'
		} );
		$( '.mw-rating-tag' ).css( {
			'float':'right',
			'margin-top':'15px',
			'margin-right':'10px',
			'background-color':'#fff'
		} );
	}
}

/* slidey stuff */
$(function () {
    $( ".clicker-show" ).parent().siblings( "p" ).css( "margin","0em" );
    $( ".clicker-show" ).click( function() {
		$( this ).parent().next().slideDown();
		$( this ).fadeOut();
		$( this ).prev().fadeIn();
    } );
} );
 
$(function () {
    $( ".clicker-hide" ).click( function() {
      $( this ).parent().next().slideUp();
      $( this ).fadeOut();
      $( this ).next().fadeIn();
    } );
} );
/* slidey stuff 2 */
$( function() {
    $( ".slide-link" ).addClass( "link" );
    var hidelink = "[hide]";
    var showlink = "[show]";
 
    $( ".slide-content" ).each( function() {
        if ( $( this ).hasClass( "noshown" ) ) {
            var fid = $( this ).attr( "title" );
            var flink = $( ".slide-link[title=\"" + fid + "\"]" );
            flink.html(showlink);
        } else {
            var tid = $( this ).attr( "title" );
            var tlink = $( ".slide-link[title=\"" + tid + "\"]" );
            tlink.html(hidelink);
        }
    } );
 
    $( ".slide-link" ).click( function() {
        var tid = $( this ).attr( "title" );
        var content = $( ".slide-content[title=\"" + tid + "\"]" );
 
        if (content.hasClass( "noshown" ) ) {
            content.slideDown( 500 );
            $( this ).fadeOut(250, function() {
                $( this ).html(hidelink);
            } );
            $( this ).fadeIn( 250 );
            content.removeClass( "noshown" );
            content.addClass( "shown" );
        } else {
            content.slideUp( 500 );
            $( this ).fadeOut( 250, function() {
				$( this ).html(showlink);
            } );
            $( this ).fadeIn( 250 );
            content.removeClass( "shown" );
            content.addClass( "noshown" );
        }
    } );
} );

/* table scrolling - [[User:UltrasonicNXT]] */
$( window ).scroll( function(){
	placeDetection( $( window ).scrollTop() );
} );
 
function placeDetection(scroll){
  $( ".ttbutton" ).each(function( index ){
	var it = $( this ).nextAll( ".themetable" ).first();
	var top = it.offset().top;
	var bottom = it.outerHeight() + it.offset().top;
	var browser = $(window).height();
 	if( it.outerHeight() > browser * 1.5 ){
		if( scroll >= top && scroll <= bottom && $( this ).is( ":hidden" ) ){
			$( this ).fadeIn();
    	}
		if( scroll <= top || scroll >= bottom && $( this ).is( ":visible" ) ){
 			$( this ).fadeOut();
		}
	} else {
		$( this ).hide();
		}
	} );
}
 
$( ".ttbutton > .bottom" ).click( function() {
	var it = $( this ).parent().nextAll( ".themetable" ).first();
	var where = it.outerHeight() + it.offset().top - 100;
	$( "html,body" ).animate( { scrollTop: where }, 1500);
} );
 
$( ".ttbutton > .top" ).click( function() {
	var it = $( this ).parent().nextAll( ".themetable" ).first();
	var where = it.offset().top - 100;
	$( "html,body" ).animate( { scrollTop: where }, 1500);
} );

/* IRC */
$( function() {
	var nick = (mw.config.get( 'wgUserName' ) === null) ? ( 'BP-Visitor-' + Math.floor(Math.random() * 10) ) : mw.config.get( 'wgUserName' ).replace(/ /g, '_' ); 
	$( '#IRCReplace' ).html( '<iframe src="http://webchat.freenode.net/?nick=' + nick + '&channels=brickipedia&prompt=true&uio=OT10cnVlJjExPTUxJjEyPXRydWU37" width="100%" height="500" style="border:0;"></iframe>' );
} );

/* "Submit Review" button */
$(btnSubmitReview);
 
function btnSubmitReview() {
	var btn;
	var title = mw.config.get( 'wgTitle' ).replace( /&/g, '%26' );
	if ( mw.config.get( 'wgUserName' ) == 'null' ) {
		btn = '<center><div style="background-color:#ddddee;border:2px outset #9999bb;text-align:center;padding:2px 5px" id="sb-rev"><a href="/w/index.php?title=Special:UserLogin">Log in</a> to submit a review</div></center>';
	} else {
		btn = '<center><a style="background-color:#ddddee;border:2px outset #9999bb;text-align:center;padding:2px 5px; display:block;" id="sb-rev" href="/w/index.php?title=Review:' + title + '/' + mw.config.get( 'wgUserName' ) + '&action=edit&preload=MediaWiki:Createplate-Review&redlink=1">Submit a review</a></center>';
	}
	if ( document.getElementById( 'reviewBtn' ) ) {
		document.getElementById( 'reviewBtn' ).innerHTML += btn;
	}
}

/* "Submit Review" area on set infobox */
$( btnSubmitReviewInfobox );
 
function btnSubmitReviewInfobox() {
	var link;
	var title = mw.config.get( 'wgTitle' ).replace( /&/g, '%26' );
	if ( mw.config.get( 'wgUserName' ) != 'null' ) {
		link = '<br/><a href="/w/index.php?title=Review:'+title+'/'+mw.config.get( 'wgUserName' )+'&action=edit&preload=MediaWiki:Createplate-Review&redlink=1">[Submit/view my review]</a>';
	}
	if ( document.getElementById( 'reviewLink' ) ) {
		document.getElementById( 'reviewLink' ).innerHTML += link;
	}
}

/* Advent cal */
$( function() {
	$( '.advent-cal img' ).attr( {
		width: '',
		height: ''
	} );
} );

/* show USERNAME */
$( function() {
	var name = mw.config.get( 'wgUserName' );
	if ( !window.disableUsernameReplace && name ) {
		$( 'span.insertusername' ).text( name );
	}
} );

/* Set infobox image tabber */
$( "#infoBtnBoxOff" ).click( function() {
	$( "#infoBtnBoxOff" ).css( "display", "none" );
	$( "#infoBtnBoxOn" ).css( "display", "inline-block" );
	$( "#infoBtnSetOn" ).css( "display", "none" );
	$( "#infoBtnSetOff" ).css( "display", "inline-block" );
	$( "#infoAltImage" ).hide();
	$( "#infoImage" ).show();
} );
$( "#infoBtnSetOff" ).click( function() {
	$( "#infoBtnBoxOff" ).css( "display", "inline-block" );
	$( "#infoBtnBoxOn" ).css( "display", "none" );
	$( "#infoBtnSetOn" ).css( "display", "inline-block" );
	$( "#infoBtnSetOff" ).css( "display", "none" );
	$( "#infoAltImage" ).show();
	$( "#infoImage" ).hide();
} );



/* Generic tabs code */
/** Tab 1**/
$( "#tabs1Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs1On" ).css( "display", "inline-block" );
	$( "#tabs1Off" ).css( "display", "none" );
	$( "#tabs1Content" ).show();
} );

/** Tab 2**/
$( "#tabs2Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs2On" ).css( "display", "inline-block" );
	$( "#tabs2Off" ).css( "display", "none" );
	$( "#tabs2Content" ).show();
} );

/** Tab 3**/
$( "#tabs3Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs3On" ).css( "display", "inline-block" );
	$( "#tabs3Off" ).css( "display", "none" );
	$( "#tabs3Content" ).show();
} );

/** Tab 4**/
$( "#tabs4Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs4On" ).css( "display", "inline-block" );
	$( "#tabs4Off" ).css( "display", "none" );
	$( "#tabs4Content" ).show();
} );

/** Tab 5**/
$( "#tabs5Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs5On" ).css( "display", "inline-block" );
	$( "#tabs5Off" ).css( "display", "none" );
	$( "#tabs5Content" ).show();
} );

/** Tab 6**/
$( "#tabs6Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs6On" ).css( "display", "inline-block" );
	$( "#tabs6Off" ).css( "display", "none" );
	$( "#tabs6Content" ).show();
} );

/** Tab 7**/
$( "#tabs7Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs7On" ).css( "display", "inline-block" );
	$( "#tabs7Off" ).css( "display", "none" );
	$( "#tabs7Content" ).show();
} );

/** Tab 8**/
$( "#tabs8Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs8On" ).css( "display", "inline-block" );
	$( "#tabs8Off" ).css( "display", "none" );
	$( "#tabs8Content" ).show();
} );

/** Tab 9**/
$( "#tabs9Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs9On" ).css( "display", "inline-block" );
	$( "#tabs9Off" ).css( "display", "none" );
	$( "#tabs9Content" ).show();
} );

/** Tab 10**/
$( "#tabs10Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs10On" ).css( "display", "inline-block" );
	$( "#tabs10Off" ).css( "display", "none" );
	$( "#tabs10Content" ).show();
} );

/** Tab 11**/
$( "#tabs11Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs11On" ).css( "display", "inline-block" );
	$( "#tabs11Off" ).css( "display", "none" );
	$( "#tabs11Content" ).show();
} );

/** Tab 12**/
$( "#tabs12Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs12On" ).css( "display", "inline-block" );
	$( "#tabs12Off" ).css( "display", "none" );
	$( "#tabs12Content" ).show();
} );

/** Tab 13**/
$( "#tabs13Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs13On" ).css( "display", "inline-block" );
	$( "#tabs13Off" ).css( "display", "none" );
	$( "#tabs13Content" ).show();
} );

/** Tab 14**/
$( "#tabs14Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs14On" ).css( "display", "inline-block" );
	$( "#tabs14Off" ).css( "display", "none" );
	$( "#tabs14Content" ).show();
} );

/** Tab 15**/
$( "#tabs15Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs15On" ).css( "display", "inline-block" );
	$( "#tabs15Off" ).css( "display", "none" );
	$( "#tabs15Content" ).show();
} );

/** Tab 16**/
$( "#tabs16Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs16On" ).css( "display", "inline-block" );
	$( "#tabs16Off" ).css( "display", "none" );
	$( "#tabs16Content" ).show();
} );

/** Tab 17**/
$( "#tabs17Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs17On" ).css( "display", "inline-block" );
	$( "#tabs17Off" ).css( "display", "none" );
	$( "#tabs17Content" ).show();
} );

/** Tab 18**/
$( "#tabs18Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs18On" ).css( "display", "inline-block" );
	$( "#tabs18Off" ).css( "display", "none" );
	$( "#tabs18Content" ).show();
} );

/** Tab 19**/
$( "#tabs19Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs19On" ).css( "display", "inline-block" );
	$( "#tabs19Off" ).css( "display", "none" );
	$( "#tabs19Content" ).show();
} );

/** Tab 20**/
$( "#tabs20Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs20On" ).css( "display", "inline-block" );
	$( "#tabs20Off" ).css( "display", "none" );
	$( "#tabs20Content" ).show();
} );

/** Tab 21**/
$( "#tabs21Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs21On" ).css( "display", "inline-block" );
	$( "#tabs21Off" ).css( "display", "none" );
	$( "#tabs21Content" ).show();
} );

/** Tab 22**/
$( "#tabs22Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs22On" ).css( "display", "inline-block" );
	$( "#tabs22Off" ).css( "display", "none" );
	$( "#tabs22Content" ).show();
} );

/** Tab 23**/
$( "#tabs23Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs23On" ).css( "display", "inline-block" );
	$( "#tabs23Off" ).css( "display", "none" );
	$( "#tabs23Content" ).show();
} );

/** Tab 24**/
$( "#tabs24Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs24On" ).css( "display", "inline-block" );
	$( "#tabs24Off" ).css( "display", "none" );
	$( "#tabs24Content" ).show();
} );

/** Tab 25**/
$( "#tabs25Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs25On" ).css( "display", "inline-block" );
	$( "#tabs25Off" ).css( "display", "none" );
	$( "#tabs25Content" ).show();
} );

/** Tab 26**/
$( "#tabs26Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs26On" ).css( "display", "inline-block" );
	$( "#tabs26Off" ).css( "display", "none" );
	$( "#tabs26Content" ).show();
} );

/** Tab 27**/
$( "#tabs27Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs27On" ).css( "display", "inline-block" );
	$( "#tabs27Off" ).css( "display", "none" );
	$( "#tabs27Content" ).show();
} );

/** Tab 28**/
$( "#tabs28Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs28On" ).css( "display", "inline-block" );
	$( "#tabs28Off" ).css( "display", "none" );
	$( "#tabs28Content" ).show();
} );

/** Tab 29**/
$( "#tabs29Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs29On" ).css( "display", "inline-block" );
	$( "#tabs29Off" ).css( "display", "none" );
	$( "#tabs29Content" ).show();
} );

/** Tab 30**/
$( "#tabs30Off" ).click( function() {
	$( ".infoBtnOff" ).css( "display", "inline-block" );
	$( ".infoBtnOn" ).css( "display", "none" );
	$( ".tabsContent" ).hide();
	$( "#tabs30On" ).css( "display", "inline-block" );
	$( "#tabs30Off" ).css( "display", "none" );
	$( "#tabs30Content" ).show();
} );