Jump to content

User:Dgw/prefixprompt.js

From Wikipedia, the free encyclopedia
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.
/* Add PrefixIndex lookup link to toolbox */
function prefixprompt()
{
  var prefixToLookUp = prompt('What prefix would you like to look up?\n(Type \'help\' for more information about this feature.)',mw.config.get('wgPageName'));
  switch(prefixToLookUp)
  {
    case '': alert('Please enter a prefix.'); prefixprompt(); break;
    case null: /* Do nothing */ break;
    case 'help': window.location = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace("$1", "User:Voyagerfan5761/prefixprompt"); break;
    default: window.location = mw.config.get('wgServer') + mw.config.get('wgArticlePath').replace("$1", "Special:PrefixIndex") + "/" + prefixToLookUp.replace(/ /, "_"); break;
  }
}
 
$( function (){
  if(mw.config.get('wgCanonicalNamespace') != "Special")
  {
    addLink("p-tb", "javascript:prefixprompt();", "Prefix lookup", "t-prefixlookup", "List page titles with a prefix", 0, "t-upload");
  }
});