MediaWiki:Gadget-DeepcatSearch.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 deepcat:"Gadget-DeepcatSearch.js"
  * to ease finding images in a category and its sub-categories.
  * The links are added as new tabs (monobook) or to the tab-cycler (dropdown, vector).
  *
  * @rev 15:30, 3 March 2021 (UTC)
  * @author Gadget-Gmaps.js by Docu (2009)
  * @author Gadget-Geocodecattodo.js forked by Abigor (2009)
  * @author Gadget-Searchnotincat.js forked by Docu (2010)
  * @author rewritten by DieBuche (2010) and Rillke (2012)
  * @author Gadget-DeepcatSearch.js forked by RoyZuo (2021)
**/

/*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:MediaSearch&search=" + 
      "deepcategory:%22" + 
      (mw.config.get('wgTitle').split(" ").join("_")) + "%22", 
    'Deepcat🖼️', 
    'ca-deepcatsearch', 
    "Find images in sub-categories");
    mw.util.addPortletLink('p-cactions', 
      mw.config.get('wgScript') + "?title=Special:Search&limit=100&search=" + 
      "deepcategory:%22" + 
      (mw.config.get('wgTitle').split(" ").join("_")) + "%22", 
    'Deepcat🔍', 
    'ca-deepcatsearch',
    "Find images in sub-categories");
  });
}