MediaWiki:Gadget-Searchnotincat.js

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
/**
  * Builds a search-string like Gadget-Searchnotincat.js +-incategory:"Gadget-Searchnotincat.js"
  * to ease finding images not in a category.
  * The link is added as a new tab (monobook) or to the tab-cycler(dropdown, vector)
**/

/*global mw, jQuery*/
if (mw.config.get('wgNamespaceNumber') === 14) {
  jQuery(document).ready(function(){
    'use strict';
    mw.util.addPortletLink('p-cactions', 
      mw.config.get('wgScript') + "?title=Special:Search&search=" + 
      encodeURIComponent(mw.config.get('wgTitle')) + "+-incategory:%22" + 
      (mw.config.get('wgTitle').split(" ").join("_")) + "%22", 
    'Search not in category', 
    'ca-searchnotincat', 
    "Find images not in the category", null);
  });
}