MediaWiki:Common.js: Porōwnanie wersyji

Ze SileSłownik
Idź do: nawigacyjŏ, szukej
(Wycōfaniy wersyji 776 naszkryflanej bez Grzegorz Kulik (godka))
Ôznaczynie: Anulowanie edycji
(Wycōfaniy wersyji 775 naszkryflanej bez Grzegorz Kulik (godka))
Ôznaczynie: Anulowanie edycji
Linijŏ 1: Linijŏ 1:
 
// Skrypt dla strony specjalnej [[Special:Search]]
 
// Skrypt dla strony specjalnej [[Special:Search]]
/*
+
 
== Small search keyboard ==
+
/**
; Author: Maciej Jaros [[:pl:User:Nux]]
+
  * Change Special:Search to use a drop-down menu
; Licence: CC-BY or [http://opensource.org/licenses/gpl-license.php GNU General Public License v2]
+
  * Description: Dodaje do strony Special:Search menu rozwijane
*/
+
  *             pozwalające na wybór wyszukiwarki
if (wgCanonicalSpecialPageName == "Search")
+
  * Created by: [[:en:User:Gracenotes]]
{
 
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") {
+
function specialSearchEnhanced() {
var searchEngines = [];
+
var searchEngines, createOption, searchForm, searchBox, selectBox, optSelected, lStat;
addOnloadHook(SpecialSearchEnhanced);
+
searchEngines = [];
}
+
+
createOption = function ( site, action, mainQ, addQ, addV ) {
function SpecialSearchEnhanced() {
+
var opt = document.createElement( 'option' );
var createOption = function(site, action, mainQ, addQ, addV) {
+
opt.appendChild( document.createTextNode( site ) );
var opt = document.createElement('option');
+
searchEngines.push( [ action, mainQ, addQ, addV ] );
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;
 
}
 
}
+
 
var searchForm;
+
if ( searchForm.lsearchbox ) {
if (document.forms['search'])
+
searchBox = searchForm.lsearchbox;
searchForm = document.forms['search'];
 
else if (document.forms['powersearch'])
 
searchForm = document.forms['powersearch'];
 
 
if (searchForm.lsearchbox) {
 
var searchBox = searchForm.lsearchbox;
 
 
} else {
 
} else {
var searchBox = searchForm.search;
+
searchBox = searchForm.search;
 
}
 
}
var selectBox = document.createElement('select');
+
 +
selectBox = document.createElement( 'select' );
 
selectBox.id = 'searchEngine';
 
selectBox.id = 'searchEngine';
searchForm.onsubmit = function() {
+
var optSelected = searchEngines[document.getElementById('searchEngine').selectedIndex];
+
searchForm.onsubmit = function () {
searchForm.action = optSelected[0];
+
optSelected = searchEngines[ document.getElementById( 'searchEngine' ).selectedIndex ];
searchBox.name = optSelected[1];
+
searchForm.action = optSelected[ 0 ];
searchForm.title.value = optSelected[3];
+
searchBox.name = optSelected[ 1 ];
searchForm.title.name = optSelected[2];
+
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( 'MediaWiki', mw.util.wikiScript(), 'search', 'title', 'Special:Search' ) );
selectBox.appendChild(createOption('Windows Live', 'http://search.live.com/results.aspx', 'q', 'q1', 'site:http://pl.wikipedia.org'));
+
selectBox.appendChild( createOption( 'Google', '//www.google.pl/search', 'q', 'sitesearch', 'pl.wiktionary.org' ) );
selectBox.appendChild(createOption('Wikiwix', 'http://pl.wikiwix.com/', 'action', 'lang', 'pl'));
+
selectBox.appendChild( createOption( 'Yahoo', '//search.yahoo.com/search', 'p', 'vs', 'pl.wiktionary.org' ) );
selectBox.appendChild(createOption('Mayflower - grafiki', 'http://toolserver.org/~tangotango/mayflower/search.php', 'q', 'il', 'pl'));
+
selectBox.appendChild( createOption( 'Bing', '//www.bing.com/search', 'q', 'q1', 'site:http://pl.wiktionary.org' ) );
 
 
searchBox.style.marginLeft = '0px';
 
searchBox.style.marginLeft = '0px';
if (document.getElementById('loadStatus')) {
+
var lStat = document.getElementById('loadStatus');
+
if ( document.getElementById( 'loadStatus' ) ) {
 +
lStat = document.getElementById( 'loadStatus' );
 
} else {
 
} else {
var lStat = searchForm.fulltext;
+
lStat = searchForm.title;
 +
}
 +
 +
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:43, 31 mar 2019

// Skrypt dla strony specjalnej [[Special:Search]]

/**
 * 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() {
	var searchEngines, createOption, searchForm, searchBox, selectBox, optSelected, lStat;
	searchEngines = [];
	
	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;
	};

	if ( document.forms.powersearch ) {
		searchForm = document.forms.powersearch;
	} else if ( document.forms.search ) {
		searchForm = document.forms.search;
	}

	if ( searchForm.lsearchbox ) {
		searchBox = searchForm.lsearchbox;
	} else {
		searchBox = searchForm.search;
	}
	
	selectBox = document.createElement( 'select' );
	selectBox.id = 'searchEngine';
	
	searchForm.onsubmit = function () {
		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', mw.util.wikiScript(), 'search', 'title', 'Special:Search' ) );
	selectBox.appendChild( createOption( 'Google', '//www.google.pl/search', 'q', 'sitesearch', 'pl.wiktionary.org' ) );
	selectBox.appendChild( createOption( 'Yahoo', '//search.yahoo.com/search', 'p', 'vs', 'pl.wiktionary.org' ) );
	selectBox.appendChild( createOption( 'Bing', '//www.bing.com/search', 'q', 'q1', 'site:http://pl.wiktionary.org' ) );
	searchBox.style.marginLeft = '0px';
	
	if ( document.getElementById( 'loadStatus' ) ) {
		lStat = document.getElementById( 'loadStatus' );
	} else {
		lStat = searchForm.title;
	}
	
	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;
		}
	}

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