MediaWiki:Common.js: Verskil tussen weergawes

Vanuit Wikiquote
Content deleted Content added
Adriaan (Besprekings | bydraes)
edit
Adriaan (Besprekings | bydraes)
toets
Lyn 174: Lyn 174:
newEl.innerHTML = "\
newEl.innerHTML = "\
<b>Sleutelbordjie:\
<b>Sleutelbordjie:\
&nbsp;<a onclick=\"insertTagsTo_('ä','','','lsearchbox');return false\" href=\"#\">ä</a>\
&nbsp;<a onclick=\"insertTagsTo_('ä','','','lsearchbox');return false\" href=\"#\">ä</a>\
<a onclick=\"insertTagsTo_('ç','','','lsearchbox');return false\" href=\"#\">ç</a>\
<a onclick=\"insertTagsTo_('ç','','','lsearchbox');return false\" href=\"#\">ç</a>\
<a onclick=\"insertTagsTo_('è','','','lsearchbox');return false\" href=\"#\">è</a>\
<a onclick=\"insertTagsTo_('è','','','lsearchbox');return false\" href=\"#\">è</a>\
<a onclick=\"insertTagsTo_('é','','','lsearchbox');return false\" href=\"#\">é</a>\
<a onclick=\"insertTagsTo_('é','','','lsearchbox');return false\" href=\"#\">é</a>\
<a onclick=\"insertTagsTo_('ë','','','lsearchbox');return false\" href=\"#\">ë</a>\
<a onclick=\"insertTagsTo_('ë','','','lsearchbox');return false\" href=\"#\">ë</a>\
<a onclick=\"insertTagsTo_('ê','','','lsearchbox');return false\" href=\"#\">ê</a>\
<a onclick=\"insertTagsTo_('ê','','','lsearchbox');return false\" href=\"#\">ê</a>\
<a onclick=\"insertTagsTo_('ï','','','lsearchbox');return false\" href=\"#\">ï</a>\
<a onclick=\"insertTagsTo_('ï','','','lsearchbox');return false\" href=\"#\">ï</a>\
<a onclick=\"insertTagsTo_('î','','','lsearchbox');return false\" href=\"#\">î</a>\
<a onclick=\"insertTagsTo_('î','','','lsearchbox');return false\" href=\"#\">î</a>\
<a onclick=\"insertTagsTo_('ö','','','lsearchbox');return false\" href=\"#\">ö</a>\
<a onclick=\"insertTagsTo_('ö','','','lsearchbox');return false\" href=\"#\">ö</a>\
<a onclick=\"insertTagsTo_('ô','','','lsearchbox');return false\" href=\"#\">ô</a>\
<a onclick=\"insertTagsTo_('ô','','','lsearchbox');return false\" href=\"#\">ô</a>\
<a onclick=\"insertTagsTo_('ü','','','lsearchbox');return false\" href=\"#\">ü</a>\
<a onclick=\"insertTagsTo_('ü','','','lsearchbox');return false\" href=\"#\">ü</a>\
<a onclick=\"insertTagsTo_('û','','','lsearchbox');return false\" href=\"#\">û</a></b>\
<a onclick=\"insertTagsTo_('û','','','lsearchbox');return false\" href=\"#\">û</a></b>\
";
";

Wysiging soos op 20:21, 2 September 2007

function returnObjById( id ) 
{ 
    if (document.getElementById) 
        var returnVar = document.getElementById(id); 
    else if (document.all) 
        var returnVar = document.all[id]; 
    else if (document.layers) 
        var returnVar = document.layers[id];
    return returnVar; 
}

function insertTagsTo_(tagOpen, tagClose, sampleText, outputid) {
	var txtarea = document.getElementById(outputid);
	if (!txtarea)
		return
	;
 
	// IE
	if (document.selection  && !is_gecko) {
		var theSelection = document.selection.createRange().text;
		if (!theSelection)
			theSelection=sampleText;
		txtarea.focus();
		if (theSelection.charAt(theSelection.length - 1) == " ") { // exclude ending space char, if any
			theSelection = theSelection.substring(0, theSelection.length - 1);
			document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
		} else {
			document.selection.createRange().text = tagOpen + theSelection + tagClose;
		}
 
	// Mozilla
	} else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
		var replaced = false;
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		if (endPos-startPos)
			replaced = true;
		var scrollTop = txtarea.scrollTop;
		var myText = (txtarea.value).substring(startPos, endPos);
		if (!myText)
			myText=sampleText;
		if (myText.charAt(myText.length - 1) == " ") { // exclude ending space char, if any
			subst = tagOpen + myText.substring(0, (myText.length - 1)) + tagClose + " ";
		} else {
			subst = tagOpen + myText + tagClose;
		}
		txtarea.value = txtarea.value.substring(0, startPos) + subst +
			txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		//set new selection
		if (replaced) {
			var cPos = startPos+(tagOpen.length+myText.length+tagClose.length);
			txtarea.selectionStart = cPos;
			txtarea.selectionEnd = cPos;
		} else {
			txtarea.selectionStart = startPos+tagOpen.length;
			txtarea.selectionEnd = startPos+tagOpen.length+myText.length;
		}
		txtarea.scrollTop = scrollTop;
	}
	// reposition cursor if possible
	if (txtarea.createTextRange)
		txtarea.caretPos = document.selection.createRange().duplicate();
}

 /** Extra toolbar options ****************************************************** <nowiki>
  *
  *  Description: UNDOCUMENTED
  *  Maintainers: [[User:MarkS]]?, [[User:Voice of All]], [[User:R. Koot]]
  */
 
 //This is a modified copy of a script by User:MarkS for extra features added by User:Voice of All.
 // This is based on the original code on Wikipedia:Tools/Editing tools
 // To disable this script, add <code>mwCustomEditButtons = [];<code> to [[Special:Mypage/monobook.js]]
 
 if (mwCustomEditButtons) {
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c8/Button_redirect.png",
     "speedTip": "Aanstuur",
     "tagOpen": "#REDIRECT [[",
     "tagClose": "]]",
     "sampleText": "Bladsynaam hier"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/c/c9/Button_strike.png",
     "speedTip": "Deurstroke teks",
     "tagOpen": "<s>",
     "tagClose": "</s>",
     "sampleText": "Deurstroke teks"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
     "speedTip": "Lynbreuk",
     "tagOpen": "<br />",
     "tagClose": "",
     "sampleText": ""};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/8/80/Button_upper_letter.png",
     "speedTip": "Boskrif",
     "tagOpen": "<sup>",
     "tagClose": "</sup>",
     "sampleText": "Boskrif"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/7/70/Button_lower_letter.png",
     "speedTip": "Onderskrif",
     "tagOpen": "<sub>",
     "tagClose": "</sub>",
     "sampleText": "Onderskrif"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/5/58/Button_small.png",
     "speedTip": "Klein teks",
     "tagOpen": "<small>",
     "tagClose": "</small>",
     "sampleText": "Klein teks"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/3/34/Button_hide_comment.png",
     "speedTip": "Verskuilde kommentaar",
     "tagOpen": "<!-- ",
     "tagClose": " -->",
     "sampleText": "Kommentaar"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/12/Button_gallery.png",
     "speedTip": "Galery",
     "tagOpen": "\n<gallery>\n",
     "tagClose": "\n</gallery>",
     "sampleText": "Beeld:Voorbeeld.jpg|Onderskrif1\nBeeld:Voorbeeld.jpg|Onderskrif2"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png",
     "speedTip": "Haal aan",
     "tagOpen": "<blockquote>\n",
     "tagClose": "</blockquote>\n",
     "sampleText": "'n Blok aangehaalde teks"};
 
   mwCustomEditButtons[mwCustomEditButtons.length] = {
     "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
     "speedTip": "Tabel",
     "tagOpen": '{| class="prettytable"\n|-\n',
     "tagClose": "\n|}",
     "sampleText": "! hoof 1\n! hoof 2\n! hoof 3\n|-\n| ry 1, sel 1\n| ry 1, sel 2\n| ry 1, sel 3\n|-\n| ry 2, sel 1\n| ry 2, sel 2\n| ry 2, sel 3"};
 }

 //fix edit summary prompt for undo
 //this code fixes the fact that the undo function combined with the "no edit summary prompter" causes problems if leaving the
 //edit summary unchanged
 //this was added by [[User:Deskana]], code by [[User:Tra]]
 addOnloadHook(function () {
   if (document.location.search.indexOf("undo=") != -1
   && document.getElementsByName('wpAutoSummary')[0]) {
     document.getElementsByName('wpAutoSummary')[0].value='';
   }
 })

/*
== 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 (wgNamespaceNumber == -1 && wgPageName=="Spesiaal:Search")
{
	addOnloadHook(addSearchKeyboard);
}
 
function addSearchKeyboard() {
	var subEl = returnObjById('results');
	var newEl = document.createElement('div');
	newEl.className = 'search_keyboard';
	newEl.innerHTML = "\
<b>Sleutelbordjie:\
&nbsp;<a onclick=\"insertTagsTo_('ä','','','lsearchbox');return false\" href=\"#\">ä</a>\•
<a onclick=\"insertTagsTo_('ç','','','lsearchbox');return false\" href=\"#\">ç</a>\•
<a onclick=\"insertTagsTo_('è','','','lsearchbox');return false\" href=\"#\">è</a>\•
<a onclick=\"insertTagsTo_('é','','','lsearchbox');return false\" href=\"#\">é</a>\•
<a onclick=\"insertTagsTo_('ë','','','lsearchbox');return false\" href=\"#\">ë</a>\•
<a onclick=\"insertTagsTo_('ê','','','lsearchbox');return false\" href=\"#\">ê</a>\•
<a onclick=\"insertTagsTo_('ï','','','lsearchbox');return false\" href=\"#\">ï</a>\•
<a onclick=\"insertTagsTo_('î','','','lsearchbox');return false\" href=\"#\">î</a>\•
<a onclick=\"insertTagsTo_('ö','','','lsearchbox');return false\" href=\"#\">ö</a>\•
<a onclick=\"insertTagsTo_('ô','','','lsearchbox');return false\" href=\"#\">ô</a>\•
<a onclick=\"insertTagsTo_('ü','','','lsearchbox');return false\" href=\"#\">ü</a>\•
<a onclick=\"insertTagsTo_('û','','','lsearchbox');return false\" href=\"#\">û</a></b>\
";
	newEl.style.cssText = 'margin-left:25%; width:50%; font-size:small;';
	subEl.parentNode.insertBefore(newEl, subEl);
}