You must log in to edit PetroWiki. Help with editing
Content of PetroWiki is intended for personal use only and to supplement, not replace, engineering judgment. SPE disclaims any and all liability for your use of such content. More information
MediaWiki:Common.js: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
/* Any JavaScript here will be loaded for all users on every page load. */ | /* Any JavaScript here will be loaded for all users on every page load. */ /** | ||
/** | |||
* MainPage-tab | * MainPage-tab | ||
* On the main page (and its associated namespaces and actions (Talk, edit, history etc.) | * On the main page (and its associated namespaces and actions (Talk, edit, history etc.) | ||
Line 8: | Line 8: | ||
* @rev: 3 | * @rev: 3 | ||
*/ | */ | ||
$( document ).ready( function() { | $( document ).ready( function() { | ||
var title = mw.config.get( 'wgTitle' ); | var title = mw.config.get( 'wgTitle' ); | ||
var hasMainPageTab = (title === 'Main Page'); // Title of the main page. If applicable, without the namespace prefix (eg. "MyWiki:") | |||
if ( hasMainPageTab ) { | |||
$( '#ca-nstab-main a' ).text( title ); | |||
} | |||
//The line below should be enabled if UploadWizard doesn't work on IE. //if (isIE() != "") { $("#t-upload a").prop('href', '/Special:Upload'); } | |||
} ); | |||
function stristr (haystack, needle, bool) { | function stristr (haystack, needle, bool) { | ||
// * example 1: stristr('Kevin van Zonneveld', 'Van'); | // * example 1: stristr('Kevin van Zonneveld', 'Van'); | ||
// * returns 1: 'van Zonneveld' | |||
// * example 2: stristr('Kevin van Zonneveld', 'VAN', true); | |||
// * returns 2: 'Kevin ' | |||
var pos = 0; | |||
haystack += '';'' | |||
pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase());'' | |||
if (pos == -1) { | |||
return false; | |||
} else { | |||
if (bool) { | |||
return haystack.substr(0, pos); | |||
} else { | |||
return haystack.slice(pos); | |||
} | |||
} | |||
} | |||
function isIE() { | |||
var myNav = navigator.userAgent.toLowerCase(); | |||
return (myNav.indexOf('msie')!= -1)? parseInt(myNav.split('msie')[1]): false; | |||
} | } | ||
function sizing() { | function sizing() { | ||
var request_uri = location.pathname + location.search; | var request_uri = location.pathname + location.search; | ||
left_space= $('#side').outerWidth( true ); | |||
right_space= $('#sponsor').outerWidth( true ); | |||
//alert("Left: "+left_space+" Right: "+right_space+" Window: "+$('#container').innerWidth()); | //alert("Left: "+left_space+" Right: "+right_space+" Window: "+$('#container').innerWidth()); | ||
//$('#mainContent').width($(window).width() - left_space - right_space -10); | |||
//$('#mainContent').width($('#container').innerWidth() - left_space - right_space-10); | |||
if(stristr(request_uri,'/special:') || stristr(request_uri,'/special%3a') || request_uri.indexOf("Special:")!== -1 || request_uri.indexOf("Special%3A")!== -1) | |||
$('#mainContent').width($('#container').innerWidth() - left_space - right_space-40); | |||
else | |||
$('#mainContent').width($('#container').innerWidth() - left_space - right_space-10); | |||
} | } | ||
$(document).ready(sizing); | $(document).ready(sizing); $(window).resize(sizing); | ||
$(window).resize(sizing); | |||
var addthis_config = addthis_config||{}; addthis_config.data_track_addressbar = false; addthis_config.data_track_clickback = false; | |||
//$( "input#mw-search-ns274" ).parent().parent().css( "display", "none" ); | |||
Latest revision as of 13:26, 8 January 2016
/* Any JavaScript here will be loaded for all users on every page load. */ /** * MainPage-tab * On the main page (and its associated namespaces and actions (Talk, edit, history etc.) * this script will put "Main Page" instead of "Article" or "Page" in the first tab. * * @source: www.mediawiki.org/wiki/Snippets/Main_Page_tab * @rev: 3 */ $( document ).ready( function() { var title = mw.config.get( 'wgTitle' ); var hasMainPageTab = (title === 'Main Page'); // Title of the main page. If applicable, without the namespace prefix (eg. "MyWiki:") if ( hasMainPageTab ) { $( '#ca-nstab-main a' ).text( title ); } //The line below should be enabled if UploadWizard doesn't work on IE. //if (isIE() != "") { $("#t-upload a").prop('href', '/Special:Upload'); } } ); function stristr (haystack, needle, bool) { // * example 1: stristr('Kevin van Zonneveld', 'Van'); // * returns 1: 'van Zonneveld' // * example 2: stristr('Kevin van Zonneveld', 'VAN', true); // * returns 2: 'Kevin ' var pos = 0; haystack += '';'' pos = haystack.toLowerCase().indexOf((needle + '').toLowerCase());'' if (pos == -1) { return false; } else { if (bool) { return haystack.substr(0, pos); } else { return haystack.slice(pos); } } } function isIE() { var myNav = navigator.userAgent.toLowerCase(); return (myNav.indexOf('msie')!= -1)? parseInt(myNav.split('msie')[1]): false; } function sizing() { var request_uri = location.pathname + location.search; left_space= $('#side').outerWidth( true ); right_space= $('#sponsor').outerWidth( true ); //alert("Left: "+left_space+" Right: "+right_space+" Window: "+$('#container').innerWidth()); //$('#mainContent').width($(window).width() - left_space - right_space -10); //$('#mainContent').width($('#container').innerWidth() - left_space - right_space-10); if(stristr(request_uri,'/special:') || stristr(request_uri,'/special%3a') || request_uri.indexOf("Special:")!== -1 || request_uri.indexOf("Special%3A")!== -1) $('#mainContent').width($('#container').innerWidth() - left_space - right_space-40); else $('#mainContent').width($('#container').innerWidth() - left_space - right_space-10); } $(document).ready(sizing); $(window).resize(sizing); var addthis_config = addthis_config||{}; addthis_config.data_track_addressbar = false; addthis_config.data_track_clickback = false; //$( "input#mw-search-ns274" ).parent().parent().css( "display", "none" );