MediaWiki:Common.js: Porōwnanie wersyji
Linijŏ 1: | Linijŏ 1: | ||
// Skrypt dla strony specjalnej [[Special:Search]] | // Skrypt dla strony specjalnej [[Special:Search]] | ||
− | + | /* | |
− | /* | + | == Small search keyboard == |
− | * Change Special:Search to use a drop-down menu | + | ; Author: Maciej Jaros [[:pl:User:Nux]] |
− | * Description: Dodaje do strony Special:Search menu rozwijane | + | ; Licence: CC-BY or [http://opensource.org/licenses/gpl-license.php GNU General Public License v2] |
− | * | + | */ |
− | * Created by: [[ | + | if (wgCanonicalSpecialPageName == "Search") |
+ | { | ||
+ | addOnloadHook(addSearchKeyboards); | ||
+ | } | ||
+ | |||
+ | function addSearchKeyboards() { | ||
+ | |||
+ | if (document.forms['search']) | ||
+ | addSearchKeyboard(document.forms['search']); | ||
+ | |||
+ | if (document.forms['powersearch']) | ||
+ | addSearchKeyboard(document.forms['powersearch']); | ||
+ | |||
+ | } | ||
+ | |||
+ | function addSearchKeyboard(searchForm) { | ||
+ | var searchBoxId = 'lsearchbox'; | ||
+ | if (!searchForm.lsearchbox) { | ||
+ | if (searchForm.search.id == '') { | ||
+ | searchBoxId = searchForm.name + 'box'; | ||
+ | searchForm.search.id = searchBoxId; | ||
+ | } else | ||
+ | searchBoxId = searchForm.search.id; | ||
+ | } | ||
+ | |||
+ | var letters = new Array('ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż'); | ||
+ | var html = "Klawiaturka: "; | ||
+ | for (var i = 0; i < letters.length; i++) { | ||
+ | html += "<a onclick=\"insertTagsTo_('" + letters[i] + "','','','" + searchBoxId + "');return false\" href=\"#\">" + letters[i] + "</a>"; | ||
+ | } | ||
+ | |||
+ | var newEl = document.createElement('div'); | ||
+ | newEl.className = 'search_keyboard'; | ||
+ | newEl.innerHTML = html; | ||
+ | newEl.style.cssText = 'width:50%; font-size:small; font-weight: bold'; | ||
+ | document.getElementById(searchBoxId).parentNode.appendChild(newEl); | ||
+ | } | ||
+ | |||
+ | /** Change Special:Search to use a drop-down menu | ||
+ | * | ||
+ | * Description: Dodaje do strony Special:Search menu rozwijane | ||
+ | * pozwalające na wybór wyszukiwarki | ||
+ | * Created by: [[en:User:Gracenotes]] | ||
*/ | */ | ||
− | + | ||
− | + | if (wgCanonicalSpecialPageName == "Search") { | |
− | var | + | var searchEngines = []; |
− | + | addOnloadHook(SpecialSearchEnhanced); | |
− | + | } | |
− | createOption = function ( site, action, mainQ, addQ, addV ) { | + | |
− | var opt = document.createElement( 'option' ); | + | function SpecialSearchEnhanced() { |
− | opt.appendChild( document.createTextNode( site ) ); | + | var createOption = function(site, action, mainQ, addQ, addV) { |
− | searchEngines. | + | var opt = document.createElement('option'); |
+ | opt.appendChild(document.createTextNode(site)); | ||
+ | searchEngines[searchEngines.length] = [action, mainQ, addQ, addV]; | ||
return opt; | return opt; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | ||
− | if ( searchForm.lsearchbox ) { | + | var searchForm; |
− | searchBox = searchForm.lsearchbox; | + | if (document.forms['search']) |
+ | searchForm = document.forms['search']; | ||
+ | else if (document.forms['powersearch']) | ||
+ | searchForm = document.forms['powersearch']; | ||
+ | |||
+ | if (searchForm.lsearchbox) { | ||
+ | var searchBox = searchForm.lsearchbox; | ||
} else { | } else { | ||
− | searchBox = searchForm.search; | + | var searchBox = searchForm.search; |
} | } | ||
− | + | var selectBox = document.createElement('select'); | |
− | |||
selectBox.id = 'searchEngine'; | selectBox.id = 'searchEngine'; | ||
− | + | searchForm.onsubmit = function() { | |
− | searchForm.onsubmit = function () { | + | var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex]; |
− | optSelected = searchEngines[ document.getElementById( 'searchEngine' ).selectedIndex ]; | + | searchForm.action = optSelected[0]; |
− | searchForm.action = optSelected[ 0 ]; | + | searchBox.name = optSelected[1]; |
− | searchBox.name = optSelected[ 1 ]; | + | searchForm.title.value = optSelected[3]; |
− | searchForm.title.value = optSelected[ 3 ]; | + | searchForm.title.name = optSelected[2]; |
− | searchForm.title.name = optSelected[ 2 ]; | + | } |
− | } | + | selectBox.appendChild(createOption('MediaWiki', wgScriptPath + '/index.php', 'search', 'title', 'Special:Search')); |
− | + | selectBox.appendChild(createOption('Google', 'http://www.google.pl/search', 'q', 'sitesearch', 'pl.wikipedia.org')); | |
− | selectBox.appendChild( createOption( 'MediaWiki', | + | selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'pl.wikipedia.org')); |
− | selectBox.appendChild( createOption( 'Google', '//www.google.pl/search', 'q', 'sitesearch', 'pl. | + | selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://pl.wikipedia.org')); |
− | selectBox.appendChild( createOption( 'Yahoo', '//search.yahoo.com/search', 'p', 'vs', 'pl. | + | selectBox.appendChild(createOption('Wikiwix', 'http://pl.wikiwix.com/', 'action', 'lang', 'pl')); |
− | selectBox.appendChild( createOption( ' | + | selectBox.appendChild(createOption('Mayflower - grafiki', 'http://toolserver.org/~tangotango/mayflower/search.php', 'q', 'il', 'pl')); |
+ | |||
searchBox.style.marginLeft = '0px'; | searchBox.style.marginLeft = '0px'; | ||
− | + | if (document.getElementById('loadStatus')) { | |
− | if ( document.getElementById( 'loadStatus' ) ) { | + | var lStat = document.getElementById('loadStatus'); |
− | lStat = document.getElementById( 'loadStatus' ); | ||
} else { | } else { | ||
− | lStat = searchForm. | + | var lStat = searchForm.fulltext; |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
− | + | lStat.parentNode.insertBefore(selectBox, lStat); | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } |
Wersyjŏ ze dnia 20:41, 31 mar 2019
// Skrypt dla strony specjalnej [[Special:Search]] /* == Small search keyboard == ; Author: Maciej Jaros [[:pl:User:Nux]] ; Licence: CC-BY or [http://opensource.org/licenses/gpl-license.php GNU General Public License v2] */ if (wgCanonicalSpecialPageName == "Search") { addOnloadHook(addSearchKeyboards); } function addSearchKeyboards() { if (document.forms['search']) addSearchKeyboard(document.forms['search']); if (document.forms['powersearch']) addSearchKeyboard(document.forms['powersearch']); } function addSearchKeyboard(searchForm) { var searchBoxId = 'lsearchbox'; if (!searchForm.lsearchbox) { if (searchForm.search.id == '') { searchBoxId = searchForm.name + 'box'; searchForm.search.id = searchBoxId; } else searchBoxId = searchForm.search.id; } var letters = new Array('ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż'); var html = "Klawiaturka: "; for (var i = 0; i < letters.length; i++) { html += "<a onclick=\"insertTagsTo_('" + letters[i] + "','','','" + searchBoxId + "');return false\" href=\"#\">" + letters[i] + "</a>"; } var newEl = document.createElement('div'); newEl.className = 'search_keyboard'; newEl.innerHTML = html; newEl.style.cssText = 'width:50%; font-size:small; font-weight: bold'; document.getElementById(searchBoxId).parentNode.appendChild(newEl); } /** Change Special:Search to use a drop-down menu * * Description: Dodaje do strony Special:Search menu rozwijane * pozwalające na wybór wyszukiwarki * Created by: [[en:User:Gracenotes]] */ if (wgCanonicalSpecialPageName == "Search") { var searchEngines = []; addOnloadHook(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; } var searchForm; if (document.forms['search']) searchForm = document.forms['search']; else if (document.forms['powersearch']) searchForm = document.forms['powersearch']; 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('MediaWiki', wgScriptPath + '/index.php', 'search', 'title', 'Special:Search')); selectBox.appendChild(createOption('Google', 'http://www.google.pl/search', 'q', 'sitesearch', 'pl.wikipedia.org')); selectBox.appendChild(createOption('Yahoo', 'http://search.yahoo.com/search', 'p', 'vs', 'pl.wikipedia.org')); selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://pl.wikipedia.org')); selectBox.appendChild(createOption('Wikiwix', 'http://pl.wikiwix.com/', 'action', 'lang', 'pl')); selectBox.appendChild(createOption('Mayflower - grafiki', 'http://toolserver.org/~tangotango/mayflower/search.php', 'q', 'il', 'pl')); searchBox.style.marginLeft = '0px'; if (document.getElementById('loadStatus')) { var lStat = document.getElementById('loadStatus'); } else { var lStat = searchForm.fulltext; } lStat.parentNode.insertBefore(selectBox, lStat); }