MediaWiki:Search.js

Origem: Wikiquote, a coletânea de citações livre.
Nota: Após salvar, você terá de limpar a cache do seu navegador para ver as alterações:
  • Internet Explorer: Mantenha pressionada a tecla Ctrl e aperte F5; ou mantenha pressionada a tecla Ctrl e clique no botão "Recarregar" (Reload)
  • Firefox e SeaMonkey: Mantenha pressionada a tecla Shift ⇧ e clique no botão "Recarregar" (Reload ou Atualizar) ou mantenha pressionada a tecla Ctrl e aperte F5; ou mantenha pressionada as teclas Ctrl, e R (Command ⌘, Shift ⌥ e R em Macintosh)
  • Safari e Konqueror: Clique no botão "Recarregar" (Reload)
  • Opera: É necessário limpar manualmente a cache no menu "Ferramentas"→"Preferências"→"Avançadas"→"Histórico" e clicar no botão "Esvaziar Já"
  • Chrome: É necessário limpar manualmente a cache no botão "Ferramentas"→"Limpar dados de navegação", selecione "Esvaziar o cache" e clicar no botão "Limpar dados de navegação"
 /** Pesquisa em vários motores de busca *****************************************************
  *    Origem: [[:w:en:MediaWiki:Common.js]]
  * Descrição: acrescenta um menu drop-down na página [[Especial:Busca]] para pesquisar em vários motores de busca
  *     Autor: [[:w:en:User:Gracenotes]]
  ********************************************************************************************/
 if (mw.config.get('wgPageName') == "Especial:Busca") {
         var searchEngines = [];
         $(SpecialSearchEnhanced);
 }
 
 function SpecialSearchEnhanced() {
         var createOption = function(site, action, mainQ, addQ, addV) {
                 var opt = document.createElement('option');
                 opt.appendChild(document.createTextNode(site));
                 searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
                 return opt;
         };
 
         if (document.forms['powersearch'])
         var searchForm = document.forms['powersearch'];
         if (document.forms['search'])
         var searchForm = document.forms['search'];
 
         if (searchForm.lsearchbox) {
             var searchBox = searchForm.lsearchbox;
         } else {
             var 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('Wikiquote Lusófono', mw.config.get('wgScriptPath') + '/index.php', 'search', 'title', 'Special:Search'));
         selectBox.appendChild(createOption('Wikiquote Anglófono', '//en.wikiquote.org/w/index.php', 'search', 'title', 'Special:Search'));
         selectBox.appendChild(createOption('Wikipédia Lusófona', '//pt.wikipedia.org/w/index.php', 'search', 'title', 'Special:Search'));
         selectBox.appendChild(createOption('Wikipédia Anglófona', '//en.wikipedia.org/w/index.php', 'search', 'title', 'Special:Search'));
         selectBox.appendChild(createOption('Google Portugal', 'http://www.google.pt/search', 'q', 'as_sitesearch', 'pt.wikiquote.org'));
         selectBox.appendChild(createOption('Google Brasil', 'http://www.google.com.br/search', 'q', 'as_sitesearch', 'pt.wikiquote.org'));
         selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'pt.wikiquote.org'));
         selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://pt.wikiquote.org'));
         searchBox.style.marginLeft = '0px';
         if (document.getElementById('loadStatus')) {
             var lStat = document.getElementById('loadStatus');
         } else {
             var lStat = searchForm.fulltext;
         }
         lStat.parentNode.insertBefore(selectBox, lStat);
 }