MediaWiki:Common.js
Napohlad
Kedźbu: Po składowanju dyrbiš snano pufrowak swojeho wobhladowaka wuprózdnić, zo by změny widźał.
- Firefox/Safari: Dźerž tastu Umsch tłóčenu a klikń na Znowa abo tłóč pak Strg-F5 abo Strg-R (⌘-R na Mac);
- Google Chrome: Tłóč na Strg-Umsch-R (⌘-Umsch-R na Mac)
- Internet Explorer: Dźěrź tastu Strg tłóčen a klikń na Znowa abo tłóč Strg-F5.
- Opera: Dźi k Menü → Einstellungen (Opera → Einstellungen na Mac) a potom k Datenschutz & Sicherheit → Browserdaten löschen → Gespeicherte Bilder und Dateien.
/* <source lang="javascript">
Jedes JavaScript hier wird für alle Benutzer für jede Seite geladen.
/* z ruskeje wikipedije */
/* Чтоб была возможность изменить поведение кнопки "+" (добавление новой темы) для страниц обсуждения */
$(function(){
var plus = document.getElementById('ca-addsection');
if (!plus) return;
var custom = document.getElementById('add-custom-section');
if (!custom) return;
plus.firstChild.setAttribute('href', custom.getElementsByTagName('A')[0].href);
})
//po ruskej wikipediji
//according to russian wikipedia
//import module
importedScripts = {}
function importScript2(page, lang) {
page = '?title=' + encodeURIComponent(page.replace(' ','_'))
if (lang) page = '//' + lang + '.wikipedia.org/w/index.php' + page
else page = mw.config.get('wgScript') + page
if (importedScripts[page]) return
importedScripts[page] = true
var s = document.createElement('script')
s.type = 'text/javascript'
s.src = page + '&action=raw&ctype=text/javascript'
document.getElementsByTagName('head')[0].appendChild(s)
}
// end import module
/** Trovita ĉe Arno Lagrange / z esperantorěčneje wikipedije
* insertAfter : insérer un élément dans une page
*/
function insertAfter(parent, node, referenceNode) {
parent.insertBefore(node, referenceNode.nextSibling);
}
/**
* getElementsByClass : rechercher les éléments de la page dont le paramètre "class" est celui recherché
*/
function getElementsByClass(searchClass, node, tag) {
if (node == null) node = document;
if (tag == null) tag = '*';
return $.makeArray( $(node).find(tag+'.'+searchClass) );
}
// Ĝuste akiras la tekstan entenaon de nodo kaj de ties idaj nodoj / z esperantorěčneje wikipedije
// Kopirajto Harmen Christophe, http://openweb.eu.org/articles/validation_avancee, CC
function getTextContent(oNode) {
if (typeof(oNode.textContent)!="undefined") {return oNode.textContent;}
switch (oNode.nodeType) {
case 3: // TEXT_NODE
case 4: // CDATA_SECTION_NODE
return oNode.nodeValue;
break;
case 7: // PROCESSING_INSTRUCTION_NODE
case 8: // COMMENT_NODE
if (getTextContent.caller!=getTextContent) {
return oNode.nodeValue;
}
break;
case 9: // DOCUMENT_NODE
case 10: // DOCUMENT_TYPE_NODE
case 12: // NOTATION_NODE
return null;
break;
}
var _textContent = "";
oNode = oNode.firstChild;
while (oNode) {
_textContent += getTextContent(oNode);
oNode = oNode.nextSibling;
}
return _textContent;
}
// ============================================================
// BEGIN hasclass
//hasClass, from en.wp and ru.wp
var hasClass = (function (){
var reCache = {}
return function (element, className){
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
}
})()
// END hasclass
// ============================================================
//=============================================================
//*** Configuration for "star" logo in front of interwiki links to Featured Articles
//*** and green symbol in front of interwiki links to Good Articles
/** set to false in Special:Mypage/monobook.js to switch off this "feature" */
/** description that is displayed when cursor hovers above FA interwiki links */
var linkFA_description = "Tutón nastawk bu jako ekscelentny pohódnoćeny.";
var linkGA_description = "Tutón nastawk bu jako čitanja hódny pohódnoćeny.";
// linkFA_bullet/linkGA_bullet and linkFA_style/linkGA_Style werden nur für cologneblue verwendet,
// für monobook, modern und simple siehe [[MediaWiki:Common.css]], vector hat in [[MediaWiki:Vector.css]] eigene Definitionen
/** image to use instead of the standard bullet (for cologneblue) */
var linkFA_bullet = "//upload.wikimedia.org/wikipedia/commons/d/d0/Monobook-bullet-star-transparent.png";
var linkGA_bullet = "//upload.wikimedia.org/wikipedia/commons/a/a1/Monobook-bullet-star-gray.png";
/** style to use for the linkFA_bullet/LinkGA_bullet img */
var linkFA_style = "margin-right: 0.2em;";
var linkGA_style = "margin-right: 0.2em;";
/**
* star logo for featured articles in other languages,
* see Template:Link_FA / Template:Link_GA and MediaWiki:Common.css
*/
$(function() {
// early exit when disabled
if ((mw.user.options.exists('linkFA_enabled') && !mw.user.options.get('linkFA_enabled'))) return;
// skins that can be handled the CSS class way
if (mw.config.get('skin') == "monobook" || mw.config.get('skin') == "modern" || mw.config.get('skin')== "vector" ) {
linkFA_CSS();
}
else if (mw.config.get('skin') == "cologneblue") {
linkFA_decorate();
}
/** skin == "monobook" || skin="modern" || skin== "vector"*/
function linkFA_CSS() {
// 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];
//extract necessary classname
var matches = li.className.match( /(?:^| )(interwiki-[^ ]+)(?: |$)/ );
if ( !matches || matches.length != 2 ) {
continue;
}
var className = matches[1];
// only links with a corresponding Link_FA template are interesting
if (document.getElementById(className + "-fa") && li.className.indexOf("badge-featuredarticle") === -1) {
li.className += " FA"; // additional class so the template can be hidden with CSS
li.title = linkFA_description; // change title
continue;
}
if (document.getElementById(className + "-ga") && li.className.indexOf("badge-goodarticle") === -1) {
li.className += " GA"; // additional class so the template can be hidden with CSS
li.title = linkGA_description; // change title
continue;
}
}
}
/** skin == "cologneblue" */
function linkFA_decorate() {
// these root elements can contain FA-/GA-links
var rootIds = new Array("topbar", "footer");
for (var i=0; i<rootIds.length; i++) {
var root = document.getElementById(rootIds[i]);
if (!root) continue;
// if the root exists, try to decorate all the links within
var links = root.getElementsByTagName("a");
for (var j=0; j<links.length; j++) {
decorate(links[j], "-fa", linkFA_bullet, linkFA_description, linkFA_style);
decorate(links[j], "-ga", linkGA_bullet, linkGA_description, linkGA_style);
}
}
}
/** id necessary, modify a link to show the FA- or GA-star (older) */
function decorate(link, idSuffix, bullet, description, style) {
var lang = link.hostname.split(".")[0];
var fa = document.getElementById("interwiki-" + lang + idSuffix);
if (!fa) return;
// build an image-node for the FA-star
var img = document.createElement("img");
img.setAttribute("src", bullet);
img.setAttribute("alt", description);
img.setAttribute("style", style);
// decorate the link with the image
link.appendChild(img);
link.appendChild(link.removeChild(link.firstChild));
link.setAttribute("title", description);
}
});
/**
* load the Edittools on [[Special:Upload]] and prefill the summary textarea
* Load pages: [[MediaWiki:Onlyifuploading.js]], [[MediaWiki:Onlyifediting.js]]
*/
if (mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Upload') {
mw.loader.load('//hsb.wikipedia.org/w/index.php?title=MediaWiki:Onlyifuploading.js&action=raw&ctype=text/javascript');
mw.loader.load('//hsb.wikipedia.org/w/index.php?title=MediaWiki:Onlyifediting.js&action=raw&ctype=text/javascript');
}
/**
* load the Edittools ([[MediaWiki:Edittools]], the part under the edit form)
* Load page: [[MediaWiki:Onlyifediting.js]]
*/
if ( mw.config.get( 'wgAction' ) === 'edit' || mw.config.get( 'wgAction' ) === 'submit' ) {
mw.loader.load('//hsb.wikipedia.org/w/index.php?title=MediaWiki:Onlyifediting.js&action=raw&ctype=text/javascript');
}
// ============================================================
// BEGIN Dynamic Navigation Bars
// NEEDS Enable multiple onload functions
// nowa wersija po ruskej wikipediji
//Collapsible Tables and Divs, [[:ru:ВП:СБ]]
var autoCollapse = 0
var collapseCaption = 'Schować'
var expandCaption = 'Pokazać'
function collapsibleTables(){
var Table, HRow, THs, Header, btn, a, tblIdx = 0, colTables = []
var allTables = document.getElementsByTagName('table')
for (var i=0; Table = allTables[i]; i++){
if (!hasClass(Table, 'collapsible')) continue
if (!(HRow = Table.rows[0])) continue
THs = HRow.getElementsByTagName('th')
if (THs.length == 0) continue
Header = THs[THs.length-1] //last TH, not 1st like in en.wp
Table.id = 'collapsibleTable' + tblIdx
btn = document.createElement('span')
btn.style.styleFloat = btn.style.cssFloat = 'right'
btn.style.fontWeight = 'normal'
a = document.createElement('a')
a.id = 'collapseButton' + tblIdx
a.href = 'javascript:collapseTable(' + tblIdx + ');'
a.appendChild(document.createTextNode(collapseCaption))
btn.appendChild(document.createTextNode('['))
btn.appendChild(a)
btn.appendChild(document.createTextNode(']'))
Header.insertBefore(btn, Header.childNodes[0])
colTables[tblIdx++] = Table
}
for (var i=0; i < tblIdx; i++)
if ((tblIdx > autoCollapse && hasClass(colTables[i], 'autocollapse')) || hasClass(colTables[i], 'collapsed'))
collapseTable(i)
}
function collapseTable (idx){
var Table = document.getElementById('collapsibleTable' + idx)
var btn = document.getElementById('collapseButton' + idx)
if (!Table || !btn) return false
var Rows = Table.rows
var isShown = (btn.firstChild.data == collapseCaption)
btn.firstChild.data = isShown ? expandCaption : collapseCaption
var disp = isShown ? 'none' : Rows[0].style.display
for (var i=1; i < Rows.length; i++)
Rows[i].style.display = disp
}
var NavigationBarHide = '[' + collapseCaption + ']'
var NavigationBarShow = '[' + expandCaption + ']'
var NavigationBarShowDefault = autoCollapse
function collapsibleDivs(){
var navIdx = 0, colNavs = [], i, NavFrame
var content = document.getElementById('content')
if ( !content ) {
return
}
var divs = content.getElementsByTagName('div')
for (i=0; NavFrame = divs[i]; i++) {
if (!hasClass(NavFrame, 'NavFrame')) continue
NavFrame.id = 'NavFrame' + navIdx
var a = document.createElement('a')
a.className = 'NavToggle'
a.id = 'NavToggle' + navIdx
a.href = 'javascript:collapseDiv(' + navIdx + ');'
a.appendChild(document.createTextNode(NavigationBarHide))
// Find the NavHead and attach the toggle link (Must be this complicated because Moz's firstChild handling is borked)
for (var j=0; j < NavFrame.childNodes.length; j++)
if (hasClass(NavFrame.childNodes[j], 'NavHead'))
NavFrame.childNodes[j].appendChild(a)
colNavs[navIdx++] = NavFrame
}
for (i=0; i < navIdx; i++)
if ((navIdx > NavigationBarShowDefault && !hasClass(colNavs[i], 'expanded')) || hasClass(colNavs[i], 'collapsed'))
collapseDiv(i)
}
function collapseDiv(idx) {
var div = document.getElementById('NavFrame' + idx)
var btn = document.getElementById('NavToggle' + idx)
if (!div || !btn) return false
var isShown = (btn.firstChild.data == NavigationBarHide)
btn.firstChild.data = isShown ? NavigationBarShow : NavigationBarHide
var disp = isShown ? 'none' : 'block'
for (var child = div.firstChild; child != null; child = child.nextSibling)
if (hasClass(child, 'NavPic') || hasClass(child, 'NavContent'))
child.style.display = disp
}
$(collapsibleDivs);
$(collapsibleTables);
// END Dynamic Navigation Bars
// ============================================================
// ============================================================
// BEGIN Map
mw.config.set( 'osm_proj_map', 'karta' ); //"map" in project language
mw.config.set( 'osm_proj_lang', 'hsb' ); //project language//
mw.loader.load('//meta.wikimedia.org/w/index.php?title=MediaWiki:OSM.js&action=raw&ctype=text/javascript&smaxage=21600&maxage=86400');
// END Map
// ============================================================
/** Skript für předłoha:Galerija */
$(function() {
if (document.URL.match(/printable/g)) return;
function toggleImageFunction(group, remindex, shwindex) {
return function() {
document.getElementById("ImageGroupsGr" + group + "Im" + remindex).style["display"] = "none";
document.getElementById("ImageGroupsGr" + group + "Im" + shwindex).style["display"] = "block";
return false;
};
}
var divs = document.getElementsByTagName("div");
var i = 0, j = 0;
var units, search;
var currentimage;
var UnitNode;
for (i = 0; i < divs.length; i++) {
if (divs[i].className !== "ImageGroup") { continue; }
UnitNode = undefined;
search = divs[i].getElementsByTagName("div");
for (j = 0; j < search.length; j++) {
if (search[j].className !== "ImageGroupUnits") { continue; }
UnitNode=search[j];
break;
}
if (UnitNode === undefined) { continue; }
units = [];
for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
var temp = UnitNode.childNodes[j];
if (['center', 'mw-halign-center'].some(function(className) { return temp.classList.contains(className); })) { units.push(temp); }
}
var rightlink = undefined;
var commentText = undefined;
var wrap;
for (j = 0; j < units.length; j++) {
currentimage = units[j];
wrap = document.createElement('div');
wrap.id = "ImageGroupsGr" + i + "Im" + j;
currentimage.parentNode.insertBefore(wrap, currentimage);
wrap.appendChild(currentimage);
var leftlink = document.createElement("a");
if (commentText !== undefined) {
leftlink.setAttribute("title", commentText);
}
var comment;
if (typeof(currentimage.getAttribute("title")) !== "string") {
commentText = (j+1) + "/" + units.length;
comment = document.createElement("tt").appendChild(document.createTextNode("("+ commentText + ")"));
}
else {
commentText = currentimage.getAttribute("title");
comment = document.createElement("span").appendChild(document.createTextNode(commentText));
currentimage.removeAttribute("title");
}
if(rightlink !== undefined) {
rightlink.setAttribute("title", commentText);
}
var imghead = document.createElement("div");
rightlink = document.createElement("a");
if (j != 0) {
leftlink.href = "#";
leftlink.onclick = toggleImageFunction(i, j, j-1);
leftlink.appendChild(document.createTextNode("◀"));
}
if (j != units.length - 1) {
rightlink.onclick = toggleImageFunction(i, j, j+1);
rightlink.appendChild(document.createTextNode("▶"));
}
imghead.style["fontSize"] = "110%";
imghead.style["fontweight"] = "bold";
imghead.appendChild(leftlink);
imghead.appendChild(document.createTextNode("\xA0"));
imghead.appendChild(comment);
imghead.appendChild(document.createTextNode("\xA0"));
imghead.appendChild(rightlink);
if (units.length > 1) {
wrap.insertBefore(imghead,wrap.childNodes[0]);
}
if (j != 0) {
wrap.style["display"] = "none";
}
}
}
});
/**
* Script pour alterner entre plusieurs cartes de géolocalisation
*/
function GeoBox_Init(Element){
if(!Element) Element = document.body;
var cont = $( Element ).find( 'div.img_toogle' ).get();
for (var i = 0,m=cont.length; i < m; i++) {
cont[i].id = 'img_toogle_' + i;
var Boxes = $( cont[i] ).find( '.geobox' ).get();
var ToggleLinksDiv = document.createElement('ul');
ToggleLinksDiv.id = 'geoboxToggleLinks_' + i;
for(var a=0,l=Boxes.length;a<l;a++){
var ThisBox = Boxes[a];
ThisBox.id = 'geobox_' + i + "_" + a;
ThisBox.style.borderTop='0';
var ThisAlt = ThisBox.getElementsByTagName('img')[0].alt;
var toggle = document.createElement('a');
toggle.id = 'geoboxToggle_' + i + "_" + a;
toggle.appendChild(document.createTextNode(ThisAlt));
toggle.href='javascript:;';
toggle.onclick = function(){
GeoBox_Toggle(this);
return false;
};
var Li = document.createElement('li');
Li.appendChild(toggle);
ToggleLinksDiv.appendChild(Li);
if(a==(l-1)){
Li.style.display = "none";
}else{
ThisBox.style.display = "none";
}
}
cont[i].appendChild(ToggleLinksDiv);
}
}
function GeoBox_Toggle(link){
var ImgToggleIndex = link.id.split('geoboxToggle_').join('').replace(/_.*/g, "");
var GeoBoxIndex = link.id.replace(/.*_/g, "");
var ImageToggle = document.getElementById('img_toogle_' + ImgToggleIndex);
var Links = document.getElementById('geoboxToggleLinks_' + ImgToggleIndex);
var Geobox = document.getElementById('geobox_' + ImgToggleIndex + "_" + GeoBoxIndex);
var Link = document.getElementById('geoboxToggle_' + ImgToggleIndex + "_" + GeoBoxIndex);
if( (!ImageToggle) || (!Links) || (!Geobox) || (!Link) ) return;
var AllGeoboxes = $( ImageToggle ).find( '.geobox' ).get();
for(var a=0,l=AllGeoboxes.length;a<l;a++){
var ThisgeoBox = AllGeoboxes[a];
if(ThisgeoBox.id === Geobox.id){
ThisgeoBox.style.display = "";
}else{
ThisgeoBox.style.display = "none";
}
}
var AllToggleLinks = Links.getElementsByTagName('a');
for(var a=0,l=AllToggleLinks.length;a<l;a++){
var thisToggleLink = AllToggleLinks[a];
if(thisToggleLink.id === Link.id){
thisToggleLink.parentNode.style.display = "none";
}else{
thisToggleLink.parentNode.style.display = "";
}
}
}
if ( ['view','submit'].indexOf(mw.config.get('wgAction')) !== -1) {
$( function() {
GeoBox_Init();
} );
}
/* Z esperantorěčneje wikipedije */
/** Trovita ĉe Arno Lagrange
* El franclingva Vikipedio :
* Laŭ decido de [[:fr:Wikipédia:Prise de décision/Lien interprojet]]
* Kopias la interprojektajn ligilojn el la ŝablono {{Projekto}}
* en la maldekstran strion
* remove_other_projects = true; en persona monobook.js por krome ne plu aperigi
* la ŝablonon en la paĝo
* no_other_projects = true; en persona monobook.js por malebligi ke tiu skripto funkciu
*/
function aliajProjektoj() {
var div, Portlet_ClassName, PBody_ClassName, Column_Id, skin;
if ((typeof no_other_projects !== 'undefined') && no_other_projects) {
return;
}
if (mw.config.get('wgNamespaceNumber') !== 0) {
return;
}
if (mw.config.get('wgAction') !== 'view') {
return;
}
div = document.getElementById('druhe_projekty');
if(!div) return;
skin = mw.config.get('skin');
if (skin === "monobook") {
Portlet_ClassName = "portlet";
PBody_ClassName = "pBody";
Column_Id = 'column-one';
} else if (skin === "modern") {
Portlet_ClassName = "portlet";
PBody_ClassName = "pBody";
Column_Id = 'mw_portlets';
} else if (skin === "vector") {
Portlet_ClassName = "portal collapsed";
PBody_ClassName = "body";
Column_Id = 'mw-panel'
} else {
Portlet_ClassName = false;
}
if(!Portlet_ClassName) {
return;
}
var list = div.getElementsByTagName('li');
var newlist = document.createElement("ul");
for (var i = 0; i < list.length ; i++) {
list.link = list[i].getElementsByTagName('a')[0];
list.text = list.link.getElementsByTagName('span')[0];
var newlistitem = document.createElement("li");
var newlink = document.createElement("a");
var newlinktext = document.createTextNode(getTextContent(list.text));
newlink.appendChild(newlinktext);
newlink.title=getTextContent(list.link);
newlink.href=list.link.href;
newlistitem.appendChild(newlink);
newlist.appendChild(newlistitem);
}
var interProject = document.createElement("div");
interProject.className = Portlet_ClassName;
interProject.id = 'p-projects';
interProject.innerHTML = '<h3>Druhe projekty<\/h3><div class="'+PBody_ClassName+'"><ul>'+newlist.innerHTML+'</ul></div>';
var tb = document.getElementById('p-tb');
insertAfter(tb.parentNode,interProject,tb);
if (typeof remove_other_projects !== "undefined" && remove_other_projects) {
div.parentNode.removeChild(div);
}
}
$(aliajProjektoj);
// Wuslědki z Wikidaty
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' || ( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false ) ) {
mw.loader.load("//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript");
}
// </source>