MediaWiki:Common.js
From Brickipedia, the LEGO Wiki
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.
mw.loader.load( '//en.brickimedia.org/w/index.php?title=User:ToaMeiko/createpage.js&action=raw&ctype=text/javascript' );
mw.loader.load( '//en.brickimedia.org/w/index.php?title=MediaWiki:NewBlog.js&action=raw&ctype=text/javascript' );
mw.loader.load( '//en.brickimedia.org/w/index.php?title=MediaWiki:NewReview.js&action=raw&ctype=text/javascript' );
/* 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( '//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 */
/** commented out on 11 May 2024 by [[User:Jack Phoenix]] as freenode is gone, we're now on Libera and have been for a while
$( 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 */
for ( var tabIterator = 1; tabIterator <= 30; tabIterator++ ) {
// For searching: #tabs1Off, #tabs2Off, #tabs3Off, #tabs4Off, #tabs5Off, #tabs6Off,
// #tabs7Off, #tabs8Off, #tabs9Off, #tabs10Off, #tabs11Off, #tabs12Off, #tabs13Off, #tabs14Off,
// #tabs15Off, #tabs16Off, #tabs17Off, #tabs18Off, #tabs19Off, #tabs20Off, #tabs21Off, #tabs22Off,
// #tabs23Off, #tabs24Off, #tabs25Off, #tabs26Off, #tabs27Off, #tabs28Off, #tabs29Off, #tabs30Off
//
// #tabs1On, #tabs2On, #tabs3On, #tabs4On, #tabs5On, #tabs6On, #tabs7On, #tabs8On, #tabs9On,
// #tabs10On, #tabs11On, #tabs12On, #tabs13On, #tabs14On, #tabs15On, #tabs16On, #tabs17On,
// #tabs18On, #tabs19On, #tabs20On, #tabs21On, #tabs22On, #tabs23On, #tabs24On, #tabs25On,
// #tabs26On, #tabs27On, #tabs28On, #tabs29On, #tabs30On
//
// #tabs1Content, #tabs2Content, #tabs3Content, #tabs4Content, #tabs5Content, #tabs6Content,
// #tabs7Content, #tabs8Content, #tabs9Content, #tabs10Content, #tabs11Content, #tabs12Content,
// #tabs13Content, #tabs14Content, #tabs15Content, #tabs16Content, #tabs17Content, #tabs18Content,
// #tabs19Content, #tabs20Content, #tabs21Content, #tabs22Content, #tabs23Content, #tabs24Content,
// #tabs25Content, #tabs26Content, #tabs27Content, #tabs28Content, #tabs29Content, #tabs30Content
$( '#tabs' + tabIterator + 'Off' ).click( function() {
$( '.infoBtnOff' ).css( 'display', 'inline-block' );
$( '.infoBtnOn' ).css( 'display', 'none' );
$( '.tabsContent' ).hide();
$( '#tabs' + tabIterator + 'On' ).css( 'display', 'inline-block' );
$( '#tabs' + tabIterator + 'Off' ).css( 'display', 'none' );
$( '#tabs' + tabIterator + 'Content' ).show();
} );
}
/* Advent calendar show/hide */
$( ".calShowAll" ).click(function() {
$(".calContent").show();
$(".calHider").hide();
});
$( ".calHideAll" ).click(function() {
$(".calContent").hide();
$(".calHider").show();
});
for ( var iterator = 1; iterator <= 24; iterator++ ) {
// For searching: .calHider1, .calHider2, .calHider3, .calHider4, .calHider5,
// .calHider6, .calHider7, .calHider8, .calHider9, .calHider10, .calHider11,
// .calHider12, .calHider13, .calHider14, .calHider15, .calHider16, .calHider17,
// .calHider18, .calHider19, .calHider20, .calHider21, .calHider22, .calHider23,
// .calHider24
// .calContent1, .calContent2, .calContent3, .calContent4, .calContent5, .calContent6,
// .calContent7, .calContent8, .calContent9, .calContent10, .calContent11, .calContent12,
// .calContent13, .calContent14, .calContent15, .calContent16, .calContent17, .calContent18,
// .calContent19, .calContent20, .calContent21, .calContent22, .calContent23, .calContent24
$( '.calHider' + iterator ).click( function() {
$( '.calHider' + iterator ).hide();
$( '.calContent' + iterator ).show();
} );
$( '.calContent' + iterator ).click( function() {
$( '.calHider' + iterator ).show();
$( '.calContent' + iterator ).hide();
} );
}