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

PetroWiki
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.
/* 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 );
        }
      } );

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 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;