User:Davidgothberg/vector.js

This is an old revision of this page, as edited by Davidgothberg (talk | contribs) at 13:03, 22 February 2011 (More stuff from my monobook.js.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
/* A JavaScript file loaded from my local web server for testing. */
importScriptURI( 'http://localhost:8080/wikipediatest.js' );


/****** Changing the user interface *************************/


/*******************************************************
   Note! The DavidClock has been moved to 
   [[User:Davidgothberg/clock.js]]. See code and usage
   explanation there.
********************************************************/
window.davidClock = 300;    //Static + ticking clock, every 5 minutes.
importScript( "User:Davidgothberg/clock.js" );



/* New messages history */
importScript( "User:Davidgothberg/newmessageshistory.js" );



// Add some links in the navigation and toolbox menus 
// on the left side of the page.
addOnloadHook( function() {
 
  // Add an "Extended search" link to the "navigation" menu".
  addPortletLink( 'p-navigation', wgArticlePath.replace("$1", "Special:Search"), 'Extended search', 'pt-search', 'More search options' );
 
  // Add "Secure server view" or "Normal server view" link.
  if( wgServer == "http://en.wikipedia.org" ) {
    addPortletLink( "p-tb", 
      "https://secure.wikimedia.org/wikipedia/en/wiki/" + wgPageName, 
      "Secure server view", "pt-securepage", "Secure server view" );
  }
  else if( wgServer == "https://secure.wikimedia.org" ) {
    addPortletLink( "p-tb", 
      "http://en.wikipedia.org/wiki/" + wgPageName, 
      "Normal server view", "pt-securepage", "Normal server view" );
  }
 
  // List subpages of the current page.
  addPortletLink( "p-tb", wgScript + "?title=Special:PrefixIndex/" + wgPageName + "/", 
    "Subpages", "pt-subpages", "Subpages" );
 
  // List template transclusion count of the current template page.
  if ( wgNamespaceNumber == 10 || wgNamespaceNumber == 11 ) {
    addPortletLink( "p-tb", 
      "http://toolserver.org/~jarry/templatecount/index.php?lang=en&name=" 
      + wgTitle + "#bottom", 
      "Template transclusions", "pt-transclusion-count", "Transclusion count" );
  }
 
} );



// [[Wikipedia:Tools/Navigation popups]]
// Loaded through "my preferences - Gadgets - Navigation popups".

// When true prevents loading of preview data for the popup.
simplePopups=true;

// When false makes it so the "actions" menu instead
// goes under the page link instead of as a separate menu.
popupActionsMenu=false;



/* Makes the "compare selected revisions" button on history pages 
   into a link (allows diffs in new windows, tabs, etc.)
   [[User:Superm401/Compare link.js]]  */
importScript("User:Superm401/Compare link.js");



/* Colour matching brackets in a copy of the edit box.
   [[User:ais523/bracketmatch.js]]   */
importScript("User:ais523/bracketmatch.js");

 
 
/* Shows both "preview" and "changes" with Ajax, 
   much faster than standard preview/changes buttons. 
   [[User:Js/ajaxPreview]]   */
importScript("User:Js/ajaxPreview.js");
ajaxPreviewButton = 'P';    // "Preview" button text, when above.
ajaxDiffButton = 'D';       // "Changes" button text, when above.
ajaxPreviewPos = 'bottom';  // Buttons on the bottom, replacing standard.
/* Code to execute after each preview update. */
ajaxPreviewExec = function(previewArea) {
  if (window.setupTooltips)
    setupTooltips(previewArea);   // Restart the Navigation popups.
}



/****** End, changing the user interface *************************/
/****** Start, experimenting *************************************/


/* Changes the drop-down menu in Vector into tabs. 
   Works but the tabs overlap due to my low screen resolution. */
// importScript( "User:Svick/DropDownToTabs.js" );


// Changes the drop-down menu in Vector into tabs.
// This modified version of Svick's script didn't work.
/*
function fixTab(item) {
  var node = item.firstChild.firstChild;
  if (node.nodeType != 1 || node.tagName.toLowerCase() != 'span')
    item.firstChild.innerHTML = "<span>" + item.firstChild.innerHTML + "</span>";
}

addOnloadHook( function() {
  // document.getElementById('p-cactions').className = 'vectorTabs';
  var elems = document.getElementById('p-cactions').getElementsByTagName('li');
  for (var i = 0; i < elems.length; i++)
    fixTab(elems[i]);
} )
*/