MediaWiki:Common.js: Porōwnanie wersyji

Ze SileSłownik
Idź do: nawigacyjŏ, szukej
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]
  *             pozwalające na wybór wyszukiwarki
+
*/
  * Created by: [[:en:User:Gracenotes]]
+
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]]
 
  */
 
  */
 
+
function specialSearchEnhanced() {
+
if (wgCanonicalSpecialPageName == "Search") {
var searchEngines, createOption, searchForm, searchBox, selectBox, optSelected, lStat;
+
var searchEngines = [];
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.push( [ action, mainQ, addQ, addV ] );
+
var opt = document.createElement('option');
 +
opt.appendChild(document.createTextNode(site));
 +
searchEngines[searchEngines.length] = [action, mainQ, addQ, addV];
 
return opt;
 
return opt;
};
 
 
if ( document.forms.powersearch ) {
 
searchForm = document.forms.powersearch;
 
} else if ( document.forms.search ) {
 
searchForm = document.forms.search;
 
 
}
 
}
 
+
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 = 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', mw.util.wikiScript(), 'search', 'title', 'Special:Search' ) );
+
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.wiktionary.org' ) );
+
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.wiktionary.org' ) );
+
selectBox.appendChild(createOption('Wikiwix', 'http://pl.wikiwix.com/', 'action', 'lang', 'pl'));
selectBox.appendChild( createOption( 'Bing', '//www.bing.com/search', 'q', 'q1', 'site:http://pl.wiktionary.org' ) );
+
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.title;
+
var lStat = searchForm.fulltext;
}
 
 
lStat.parentNode.appendChild( selectBox );
 
}
 
 
 
/**
 
* 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]
 
*/
 
 
 
function addSearchKeyboard( searchForm ) {
 
var searchBoxId, $input, $panel, letters;
 
searchBoxId = 'lsearchbox';
 
 
if ( !searchForm.lsearchbox ) {
 
if ( searchForm.search.id === '' ) {
 
searchBoxId = searchForm.name + 'box';
 
searchForm.search.id = searchBoxId;
 
} else {
 
searchBoxId = searchForm.search.id;
 
}
 
 
}
 
}
 
+
lStat.parentNode.insertBefore(selectBox, lStat);
$input = $( '#' + searchBoxId );
 
$panel = $( '<div class="search_keyboard" style="width:50%; font-size:small; font-weight: bold" />' );
 
$panel.append( 'Wkludź ekstra znak: ' );
 
 
 
letters = [
 
'ą', 'ć', 'ę', 'ł', 'ń', 'ó', 'ś', 'ź', 'ż', 'á', 'é', 'í', 'ó', 'ú',
 
'à', 'è', 'ì', 'ò', 'ù', 'ä', 'ë', 'ï', 'ö', 'ü', 'ÿ', 'â', 'ê', 'ô',
 
'û', 'ŷ', 'å', 'ů', 'ã', 'ẽ', 'ĩ', 'ñ', 'õ', 'ũ', 'æ', 'ð', 'œ', 'ø',
 
'þ', 'ə', 'ŋ', 'ß',
 
document.createElement( 'br' ),
 
'č', 'ě', 'ň', 'ř', 'š', 'ž', 'ŕ', 'ĉ', 'ĝ', 'ĥ', 'ĵ', 'ŝ', 'ŵ', 'ă',
 
'ĕ', 'ŭ',
 
document.createElement( 'br' ),
 
'а', 'б', 'в', 'г', 'д', 'е', 'ё', 'ж', 'з', 'и', 'й', 'к', 'л', 'м',
 
'н', 'о', 'п', 'р', 'с', 'т', 'у', 'ф', 'х', 'ц', 'ч', 'ш', 'щ', 'ь',
 
'ы', 'ъ', 'э', 'ю', 'я',
 
document.createElement( 'br' ),
 
'ґ', 'є', 'і', 'ї'
 
];
 
 
$.each( letters, function ( i, item ) {
 
var $link;
 
 
if ( typeof( item ) === 'object' ) {
 
$panel.append( item );
 
return true;
 
}
 
 
$link = $( '<a href="#"/>' );
 
$link.append( item );
 
 
$link.on( 'click', function ( event ) {
 
$input.textSelection( 'encapsulateSelection', {
 
pre: $( this ).text()
 
} );
 
event.preventDefault();
 
} );
 
 
$panel.append( $link );
 
} );
 
 
 
$input.parent().parent().append( $panel );
 
}
 
 
 
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) {
 
$( function () {
 
specialSearchEnhanced();
 
 
if ( document.forms.search ) {
 
addSearchKeyboard( document.forms.search );
 
}
 
 
 
if ( document.forms.powersearch ) {
 
addSearchKeyboard( document.forms.powersearch );
 
}
 
} );
 
 
}
 
}

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);
}