לדלג לתוכן

מדיה ויקי:Gadget-rollBackSummary.js: הבדלים בין גרסאות בדף

מתוך צפונות ויקי
מאין תקציר עריכה
מאין תקציר עריכה
שורה 1: שורה 1:
/** Collapsible tables *********************************************************
/*
* Prompt for an edit summary when clicking a rollback link
* Written by [[:he:User:Yonidebest]] based on [[:en:User:Ilmari Karonen]]'s script.
* Translated to Hebrew by [[User:ברק שושני]]
  *
  *
  * Description: Allows tables to be collapsed, showing only the header. See
  */
  *              [[Wikipedia:NavFrame]].
   
*  Maintainers: [[User:R. Koot]]
function rollBackSummary() {
*/
var bodyContent = document.getElementById('bodyContent');
 
if (!bodyContent) return;
var autoCollapse = 2;
var links = bodyContent.getElementsByTagName('A');
var collapseCaption = ( wgUserLanguage == "he" ) ? "הסתרה": "Hide";
if (!links) return;
var expandCaption = ( wgUserLanguage == "he" ) ? "הצגה" : "Show";
var promptSummary = function () {
 
  var summary = prompt("נא להכניס את סיבת השחזור, או להשאיר כ-\"ברירת מחדל\" לשימוש בתקציר העריכה הרגיל", "ברירת מחדל");
function collapseTable( tableIndex )
  if (summary == null || summary == "") return false;
{
  if (summary == "ברירת מחדל") return true;
    var Button = document.getElementById( "collapseButton" + tableIndex );
  this.href = this.href.replace("?", "?summary=" + encodeURIComponent(summary) + "&");
    var Table = document.getElementById( "collapsibleTable" + tableIndex );
  return true;
    var allRows = Table.getElementsByTagName( "tr" );  
};
 
for (var i = 0; i < links.length; i++) {
    if ( !Table || !Button || allRows.length == 0 ) {
  if links[i].href.indexOf('action=rollback') != -1) {
        return;
  var newlink = document.createElement('A');
    }
  newlink.href = links[i].href;
 
  newlink.title = "שחזור מהיר עם תקציר";
    var Rows = allRows[0].parentNode.childNodes;
  newlink.onclick = promptSummary;
 
  newlink.appendChild(document.createTextNode('תקציר'));
    if ( Button.firstChild.data == collapseCaption ) {
  links[i].parentNode.insertBefore(document.createTextNode(' ['), links[i].nextSibling);
        for ( var i = 1; i < Rows.length; i++ ) {
  links[i].parentNode.insertBefore(newlink, links[i].nextSibling);
            if ( Rows[i].nodeType == 1 ) {
  links[i].parentNode.insertBefore(document.createTextNode(' ]'), links[i].nextSibling);
                Rows[i].style.display = "none";
  }
            }
}
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( var i = 1; i < Rows.length; i++ ) {
            if ( Rows[i].nodeType == 1 ) {
                Rows[i].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 ( Tables[i].className.indexOf("collapsible") != -1 ) {
            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.style.styleFloat = "left";
            Button.style.cssFloat = "left";
            Button.style.fontWeight = "normal";
            Button.style.textAlign = "left";
            Button.style.width = "6em";
 
            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( "]" ) );
 
            var Header;
            if (Tables[i].className.indexOf("otherrow") != -1)
                Header = getElementsByClassName(Tables[i], "TD", "headerrow")[0];
            else
                Header = Tables[i].getElementsByTagName( "tr" )[0].getElementsByTagName( "th" )[0];
            /* only add button and increment count if there is a header row to work with */
            if (Header) {
                Header.insertBefore( Button, Header.childNodes[0] );
                tableIndex++;
            }
        }
    }
 
    for ( var i = 0;  i < tableIndex; i++ ) {
        if ( NavigationBoxes[i].className.indexOf("collapsed") != -1 || ( tableIndex >= autoCollapse && NavigationBoxes[i].className.indexOf("autocollapse") != -1 ) ) {
            collapseTable( i );
        }
    }
}
}


addOnloadHook(createCollapseButtons);
addOnloadHook(rollBackSummary);

גרסה מ־21:13, 15 בפברואר 2009

/*
 * Prompt for an edit summary when clicking a rollback link
 * Written by [[:he:User:Yonidebest]] based on [[:en:User:Ilmari Karonen]]'s script.
 * Translated to Hebrew by [[User:ברק שושני]]
 *
 */ 
 
function rollBackSummary() {
 var bodyContent = document.getElementById('bodyContent');
 if (!bodyContent) return;
 var links = bodyContent.getElementsByTagName('A');
 if (!links) return;
 var promptSummary = function () {
  var summary = prompt("נא להכניס את סיבת השחזור, או להשאיר כ-\"ברירת מחדל\" לשימוש בתקציר העריכה הרגיל", "ברירת מחדל");
  if (summary == null || summary == "") return false;
  if (summary == "ברירת מחדל") return true;
  this.href = this.href.replace("?", "?summary=" + encodeURIComponent(summary) + "&");
  return true;
 };
 for (var i = 0; i < links.length; i++) {
  if links[i].href.indexOf('action=rollback') != -1) {
   var newlink = document.createElement('A');
   newlink.href = links[i].href;
   newlink.title = "שחזור מהיר עם תקציר";
   newlink.onclick = promptSummary;
   newlink.appendChild(document.createTextNode('תקציר'));
   links[i].parentNode.insertBefore(document.createTextNode(' ['), links[i].nextSibling);
   links[i].parentNode.insertBefore(newlink, links[i].nextSibling);
   links[i].parentNode.insertBefore(document.createTextNode(' ]'), links[i].nextSibling);
  }
 }
}

addOnloadHook(rollBackSummary);