Quelltext der Datei: http://www.michaelster.ch/jsTestFolder/wikipedia/Common.js

Dateigrösse: 16.22 kb

[Anzeige ohne Zeilennummern]


  1 /* generated javascript */
  2 var skin = 'monobook';
  3 var stylepath = '/skins-1.5';
  4 
  5 /* MediaWiki:Common.js */
  6 /* Jedes JavaScript hier wird fuer alle Benutzer fuer jede Seite geladen. */
  7 
  8 //=============================================================
  9 //*** Configuration for "star" logo in front of interwiki links to Featured Articles
 10 
 11 /** set to false in Special:Mypage/monobook.js to switch off this "feature" */
 12 var linkFA_enabled  = true;
 13 
 14 /** description that is displayed when cursor hovers above FA interwiki links */
 15 var linkFA_description = "Dieser Artikel wurde als exzellent bewertet.";
 16 
 17 // linkFA_bullet and linkFA_style werden nur für cologneblue, nostalgia and standard verwendet,
 18 // für monobook und simple siehe [[MediaWiki:Common.css]]
 19 
 20 /** image to use instead of the standard bullet (for cologneblue, nostalgia and standard */
 21 var linkFA_bullet = "http://upload.wikimedia.org/wikipedia/commons/d/d0/Monobook-bullet-star-transparent.png";
 22 
 23 /** style to use for the linkFA_bullet img */
 24 var linkFA_style = "margin-right: 0.2em;";
 25 
 26 /**
 27  * star logo for featured articles in other languages,
 28  * see Template:Link_FA and MediaWiki:Common.css
 29  */
 30 addOnloadHook(function() {
 31     // early exit when disabled
 32     if (!linkFA_enabled) return;
 33 
 34     // skins need to be treated differently
 35     if (skin == "monobook" || skin == "simple") {
 36         newer();
 37     }
 38     else if (skin == "cologneblue" || skin == "nostalgia" || skin == "standard") {
 39         older();
 40     }
 41 
 42     /** skin == "monobook" || skin == "simple" */
 43     function newer() {
 44         // links are to replaced in p-lang only
 45         var pLang = document.getElementById("p-lang");
 46         if (!pLang) return;
 47         var lis = pLang.getElementsByTagName("li");
 48         for (var i = 0; i < lis.length; i++) {
 49             var li = lis[i];
 50             // only links with a corresponding Link_FA template are interesting
 51             if (!document.getElementById(li.className + "-fa"))   continue;
 52             // additional class so the template can be hidden with CSS
 53             li.className += " FA";
 54             // change title
 55             li.title = linkFA_description;
 56         }
 57     }
 58 
 59     /** skin == "cologneblue" || skin == "nostalgia" || skin == "standard" */
 60     function older() {
 61         // these root elements can contain FA-links
 62         var rootIds = new Array("topbar", "footer");
 63         for (var i=0; i<rootIds.length; i++) {
 64             var rootId  = rootIds[i];
 65             var root    = document.getElementById(rootId);
 66             if (!root)  continue;
 67 
 68             // if the root exists, try to decorate all the links within
 69             var links   = root.getElementsByTagName("a");
 70             for (var j=0; j<links.length; j++) {
 71                 var link    = links[j];
 72                 decorate(link);
 73             }
 74         }
 75     }
 76 
 77     /** id necessary, modify a link to show the FA-star (older) */
 78     function decorate(link) {
 79         // exit if not a FA-link
 80         var lang    = link.title.split(":")[0]; // not precise enough
 81         var fa      = document.getElementById("interwiki-" + lang + "-fa");
 82         if (!fa)    return;
 83         // possible problem owing the standard skin: "Link FA" template is transcluded with a non-interwiki parameter, for example "Special"
 84         // result: links to special pages in the topbar and/or footer might also be marked as a Featured Article
 85 
 86         // build an image-node for the FA-star
 87         var img = document.createElement("img");
 88         img.setAttribute("src",     linkFA_bullet);
 89         img.setAttribute("alt",     linkFA_description);
 90         img.setAttribute("style",   linkFA_style);
 91 
 92         // decorate the link with the image
 93         link.appendChild(img);
 94         link.appendChild(link.removeChild(link.firstChild));
 95         link.setAttribute("title", linkFA_description);
 96     }
 97 });
 98 
 99 //==============================================================================
100 //*** Fuegt einen Link "Alle Sprachen" auf der Hauptseite unter die Sprachverweise hinzu
101 
102 addOnloadHook(function() {
103    // only on the main page
104    if ( wgTitle != 'Hauptseite' || wgNamespaceNumber != 4 )    return;
105 
106    try {
107        var node = document.getElementById( "p-lang" )
108                            .getElementsByTagName('div')[0]
109                            .getElementsByTagName('ul')[0];
110 
111        var aNode = document.createElement( 'a' );
112        var liNode = document.createElement( 'li' );
113 
114        aNode.appendChild( document.createTextNode( 'Alle Sprachen' ) );
115        aNode.setAttribute( 'href' , 'http://de.wikipedia.org/wiki/Wikipedia:Sprachen' );
116        liNode.appendChild( aNode );
117        liNode.className = 'interwiki-completelist';
118        node.appendChild( liNode );
119     } catch(e) {
120         // lets just ignore what's happened
121     }
122 });
123 
124 //==============================================================================
125 //*** Veraendert die Tabellensortierfunktion so, dass auch 
126 // deutsche Tausenderpunkt und Dezimalkommata gehen.
127 // Original aus sv.wikipedia.org
128 
129 function ts_parseFloat(num) {
130     if (!num) return 0;
131     num = num.replace(/\./g, "");
132     num = num.replace(/,/, ".");
133     num = parseFloat(num);
134     return (isNaN(num) ? 0 : num);
135 }
136 
137 //================================================================================
138 //*** force the loading of another JavaScript file (Kopie von [[Commons:Common.js]])
139 // Local Maintainer: [[Commons:User:Dschwen]]
140 
141 function includePage(name) {
142     document.write('<script type="text/javascript" src="' + wgScript + '?title='
143         + name + '&action=raw&ctype=text/javascript&dontcountme=s"><\/script>');    // smaxage=3600
144 }
145 
146 //==============================================================================
147 //*** Fuegt der Suche weitere Suchengines hinzu (kopiert aus eswp)
148 
149 //auskommentiert, funktioniert nicht auf Safari
150 //includePage("MediaWiki:SpezialSuche.js"); 
151 
152 //================================================================================
153 //*** import Onlyifuploading-functions
154 // SEE ALSO [[MediaWiki:Onlyifuploading.js]]
155 
156 if (wgCanonicalSpecialPageName == "Upload") {
157     includePage("MediaWiki:Onlyifuploading.js");
158 }
159 
160 //================================================================================
161 //*** Dynamic Navigation Bars
162 
163 // set up the words in your language
164 var NavigationBarHide = 'Einklappen';
165 var NavigationBarShow = 'Ausklappen';
166 
167 // set up max count of Navigation Bars on page,
168 // if there are more, all will be hidden
169 // NavigationBarShowDefault = 0; // all bars will be hidden
170 // NavigationBarShowDefault = 1; // on pages with more than 1 bar all bars will be hidden
171 if (typeof NavigationBarShowDefault == 'undefined' ) {
172     var NavigationBarShowDefault = 1;
173 }
174 
175 // adds show/hide-button to navigation bars
176 addOnloadHook(function() {
177     // shows and hides content and picture (if available) of navigation bars
178     // Parameters:
179     //     indexNavigationBar: the index of navigation bar to be toggled
180     function toggleNavigationBar(indexNavigationBar)
181     {
182        var NavToggle = document.getElementById("NavToggle" + indexNavigationBar);
183        var NavFrame = document.getElementById("NavFrame" + indexNavigationBar);
184 
185        if (!NavFrame || !NavToggle) {
186            return false;
187        }
188 
189        // if shown now
190        if (NavToggle.firstChild.data == NavigationBarHide) {
191            for (
192                    var NavChild = NavFrame.firstChild;
193                    NavChild != null;
194                    NavChild = NavChild.nextSibling
195                ) {
196                if (NavChild.className == 'NavPic') {
197                    NavChild.style.display = 'none';
198                }
199                if (NavChild.className == 'NavContent') {
200                    NavChild.style.display = 'none';
201                }
202                if (NavChild.className == 'NavToggle') {
203                    NavChild.firstChild.data = NavigationBarShow;
204                }
205            }
206 
207        // if hidden now
208        } else if (NavToggle.firstChild.data == NavigationBarShow) {
209            for (
210                    var NavChild = NavFrame.firstChild;
211                    NavChild != null;
212                    NavChild = NavChild.nextSibling
213                ) {
214                if (NavChild.className == 'NavPic') {
215                    NavChild.style.display = 'block';
216                }
217                if (NavChild.className == 'NavContent') {
218                    NavChild.style.display = 'block';
219                }
220                if (NavChild.className == 'NavToggle') {
221                    NavChild.firstChild.data = NavigationBarHide;
222                }
223            }
224        }
225     }
226 
227     function toggleNavigationBarFunction(indexNavigationBar) {
228         return function() {
229             toggleNavigationBar(indexNavigationBar);
230             return false;
231         };
232     }
233 
234    var indexNavigationBar = 0;
235    // iterate over all < div >-elements
236    var divs = document.getElementsByTagName("div");
237    for (var i=0;  i<divs.length; i++) {
238        var NavFrame = divs[i];
239        // if found a navigation bar
240        if (NavFrame.className == "NavFrame") {
241 
242            indexNavigationBar++;
243            var NavToggle = document.createElement("a");
244            NavToggle.className = 'NavToggle';
245            NavToggle.setAttribute('id', 'NavToggle' + indexNavigationBar);
246            NavToggle.setAttribute('href', '#');
247            NavToggle.onclick = toggleNavigationBarFunction(indexNavigationBar);
248 
249            var NavToggleText = document.createTextNode(NavigationBarHide);
250            NavToggle.appendChild(NavToggleText);
251 
252            // add NavToggle-Button as first div-element
253            // in < div class="NavFrame" >
254            NavFrame.insertBefore(
255                NavToggle,
256                NavFrame.firstChild
257            );
258            NavFrame.setAttribute('id', 'NavFrame' + indexNavigationBar);
259        }
260    }
261    // if more Navigation Bars found than Default: hide all
262    if (NavigationBarShowDefault < indexNavigationBar) {
263        for(
264                var i=1;
265                i<=indexNavigationBar;
266                i++
267        ) {
268            toggleNavigationBar(i);
269        }
270    }
271 });
272 
273 //================================================================================
274 //*** import Onlyifediting-functions
275 // SEE ALSO [[MediaWiki:Onlyifediting.js]]
276 
277 if (document.URL.indexOf("action=edit") > 0 || document.URL.indexOf("action=submit") > 0) {
278     includePage("MediaWiki:Onlyifediting.js");
279 }
280 
281 //================================================================================
282 
283 /*** Skript für Vorlage: Galerie ***/
284 addOnloadHook(function() {
285   if (document.URL.match(/printable/g)) return;
286  
287   function toggleImageFunction(group,  remindex, shwindex) {
288     return function() {
289       document.getElementById("ImageGroupsGr" + group + "Im" + remindex).style["display"] = "none";
290       document.getElementById("ImageGroupsGr" + group + "Im" + shwindex).style["display"] = "block";
291       return false;
292     };
293   }
294  
295   var divs = document.getElementsByTagName("div");
296   var i = 0, j = 0;
297   var units, search;
298   var currentimage;
299   var UnitNode;
300   for (i = 0; i < divs.length; i++) {
301     if (divs[i].className !== "ImageGroup") { continue; }
302     UnitNode = undefined;
303     search = divs[i].getElementsByTagName("div");
304     for (j = 0; j < search.length; j++) {
305       if (search[j].className !== "ImageGroupUnits") { continue; }
306       UnitNode=search[j];
307       break;
308     }
309     if (UnitNode === undefined) { continue; }
310     units = [];
311     for (j = 0 ; j < UnitNode.childNodes.length ; j++ ) {
312       var temp = UnitNode.childNodes[j];
313       if (temp.className === "center") { units.push(temp); }
314     }
315     var rightlink = undefined;
316     var commentText = undefined;
317     for (j = 0; j < units.length; j++) {
318       currentimage = units[j];
319       currentimage.id = "ImageGroupsGr" + i + "Im" + j;
320       var leftlink = document.createElement("a");
321       if (commentText !== undefined) {
322         leftlink.setAttribute("title", commentText);
323       }
324       var comment;
325       if (typeof(currentimage.getAttribute("title")) !== "string") {
326         commentText = (j+1) + "/" + units.length;
327         comment = document.createElement("tt").appendChild(document.createTextNode("("+ commentText + ")"));
328       } 
329       else {
330         commentText = currentimage.getAttribute("title");
331         comment = document.createElement("span").appendChild(document.createTextNode(commentText));
332         currentimage.removeAttribute("title");
333       }
334       if(rightlink !== undefined) {
335         rightlink.setAttribute("title", commentText);
336       }
337       var imghead = document.createElement("div");
338       rightlink = document.createElement("a");
339       if (j != 0) {
340         leftlink.href = "#";
341         leftlink.onclick = toggleImageFunction(i, j, j-1);
342         leftlink.appendChild(document.createTextNode("◀"));
343       }
344       if (j != units.length - 1) {
345         rightlink.onclick = toggleImageFunction(i, j, j+1);
346         rightlink.appendChild(document.createTextNode("▶"));
347       }
348       imghead.style["fontSize"] = "110%";
349       imghead.style["fontweight"] = "bold";
350       imghead.appendChild(leftlink);
351       imghead.appendChild(document.createTextNode("\xA0"));
352       imghead.appendChild(comment);
353       imghead.appendChild(document.createTextNode("\xA0"));
354       imghead.appendChild(rightlink);
355       if (units.length > 1) {
356         currentimage.insertBefore(imghead,currentimage.childNodes[0]);
357       }
358       if (j != 0) {
359         currentimage.style["display"] = "none";
360       }
361     }
362   }
363 });
364 
365 /* MediaWiki:Monobook.js */
366 /* Der Grossteil der Codes befindet sich in [[MediaWiki:Common.js]] */
367 
368 //================================================================================
369 //*** moveEditsection: Moving of the editsection links
370 
371 /*
372  * moveEditsection
373  * Dieses Script verschiebt die [Bearbeiten]-Buttons vom rechten Fensterrand
374  * direkt rechts neben die jeweiligen Ueberschriften.
375  * This script moves the [edit]-buttons from the right border of the window
376  * directly right next to the corresponding headings.
377  *
378  * Zum Abschalten die folgende Zeile (ohne Sternchen) in die eigene monobook.js 
379  * (zu finden unter [[Special:Mypage/monobook.js|Benutzer:Name/monobook.js]]) kopieren:
380  * var oldEditsectionLinks = true;
381  *
382  * dbenzhuser (de:Benutzer:Dbenzhuser)
383  */
384 addOnloadHook(function() {
385     if (typeof oldEditsectionLinks != 'undefined' && oldEditsectionLinks)   return;
386     var spans = document.getElementsByTagName("span");
387     for (var i=0; i<spans.length; i++) {
388         var span = spans[i];
389         if (span.className != "editsection")    continue;
390         span.style.fontSize = "x-small";
391         span.style.fontWeight = "normal";
392         span.style.cssFloat = "none";
393         span.style.marginLeft = "0px";
394         span.parentNode.appendChild(document.createTextNode(" "));
395         span.parentNode.appendChild(span);
396     }
397 });
398 
399 //================================================================================
400 //*** Add button 'Inverse selection' on [[Special:Undelete]]
401 
402 /** Fügt das Bookmarklet zum Markieren aller Versionen auf Special:Undelete ein */
403 addOnloadHook(function() {
404    var form        = document.forms["undelete"];
405    if (!form)  return;
406    var elements    = form.elements;
407    var resetBtn   = elements["mw-undelete-reset"];
408    if (!resetBtn) return;
409    var toggleBtn   = document.createElement("input");
410    toggleBtn.type  = "button";
411    toggleBtn.value ="Auswahl umkehren";
412    toggleBtn.onclick   = function() {
413        for (var i=0; i<elements.length; i++) {
414            var input   = elements[i];
415            if (input.type != "checkbox")   continue;
416            input.checked   = !input.checked;
417        }
418    }
419    resetBtn.parentNode.insertBefore(toggleBtn, resetBtn);
420 });
421 
422 addOnloadHook(function() {
423     if (wgAction !== "delete") return;
424      
425     var wpReason = document.getElementById("wpReason");
426     if (!wpReason) return;
427 
428     // für Skripte und Links, die automatisch eine Löschbegründung eintragen
429     if (location.href.search(/wpReason\=/) !== -1) return;
430 
431     var regexp = /(\{\{(?:SLA|löschen|delete)[^\}]*\}\}(.*(?:CES?T\)|REDIRECT[^\]]*\]\]))?)/i;
432     var match  = regexp.exec(wpReason.value);
433     wpReason.value = match ? match[1] : "";   
434 });