MediaWiki:Gadget-DeepcatSearch.js

From wikishia

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.
/**
  * Builds a search-string like  Gadget-DeepcatSearch.js + 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*/
var dckey = mw.config.get('wgTitle').replace(/\sby\s.+/g, "");
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=" + 
      encodeURIComponent(dckey) + "+deepcat:%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=" + 
      encodeURIComponent(dckey) + "+deepcat:%22" + 
      (mw.config.get('wgTitle').split(" ").join("_")) + "%22", 
    'Deepcat🔍', 
    'ca-deepcatsearch',
    "Find images in sub-categories");
  });
}