МедијаВики:Gadget-externalsearch.js

Напомена: По објавувањето може да треба да го исчистите меѓускладот (кеш) на прелистувачот за да можете ги видите промените.

  • Firefox / Safari: Држете Shift и стиснете на Превчитај (Reload) или притиснете Ctrl-F5 или Ctrl-R (⌘-R на Mac);
  • Google Chrome: Притиснете Ctrl-Shift-R (⌘-R на Mac)
  • Internet Explorer / Edge: Држете Ctrl додека притискате на Refresh или притиснете Ctrl-F5.
  • Opera: Стиснете на Ctrl-F5.
//<source lang="JavaScript">

/** Change Special:Search to use a drop-down menu *******************************************************
 *
 * Description: Change Special:Search to use a drop-down menu, with the default being
 *	             the internal MediaWiki engine
 * Created and maintained by: [[User:Gracenotes]]
 */

function SpecialSearchEnhanced() {
	var createOption = function( site, action, mainQ, addQ, addV ) {
		var opt = document.createElement( 'option' );
		opt.appendChild( document.createTextNode( site ) );
		searchEngines.push([action, mainQ, addQ, addV]);
		return opt;
	};

	var searchBox, searchForm;
	if ( document.forms.powersearch ) {
		searchForm = document.forms.powersearch;
	}
	if ( document.forms.search ) {
		searchForm = document.forms.search;
	}

	if ( searchForm.lsearchbox ) {
		searchBox = searchForm.lsearchbox;
	} else {
		searchBox = searchForm.search;
	}
	var selectBox = document.createElement( 'select' );
	selectBox.id = 'searchEngine';
	searchForm.onsubmit = function() {
		var optSelected = searchEngines[document.getElementById( 'searchEngine' ).selectedIndex];
		searchForm.action = optSelected[0];
		searchBox.name = optSelected[1];
		searchForm.title.value = optSelected[3];
		searchForm.title.name = optSelected[2];
	};
	selectBox.appendChild( createOption( 'Македонска Википедија', mw.config.get( 'wgScriptPath' ) + '/index.php', 'search', 'title', 'Специјални:Барај' ) );
	selectBox.appendChild( createOption( 'Google', 'http://www.google.com/search', 'q', 'sitesearch', 'mk.wikipedia.org' ) );
	selectBox.appendChild( createOption( 'Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'mk.wikipedia.org' ) );
	selectBox.appendChild( createOption( 'Bing', 'http://www.bing.com/search', 'q', 'q1', 'site:http://mk.wikipedia.org' ) );
	selectBox.appendChild( createOption( 'Wikiwix', 'http://www.wikiwix.com/', 'action', 'lang', 'mk' ) );
	selectBox.appendChild( createOption( 'Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'en' ) );
	searchBox.style.marginLeft = '0px';
	var lStat;
	if ( document.getElementById( 'loadStatus' ) ) {
		lStat = document.getElementById( 'loadStatus' );
	} else {
		lStat = searchForm.title;
		if ( typeof lStat == 'object' && typeof lStat.length === 'number' ) {
			lStat = lStat[0];
		}
	}
	lStat.parentNode.insertBefore( selectBox, lStat );
}

var searchEngines = [];

if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) { // scripts specific to Special:Search
	$( SpecialSearchEnhanced );
}

//</source>