User:Samwilson/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.
'use strict';

/*global mw, jQuery*/
if ( mw.config.get('wgCanonicalNamespace') === 'Category' ) {
	jQuery( document ).ready( function() {
		var title = mw.config.get( 'wgTitle' );
		var url = mw.config.get('wgScript') + "?title=Special:Search&search=" +
			"%22" + encodeURIComponent( title ) + "%22%20-deepcat:%22" +
			( title.split( ' ' ).join( '_' ) ) + "%22";
	    mw.util.addPortletLink(
	    	'p-cactions', 
			url,
			'Search not in category',
			'ca-searchnotincat', 
			"Find related files that are not yet in this category",
			null
		);
	} );
}