Vikipediisto:Tlustulimu/monobook.js

El Komunejo

< Vikipediisto:Tlustulimu(Malsamoj inter versioj)
Iri al: navigado, serĉi
E (korekto)
E (17 versioj: Uzantosubpaĝoj)
 
(4 mezaj versioj ne montrata.)
Linio 1: Linio 1:
 +
/** Trovita ĉe Arno Lagrange
 +
* 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 getElementsByClassName(node, tag, searchClass);
 +
}
 +
 +
 +
// Ĝuste akiras la tekstan entenaon de nodo kaj de ties idaj nodoj
 +
// 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;
 +
}
 +
 +
 +
/* Füge Projektportal-Link hinzu */
/* Füge Projektportal-Link hinzu */
function addPortal()
function addPortal()
Linio 148: Linio 197:
// onload
// onload
addOnloadHook(moveEditsection);
addOnloadHook(moveEditsection);
-
 
-
// END Moving of the editsection links
 
-
// ============================================================
 
-
 
+
/** Trovita ĉe Arno Lagrange
-
// El la suprasoraba vikipedio
+
* El franclingva Vikipedio :
-
 
+
* Laŭ decido de [[:fr:Wikipédia:Prise de décision/Lien interprojet]]
-
// ============================================================
+
* Kopias la interprojektajn ligilojn el la ŝablono {{Projekto}}
-
// BEGIN hasclass
+
* en la maldekstran strion
-
//hasClass, from en.wp and ru.wp
+
* remove_other_projects = true; en persona monobook.css por krome ne plu aperigi
-
var hasClass = (function (){
+
* la ŝablonon en la paĝo
-
var reCache = {}
+
* no_other_projects = true; en persona monobook.css por malebligi ke tiu skripto funkciu
-
return function (element, className){
+
*/
-
return (reCache[className] ? reCache[className] : (reCache[className] = new RegExp("(?:\\s|^)" + className + "(?:\\s|$)"))).test(element.className)
+
-
}
+
-
})()
+
   
   
-
+
function aliajProjektoj() {
-
function addLoadEvent(f) {addOnloadHook(f)} //for backwards compatibility
+
if ((typeof no_other_projects != "undefined") && (no_other_projects)) return;
-
// END hasclass
+
if(!(wgNamespaceNumber==0)) return;
-
// ============================================================
+
if(!(wgAction=="view")) return;
-
 
+
var div = document.getElementById('aliaj_projektoj');
-
 
+
if(!div) return;
-
// ============================================================
+
var list = div.getElementsByTagName('LI');
-
// BEGIN Enable multiple onload functions
+
var newlist = document.createElement("UL");
-
+
for (var i = 0; i < list.length ; i++) {
-
// setup onload functions this way:
+
list.link = list[i].getElementsByTagName('A')[0];
-
// aOnloadFunctions[aOnloadFunctions.length] = function_name; // without brackets!
+
list.text = list.link.getElementsByTagName('SPAN')[0];
-
+
var newlistitem = document.createElement("LI");
-
if (!window.aOnloadFunctions) {
+
var newlink = document.createElement("A");
-
var aOnloadFunctions = new Array();
+
var newlinktext = document.createTextNode(getTextContent(list.text));
-
}
+
newlink.appendChild(newlinktext);
-
+
newlink.title=getTextContent(list.link);
-
window.onload = function() {
+
newlink.href=list.link.href;
-
if (window.aOnloadFunctions) {
+
newlistitem.appendChild(newlink);
-
for (var _i=0; _i<aOnloadFunctions.length; _i++) {
+
newlist.appendChild(newlistitem);
-
aOnloadFunctions[_i]();
+
}
}
 +
var interProject = document.createElement("DIV");
 +
interProject.className = 'portlet';
 +
interProject.innerHTML = '<h5>Aliaj projektoj<\/h5><div class="pBody"><ul>'+newlist.innerHTML+'</ul></div>';
 +
insertAfter(document.getElementById('column-one'),interProject,document.getElementById('p-tb'));
 +
if ((typeof remove_other_projects != "undefined") && (remove_other_projects)) {
 +
document=document.getElementById('bodyContent').removeChild(div);
}
}
}
}
   
   
-
// END Enable multiple onload functions
+
addOnloadHook(aliajProjektoj);
-
// ============================================================
+
-
var autoCollapse = 2
+
/* Jen peco laŭ propono de Arno Lagrange*/
-
var collapseCaption = 'Kaŝi'
+
document.write('<script type="text/javascript" src="'  
-
var expandCaption = 'Montri'
+
+ 'http://eo.wikipedia.org/w/index.php?title=Vikipediisto:ArnoLagrange/cache.js'  
 +
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
   
   
-
function collapsibleTables(){
+
// END Moving of the editsection links
-
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
+
-
 
+
-
/* ĉi tien estas metenda la funkcioj por div-bazitaj navigiloj */
+
-
 
+
-
addOnloadHook(collapsibleTables);
+

Nuna versio ekde 21:09, 7. Dec 2009

/** Trovita ĉe Arno Lagrange
* 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 getElementsByClassName(node, tag, searchClass);
}
 
 
// Ĝuste akiras la tekstan entenaon de nodo kaj de ties idaj nodoj
// 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;
}
 
 
 
/* Füge Projektportal-Link hinzu */
function addPortal()
{
  quickbar = document.getElementById('quickbar');
  if (quickbar)
  {
    neues = document.createElement('a')
    neues.href = '/wiki/Wikipedia:Portal'
    neues.appendChild(document.createTextNode('Projektportal'))
    quickbar.appendChild(neues)
  }
}
 
addOnloadHook(addPortal);
 
/* Einige link-Tags hinzufügen */
head = document.getElementsByTagName('head')[0]
 
function verlinke(rel, href, title)
{
  link = document.createElement('link')
  link.rel = rel
  link.href = '/wiki/' + href
  link.title = title
  head.appendChild(link)
}
 
if (head) /* sollte immer true ergeben, aber sicher ist sicher */
{
  verlinke('start', 'Hauptseite', 'Hauptseite')
  verlinke('help', 'Wikipedia:Handbuch', 'Handbuch')
  verlinke('index', 'Spezial:Allpages', 'Index')
}
 
/* decodiere UTF8 (aus Selfhtml) */
function decode_utf8(utftext) {
     var plaintext = ""; var i=0; var c=c1=c2=0;
     // while-Schleife, weil einige Zeichen uebersprungen werden
     while(i<utftext.length)
         {
         c = utftext.charCodeAt(i);
         if (c<128) {
             plaintext += String.fromCharCode(c);
             i++;}
         else if((c>191) && (c<224)) {
             c2 = utftext.charCodeAt(i+1);
             plaintext += String.fromCharCode(((c&31)<<6) | (c2&63));
             i+=2;}
         else {
             c2 = utftext.charCodeAt(i+1); c3 = utftext.charCodeAt(i+2);
             plaintext += String.fromCharCode(((c&15)<<12) | ((c2&63)<<6) | (c3&63));
             i+=3;}
         }
     return plaintext;
}
 
/* decodiere die codierten UTF8-Zeichen in Kapitel-Ankern */
function decodeanchor(anchorname)
{
  var escaped = anchorname.replace(/\.([0-9A-F][0-9A-F])/g,"%$1");
  return decode_utf8(unescape(escaped)).replace(/_/g,' ');
}
 
/* Füge Link-Tags fürs Inhaltsverzeichnis hinzu */
function addcontents()
{
  var head = document.getElementsByTagName('head')[0];
  var len = document.anchors.length
  for (i = 0; i <  len; ++i)
  {
    anchor = document.anchors[i];
    link = document.createElement('link')
    link.rel = 'chapter'
    link.href = '#' + anchor.name;
    link.title = decodeanchor(anchor.name);
    head.appendChild(link)
  }
}
 
addOnloadHook(addcontents);
 
// por la verdaj butonetoj laŭ hsbwp, plwp kaj ruwp resp. propra vikio
document.write('<script type="text/javascript" src="' 
     + 'http://eo.wikipedia.org/w/index.php?title=Vikipediisto:Tlustulimu/butonetoj.js' 
     + '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
 
// el mia suprasoraba vikipediista paĝo
// z wužiwarja Zacke w němskej wikipediji
// vom Benutzer:Zacke in dewp
function addlilink(tabs, url, name, id) {
    var na = document.createElement('a');
    na.href = url;
    na.id = id;
    na.appendChild(document.createTextNode(name));
    var li = document.createElement('li');
    li.appendChild(na);
    tabs.appendChild(li);
    return li;
}
function addtoolboxlinks() {
var tb = document.getElementById('p-navigation').getElementsByTagName('ul')[0];
addlilink(tb, '/wiki/Vikipedio:Vikiprojekto Ŝablono', 'Projekto pri ŝablonoj', '');
addlilink(tb, '/wiki/Vikipedio:Informkestoj', 'Projekto pri informkestoj', '');
addlilink(tb, '/wiki/Vikipedio:Ŝablono', 'Listoj de ŝablonoj', '');
addlilink(tb, '/wiki/Vikipedio:Forigendaj artikoloj', 'Forigo', '');
addlilink(tb, '/wiki/Speciala:Prefixindex', 'Paĝoj', '');
addlilink(tb, '/wiki/Vikipediisto:Tlustulimu/Navigejo', 'Navigejo', '');
addlilink(tb, '/wiki/Vikipediisto:Tlustulimu/Navigejo2', 'Navigejo diskuta', '');
addlilink(tb, '/wiki/Vikipediisto:Tlustulimu/Babel', 'Babel', '');
}
if (window.addEventListener) window.addEventListener("load", addtoolboxlinks, false);
else if (window.attachEvent) window.attachEvent("onload", addtoolboxlinks);
 
 
// el la suprasoraba vikipedio [[:hsb:MediaWiki:Common.js]]
// ============================================================
// BEGIN Moving of the editsection links
 
/*
* moveEditsection
* Dieses Script verschiebt die [Bearbeiten]-Buttons vom rechten Fensterrand
* direkt rechts neben die jeweiligen Überschriften.
* This script moves the [edit]-buttons from the right border of the window
* directly right next to the corresponding headings.
*
* Zum Abschalten die folgende Zeile (ohne führendes Sternchen) in die eigene
* monobook.js (zu finden unter [[Special:Mypage/monobook.js|Benutzer:Name/monobook.js]]) kopieren:
* var oldEditsectionLinks = true;
*
* dbenzhuser (de:Benutzer:Dbenzhuser)
*/
function moveEditsection() {
     if (typeof oldEditsectionLinks == 'undefined' || oldEditsectionLinks == false) {
         var spans = document.getElementsByTagName("span");
         for(var i = 0; i < spans.length; i++) {
             if(spans[i].className == "editsection") {
                 spans[i].style.fontSize = "x-small";
                 spans[i].style.fontWeight = "normal";
                 spans[i].style.cssFloat = "none";
                 spans[i].style.marginLeft = "0px";
                 spans[i].parentNode.appendChild(document.createTextNode(" "));
                 spans[i].parentNode.appendChild(spans[i]);
             }
         }
     }
}
// onload
addOnloadHook(moveEditsection);
 
/** 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.css por krome ne plu aperigi 
* la ŝablonon en la paĝo 
* no_other_projects = true; en persona monobook.css por malebligi ke tiu skripto funkciu
*/
 
function aliajProjektoj() {
if ((typeof no_other_projects != "undefined") && (no_other_projects)) return;
if(!(wgNamespaceNumber==0)) return;
if(!(wgAction=="view")) return;
var div = document.getElementById('aliaj_projektoj');
if(!div) 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';
interProject.innerHTML = '<h5>Aliaj projektoj<\/h5><div class="pBody"><ul>'+newlist.innerHTML+'</ul></div>';
insertAfter(document.getElementById('column-one'),interProject,document.getElementById('p-tb'));
if ((typeof remove_other_projects != "undefined") && (remove_other_projects)) {
document=document.getElementById('bodyContent').removeChild(div);
}
}
 
addOnloadHook(aliajProjektoj);
 
/* Jen peco laŭ propono de Arno Lagrange*/
document.write('<script type="text/javascript" src="' 
+ 'http://eo.wikipedia.org/w/index.php?title=Vikipediisto:ArnoLagrange/cache.js' 
+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
 
// END Moving of the editsection links
// ============================================================
Personaj iloj