MediaWiki:Common.js
Voorkoms
Let wel: Na die wysiging is dit dalk nodig om u blaaier se kasgeheue te verfris voordat u die veranderinge sal sien:
- Firefox / Safari: hou Shift en kliek Herlaai, of druk Ctrl-F5 of Ctrl-R (⌘-R op 'n Mac)
- Google Chrome: Druk Ctrl-Shift-R (⌘-Shift-R op 'n Mac)
- Internet Explorer / Edge: Hou Ctrl en kliek Refresh, of druk Ctrl-F5
- Opera: Gaan na Kieslys → Settings (Opera → Preferences op 'n Mac) en dan na Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */
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();
}
/*
</pre>
== Autotekst in uploadpagina voor bestanden ==
Description: Script voor Speciaal:Uploaden
Maintainers: [[:commons:User:Yonidebest]], [[:commons:User:Dschwen]]
<pre>
*/
if (wgPageName == 'Spesiaal:Upload' || wgPageName == 'Special:Upload') {
importScript('MediaWiki:Upload.js')
}
/** Collapsible tables *********************************************************
*
* Description: Allows tables to be collapsed, showing only the header. See
* [[Wikipedia:NavFrame]].
* Maintainers: [[User:R. Koot]]
*/
var autoCollapse = 2;
var collapseCaption = "hide";
var expandCaption = "show";
function collapseTable( tableIndex )
{
var Button = document.getElementById( "collapseButton" + tableIndex );
var Table = document.getElementById( "collapsibleTable" + tableIndex );
if ( !Table || !Button ) {
return false;
}
var Rows = Table.rows;
if ( Button.firstChild.data == collapseCaption ) {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = "none";
}
Button.firstChild.data = expandCaption;
} else {
for ( var i = 1; i < Rows.length; i++ ) {
Rows[i].style.display = Rows[0].style.display;
}
Button.firstChild.data = collapseCaption;
}
}
function createCollapseButtons()
{
var tableIndex = 0;
var NavigationBoxes = new Object();
var Tables = document.getElementsByTagName( "table" );
for ( var i = 0; i < Tables.length; i++ ) {
if ( hasClass( Tables[i], "collapsible" ) ) {
/* only add button and increment count if there is a header row to work with */
var HeaderRow = Tables[i].getElementsByTagName( "tr" )[0];
if (!HeaderRow) continue;
var Header = HeaderRow.getElementsByTagName( "th" )[0];
if (!Header) continue;
NavigationBoxes[ tableIndex ] = Tables[i];
Tables[i].setAttribute( "id", "collapsibleTable" + tableIndex );
var Button = document.createElement( "span" );
var ButtonLink = document.createElement( "a" );
var ButtonText = document.createTextNode( collapseCaption );
Button.className = "collapseButton"; //Styles are declared in Common.css
ButtonLink.style.color = Header.style.color;
ButtonLink.setAttribute( "id", "collapseButton" + tableIndex );
ButtonLink.setAttribute( "href", "javascript:collapseTable(" + tableIndex + ");" );
ButtonLink.appendChild( ButtonText );
Button.appendChild( document.createTextNode( "[" ) );
Button.appendChild( ButtonLink );
Button.appendChild( document.createTextNode( "]" ) );
Header.insertBefore( Button, Header.childNodes[0] );
tableIndex++;
}
}
for ( var i = 0; i < tableIndex; i++ ) {
if ( hasClass( NavigationBoxes[i], "collapsed" ) || ( tableIndex >= autoCollapse && hasClass( NavigationBoxes[i], "autocollapse" ) ) ) {
collapseTable( i );
}
else if ( hasClass( NavigationBoxes[i], "innercollapse" ) ) {
var element = NavigationBoxes[i];
while (element = element.parentNode) {
if ( hasClass( element, "outercollapse" ) ) {
collapseTable ( i );
break;
}
}
}
}
}
addOnloadHook( createCollapseButtons );
/** 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": "/media/wikipedia/commons/0/01/Button_aanstuur.png",
"speedTip": "Aanstuur",
"tagOpen": "#AANSTUUR [[",
"tagClose": "]]",
"sampleText": "Bladsynaam hier"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/wikipedia/en/c/c9/Button_strike.png",
"speedTip": "Deurstreep teks",
"tagOpen": "<s>",
"tagClose": "</s>",
"sampleText": "Deurstreep teks"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/wikipedia/en/1/13/Button_enter.png",
"speedTip": "Lynbreuk",
"tagOpen": "<br />",
"tagClose": "",
"sampleText": ""};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/wikipedia/en/8/80/Button_upper_letter.png",
"speedTip": "Boskrif",
"tagOpen": "<sup>",
"tagClose": "</sup>",
"sampleText": "Boskrif"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/wikipedia/en/7/70/Button_lower_letter.png",
"speedTip": "Onderskrif",
"tagOpen": "<sub>",
"tagClose": "</sub>",
"sampleText": "Onderskrif"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/wikipedia/en/5/58/Button_small.png",
"speedTip": "Klein teks",
"tagOpen": "<small>",
"tagClose": "</small>",
"sampleText": "Klein teks"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/wikipedia/en/3/34/Button_hide_comment.png",
"speedTip": "Verskuilde kommentaar",
"tagOpen": "<!-- ",
"tagClose": " -->",
"sampleText": "Kommentaar"};
mwCustomEditButtons[mwCustomEditButtons.length] = {
"imageFile": "/media/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": "/media/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": "/media/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"};
}
/*
== 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 = "Sleutelbord: ";
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 selectbox
* pozwalające na wybór wyszukiwarki
* Created by: [[en:User:Gracenotes]] Updated by [[fr:User:Pmartin]]
*/
if ((wgNamespaceNumber == -1) && (wgCanonicalSpecialPageName == "Search")) {
var searchEngines = {
mediawiki: {
ShortName: "MediaWiki-Soek",
Template: "/w/index.php?search={searchTerms}"
},
google: {
ShortName: "Google",
Template: "http://www.google.fr/search?hl=" + wgUserLanguage + "&q={searchTerms}&as_sitesearch=" + wgServer.substr(7, wgServer.length - 1 )
},
yahoo: {
ShortName: "Yahoo!",
Template: "http://" + wgUserLanguage + ".search.yahoo.com/search?p={searchTerms}&vs=" + wgServer
},
wlive: {
ShortName: "Windows Live",
Template: "http://search.live.com/results.aspx?q={searchTerms}&q1=site:" + wgServer
},
wikiwix: {
ShortName: "Wikiwix",
Template: "http://www.wikiwix.com/index.php?action={searchTerms}&lang="+wgContentLanguage
},
};
addOnloadHook(externalSearchEngines);
}
function externalSearchEngines() {
if (typeof SpecialSearchEnhanced2Disabled != 'undefined') return;
var mainNode = document.getElementById("powersearch");
if (!mainNode) mainNode = document.getElementById("search");
if (!mainNode) return;
var beforeNode = document.getElementById("mw-search-top-table");
if (!beforeNode) return;
beforeNode = beforeNode.nextSibling;
if (!beforeNode) return;
var firstEngine = "mediawiki";
var choices = document.createElement("div");
choices.setAttribute("id","searchengineChoices");
choices.style.textAlign = "center";
var lsearchbox = document.getElementById("searchText");
var initValue = lsearchbox.value;
var space = "";
for (var id in searchEngines) {
var engine = searchEngines[id];
if(engine.ShortName)
{
if (space) choices.appendChild(space);
space = document.createTextNode(" ");
var attr = {
type: "radio",
name: "searchengineselect",
value: id,
onFocus: "changeSearchEngine(this.value)",
id: "searchengineRadio-"+id
};
var html = "<input";
for (var a in attr) html += " " + a + "='" + attr[a] + "'";
html += " />";
var span = document.createElement("span");
span.innerHTML = html;
choices.appendChild( span );
var label
if (engine.Template.indexOf('http') == 0) {
label = document.createElement("a");
label.href = engine.Template.replace("{searchTerms}", initValue).replace("{language}", "fr");
} else {
label = document.createElement("label");
}
label.appendChild( document.createTextNode( engine.ShortName ) );
choices.appendChild( label );
}
}
mainNode.insertBefore(choices, beforeNode);
var input = document.createElement("input");
input.id = "searchengineextraparam";
input.type = "hidden";
mainNode.insertBefore(input, beforeNode);
changeSearchEngine(firstEngine, initValue);
}
function changeSearchEngine(selectedId, searchTerms) {
var currentId = document.getElementById("searchengineChoices").currentChoice;
if (selectedId == currentId) return;
document.getElementById("searchengineChoices").currentChoice = selectedId;
var radio = document.getElementById('searchengineRadio-' + selectedId);
radio.checked = "checked";
var engine = searchEngines[selectedId];
var p = engine.Template.indexOf('?');
var params = engine.Template.substr(p+1);
var form;
if (document.forms["search"]) {
form = document.forms["search"];
} else {
form = document.getElementById("powersearch");
}
form.setAttribute("action", engine.Template.substr(0,p));
var l = ("" + params).split("&");
for (var idx = 0;idx < l.length;idx++) {
var p = l[idx].split("=");
var pValue = p[1];
if (pValue == "{language}") {
} else if (pValue == "{searchTerms}") {
var input;
input = document.getElementById("searchText");
input.name = p[0];
} else {
var input = document.getElementById("searchengineextraparam");
input.name = p[0];
input.value = pValue;
}
}
}
/*
Plasing van [wysig]-skakel
---------------------------
Correction des titres qui s'affichent mal en raison de limitations dues à MediaWiki.
Copyright 2006, Marc Mongenet. Licence GPL et GFDL.
The function looks for <span class="editsection">, and move them
at the end of their parent and display them inline in small font.
var oldEditsectionLinks=true disables the function.
*/
function setModifySectionStyle() {
try {
if (!(typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false)) return;
var spans = document.getElementsByTagName("span");
for (var s = 0; s < spans.length; ++s) {
var span = spans[s];
if (span.className == "editsection") {
span.style.fontSize = "xx-small";
span.style.fontWeight = "normal";
span.style.cssFloat = span.style.styleFloat = "none";
span.parentNode.appendChild(document.createTextNode(" "));
span.parentNode.appendChild(span);
}
}
} catch (e) { /* something went wrong */ }
}
addOnloadHook(setModifySectionStyle);
/*
</pre>
== Uitgelicht in andere talen ==
Sterren voor interwikilinks van de [[Wikipedia:Etalage]]-artikelen van andere Wikipedia's. Zie {{tl|Link FA}}. Overgenomen van [[:de:MediaWiki:Common.js]]
Om deze functie uit te zetten, zet <code>enable_linkFA = false;</code> in [[Special:Mypage/monobook.js]].
<pre>
*/
var enable_linkFA = true;
function linkFA() {
if (!enable_linkFA) return;
// links are to replaced in p-lang only
var pLang = document.getElementById("p-lang");
if (!pLang) {
return;
}
var lis = pLang.getElementsByTagName("li");
for (var i=0; i<lis.length; i++) {
var li = lis[i];
// alleen links met een Link FA-sjabloon
if (!document.getElementById(li.className + "-fa")) continue;
// Extra css-klasse zodat het effect verborgen kan worden met CSS
li.className += " FA";
// Verander titel
li.title = "Hierdie is 'n voorbladartikel in 'n ander taal.";
}
}
addOnloadHook(linkFA);
/*
</pre>
/** load MediaWiki:Common.js/numarticles.js ************************** test */
if(wgPageName == 'Gebruiker:Pieter-ZA/Wikipedia_STATISTIEKE' && wgAction == 'view') importScript('MediaWiki:Common.js/numarticles.js')
/** WikiMiniAtlas *******************************************************
*
* Description: WikiMiniAtlas is a popup click and drag world map.
* This script causes all of our coordinate links to display the WikiMiniAtlas popup button.
* The script itself is located on meta because it is used by many projects.
* See [[Meta:WikiMiniAtlas]] for more information.
* Maintainers: [[User:Dschwen]]
*/
if (wgServer == "https://secure.wikimedia.org") {
var metaBase = "https://secure.wikimedia.org/wikipedia/meta";
} else {
var metaBase = "http://meta.wikimedia.org";
}
importScriptURI(metaBase+"/w/index.php?title=MediaWiki:Wikiminiatlas.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400")
// This script is needed for (anonymously) logging search terms by our Squids!
// The search URL will contain the search term,
// please modify retroactively at [[wikt:de:MediaWiki:If-search.js]];
// rather IMPORT this script; example: [[wikt:de:MediaWiki:If-search.js/import]].
// You may have to adapt this?
function $(ID) {return document.getElementById(ID);}
function $inp(ID) {return $(ID).getElementsByTagName("input")[0];}
function tfSearch(f,i) {
if ($(f)) {
$(f).setAttribute("onsubmit", "SubSearch('"+f+"','"+i+"','/')");
$(f).parentNode.innerHTML = $(f).parentNode.innerHTML; // f***ing IE
}
}
function LogSearch() {
tfSearch("searchform","searchInput");
tfSearch("search","searchText");
tfSearch("powersearch","powerSearchText");
tfSearch("bodySearch","bodySearchIput");
if ($("searchform").action.indexOf(wgScript) > -1) {
oSEAp = $inp("searchform").value;
} else {
oSEAp = $("searchform").action.replace(/^.*\/([^\/]+)$/, "$1");
}
}
addOnloadHook(LogSearch);
function SubSearch(f,i,x) {
if ($(i).value == "") {x="";}
$(f).action = wgScriptPath+"iki/"+oSEAp+x+$(i).value;
if ($inp(f).name == "title") {
if ($inp(f).parentNode == $(f)) {
$(f).removeChild($inp(f));
} else {
$(f).firstChild.removeChild($inp(f));
}
}
}