MediaWiki:Common.js
From Brickipedia, the LEGO Wiki
Revision as of 22:45, 23 June 2016 by LegoFan4000 (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 */
var FirstRowLeftBox = $('.MPBoxesLeft.MPBoxesFirstRow').height();
var FirstRowRightBox = $('.MPBoxesRight.MPBoxesFirstRow').height();
var SecondRowLeftBox = $('.MPBoxesLeft.MPBoxesSecondRow').height();
var SecondRowRightBox = $('.MPBoxesRight.MPBoxesSecondRow').height();
var ThirdRowLeftBox = $('.MPBoxesLeft.MPBoxesThirdRow').height();
var ThirdRowRightBox = $('.MPBoxesRight.MPBoxesThirdRow').height();
if (FirstRowLeftBox > FirstRowRightBox) {
$('.MPBoxesRight.MPBoxesFirstRow').css({'height':($('.MPBoxesLeft.MPBoxesFirstRow').height())+'px'});
} else {
$('.MPBoxesLeft.MPBoxesFirstRow').css({'height':($('.MPBoxesRight.MPBoxesFirstRow').height())+'px'});
}
if (SecondRowLeftBox > SecondRowRightBox) {
$('.MPBoxesRight.MPBoxesSecondRow').css({'height':($('.MPBoxesLeft.MPBoxesSecondRow').height())+'px'});
} else {
$('.MPBoxesLeft.MPBoxesSecondRow').css({'height':($('.MPBoxesRight.MPBoxesSecondRow').height())+'px'});
}
if (ThirdRowLeftBox > ThirdRowRightBox) {
$('.MPBoxesRight.MPBoxesThirdRow').css({'height':($('.MPBoxesLeft.MPBoxesThirdRow').height())+'px'});
} else {
$('.MPBoxesLeft.MPBoxesThirdRow').css({'height':($('.MPBoxesRight.MPBoxesThirdRow').height())+'px'});
}
// Upload form
$('#mw-upload-form').bind('submit', verifyInfo);
function verifyInfo(){
// Check for licensing
if ( $('#wpLicense').val() === '' ) {
alert( 'Please fill out the licensing field.' );
return false;
}
var name = $('#wpDestFile').val().toLowerCase();
var screenshot = name.indexOf('screenshot');
if ( screenshot != -1 ) {
var nonScreenshot = name.substr( 0, screenshot ) + name.substr( screenshot + 10 );
if ( nonScreenshot.match( /[a-z]/g ).length < 6 ){
alert( 'Please name your file more descriptively - we recieve to many files named "screenshot"!' );
return false;
}
}
if ( name.match( '/[\\/\^\$\.\)]}\[\(\)\{\*\+\?\|-#~@\'"`<>%£&]/g' ).length > 3 ){
alert( 'Please use less punctuation characters in your filename - letters are more descriptive!' );
}
return true;
}
/* IRC */
$(function() {
var nick = (wgUserName === null) ? ('BM-Visitor-' + Math.floor(Math.random() * 10)) : wgUserName.replace(/ /g, '_');
$('#IRCReplace').html('<iframe src="http://webchat.freenode.net/?nick=' + nick + '&channels=brickimedia&prompt=true&uio=OT10cnVlJjExPTUxJjEyPXRydWU37" width="100%" height="400" style="border:0;"></iframe>');
});
// Fix for Translate in Refreshed
if(skin == "refreshed") {
$('#pt-uls').appendTo('#userinfo');
mw.loader.addStyleTag('#pt-uls{position:absolute; right:-8em; z-index:3; top:0.85em; color:#ffffff !important;} .uls-trigger{color:#ffffff;} #pt-uls a:visited{color:#ffffff;} #search{width:100%;} @media (max-width: 600px){#pt-uls{display:none;}}');
}
/* .numberofimages class */
function commaSeparateNumber( val ) {
while ( /(\d+)(\d{3})/.test( val.toString() ) ) {
val = val.toString().replace( /(\d+)(\d{3})/, '$1' + ',' + '$2' );
}
return val;
}
$.ajax( {
type: 'GET',
url: 'http://meta.brickimedia.org/api.php?action=query&meta=siteinfo&siprop=statistics&format=json',
dataType: 'jsonp',
success: function( data ) {
images = data.query.statistics.images;
$( '.numberofimages' ).append( commaSeparateNumber( images ) );
}
} );