MediaWiki:Common.js: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
rimossa funzione LinkAdQ per passaggio ai badge di Wikidata
riscrittura da zero della casella combinata di Speciale:Ricerca
Riga 117:
 
/**
* Aggiunge un combobox a [[Speciale:Ricerca]] per selezionare il motore di ricerca.
* RICERCA
* Idea originale a [[en:MediaWiki:Gadget-externalsearch.js]].
*
* Cambia Speciale:Ricerca per usare un menu' a
* @author [[Utente:Rotpunkt]]
* tendina, con come default il motore interno di MediaWiki
*
* Creato e gestito da: [[:en:User:Gracenotes]]
* Importato in it.wiki da: [[Utente:Jalo]]
*/
if (mw.config.get('wgPageName') == "Speciale:Ricerca")
$(function() {
var searchEngines = [];
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;
};
var searchForm = document.forms.powersearch || document.forms.search;
var searchBox = searchForm.lsearchbox || searchForm.search;
 
function comboboxSearch() {
var selectBox = document.createElement('select');
var engines = {
selectBox.id = 'searchEngine';
MediaWiki: '',
searchForm.onsubmit = function() {
selectBox.appendChild(createOption(' Google',: 'http://www.google.com/search', 'q', '?sitesearch', '=it.wikipedia.org&q='));,
var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex];
selectBox.appendChild(createOption(' Yahoo',: 'http://search.yahoo.com/search', 'p', '?vs', '=it.wikipedia.org&p='));,
searchForm.action = optSelected[0];
Bing: 'http://www.bing.com/search?q1=site:http://it.wikipedia.org&q=',
searchBox.name = optSelected[1];
Wikiwix: 'http://it.wikiwix.com/?lang=it&action=',
searchForm.title.value = optSelected[3];
selectBox.appendChild(createOption(' Exalead',: 'http://www.exalead.com/wikipedia/results', 'q', '?language', '=it&q='));
searchForm.title.name = optSelected[2];
}, $select = $( '<select>' ), $form;
};
 
$.each( engines, function ( key, value ) {
selectBox.appendChild(createOption('MediaWiki', mw.config.get('wgScriptPath') + '/index.php', 'search', 'title', 'Speciale:Ricerca'));
$( '<option>' ).html( key ).appendTo( $select );
selectBox.appendChild(createOption('Google', 'http://www.google.com/search', 'q', 'sitesearch', 'it.wikipedia.org'));
} );
selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'it.wikipedia.org'));
$form = $( '#search, #powersearch' );
selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://it.wikipedia.org'));
$form.find( ':submit' ).before( $select, ' ' );
selectBox.appendChild(createOption('Wikiwix', 'http://it.wikiwix.com/', 'action', 'lang', 'it'));
$form.submit( function ( e ) {
selectBox.appendChild(createOption('Exalead', 'http://www.exalead.com/wikipedia/results', 'q', 'language', 'it'));
if ( $select.val() !== 'MediaWiki' ) {
searchBox.style.marginLeft = '0px';
e.preventDefault();
var $text = //$( '#searchText', is the firt search text. '#powerSearchText' is the second, used only if the first is not existent (e.g.: not yet done any search);
document.___location.href = engines[$select.val()] + $text.val();
buttonSearch = document.getElementById('searchText') || document.getElementById('powerSearchText');
}
} );
}
 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) {
buttonSearch.parentNode.insertBefore(selectBox, buttonSearch.nextSibling);
$( comboboxSearch );
});
}
 
/**