Diferència entre les revisions de "MediaWiki:Common.js"

De L'Enciclopèdia, la wikipedia en valencià
Anar a la navegació Anar a la busca
 
 
(No es mostren 4 edicions intermiges d'2 usuaris)
Llínea 1: Llínea 1:
/* Se carregarà per a tots els usuaris, i per a qualsevol pàgina, el codi JavaScript que hi haja després d'esta llínia. */
+
/* Se carregarà per a tots els usuaris, i per a qualsevol pàgina, el còdic JavaScript que hi haja després d'esta llínia. */
//<pre><nowiki>
+
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
/* Any JavaScript here will be loaded for all users on every page load. */
//    |—————————————————————————————————————————————————————————————————————————————————————————————————————————|    //
+
 
//    |-| I feel I am *relatively* good at JavaScript programming, so feel free to ask me questions about any |-|    //
+
function LinkFA()
//    |-| scripts on this page. I've gotten the majority of my scripts from [[WP:US/S]]; if you want code,    |-|    //
+
{
//    |-| then go there. Please note that all of these scripts are tested in and developed for Mozilla      |-|    //
+
    if ( document.getElementById( "p-lang" ) ) {
//    |-| Firefox ONLY!                                                                                      |-|    //
+
        var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
//    |—————————————————————————————————————————————————————————————————————————————————————————————————————————|    //
 
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 
   
 
   
importScript('User:Gracenotes/amelvand.js');
+
        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
importScript('User:Animum/editsection.js');
+
            if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
importScript('User:Animum/reset.js');
+
                InterwikiLinks[i].className += " FA"
importScript('User:Animum/ais523editcount.js');
+
                InterwikiLinks[i].title = "Ca artiklo havas traktita stando.";
importScript('User:Tra/sidebartranslate.js');
+
             }
importScript('User:Thedjatclubrock/avt.js');
+
         }
importScript('User:Animum/liveclock.js');
+
    }
importScript('User:AzaToth/morebits.js');
+
}
importScript('User:AzaToth/twinklefluff.js');
 
importScript('User:AzaToth/twinklewarn.js');
 
importScript('User:AzaToth/twinklexfd.js');
 
if(wgNamespaceNumber == 14) importScript('User:AzaToth/twinklebatchdelete.js');
 
importScript('User:Animum/twinkledelimages.js');
 
importScript('User:Animum/twinklespeedy.js');
 
TwinkleConfig = {
 
        deletionSummaryAd              :      "",
 
        protectionSummaryAd             :      "",
 
         summaryAd                      :      "",
 
        showSharedIPNotice              :      false,
 
        orphanBacklinksOnSpeedyDelete  :      false,
 
};
 
 
   
 
   
importScript('User:Lupin/popups.js');
+
$(document).ready( LinkFA );
//[[User:Lupin/popups.js]]
 
popupHideDelay=0.1;
 
popupDelay=1;
 
popupAdminLinks=true;
 
popupsFixDabs=true;
 
 
   
 
   
importScript('Wikipedia:WikiProject User scripts/Scripts/MotD closure script');
+
/**
importScript('Wikipedia:WikiProject User scripts/Scripts/Add LI menu');  
+
* Collapsible tables *********************************************************
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');
+
*
importScript('User:Animum/count.js');
+
* Description: Allows tables to be collapsed, showing only the header. See
importScript('Wikipedia:WikiProject User scripts/Scripts/Fix lowercase first letter problem');
+
*              [[Wikipedia:NavFrame]].
+
* Maintainers: [[User:R. Koot]]
addOnloadHook(function() {
+
*/
if(wgAction=="edit") {
+
 
  document.forms["editform"].wpWatchthis.checked = false;
+
var autoCollapse = 2;
 +
var collapseCaption = 'hide';
 +
var expandCaption = 'show';
 +
 
 +
window.collapseTable = function ( tableIndex ) {
 +
    var Button = document.getElementById( 'collapseButton' + tableIndex );
 +
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );
 +
 
 +
    if ( !Table || !Button ) {
 +
        return false;
 +
    }
 +
 
 +
    var Rows = Table.rows;
 +
    var i;
 +
 
 +
    if ( Button.firstChild.data === collapseCaption ) {
 +
        for ( i = 1; i < Rows.length; i++ ) {
 +
            Rows[i].style.display = 'none';
 +
        }
 +
        Button.firstChild.data = expandCaption;
 +
    } else {
 +
        for ( 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 = {};
 +
    var Tables = document.getElementsByTagName( 'table' );
 +
    var i;
 +
 
 +
    function handleButtonLink( index, e ) {
 +
        window.collapseTable( index );
 +
        e.preventDefault();
 +
    }
 +
 
 +
    for ( i = 0; i < Tables.length; i++ ) {
 +
        if ( $( Tables[i] ).hasClass( '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', '#' );
 +
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
 +
            ButtonLink.appendChild( ButtonText );
 +
 
 +
            Button.appendChild( document.createTextNode( '[' ) );
 +
            Button.appendChild( ButtonLink );
 +
            Button.appendChild( document.createTextNode( ']' ) );
 +
 
 +
            Header.insertBefore( Button, Header.firstChild );
 +
            tableIndex++;
 +
        }
 +
    }
 +
 
 +
    for ( i = 0;  i < tableIndex; i++ ) {
 +
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
 +
            window.collapseTable( i );
 +
        }
 +
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
 +
            var element = NavigationBoxes[i];
 +
            while ((element = element.parentNode)) {
 +
                if ( $( element ).hasClass( 'outercollapse' ) ) {
 +
                    window.collapseTable ( i );
 +
                    break;
 +
                }
 +
            }
 +
        }
 +
    }
 
}
 
}
});
+
 
 +
$(document).ready( createCollapseButtons );
 
   
 
   
//this helps automate AfD closing by adding a 'close' tab to AfD debates
+
/**
//written by [[User:Johnleemk]] based on [[Wikipedia:WikiProject User scripts/Scripts/test-n.js]] by [[User:Celestianpower]]
+
* Dynamic Navigation Bars (experimental)
   
+
*
function autoafd_result()
+
* Description: See [[Wikipedia:NavFrame]].
{
+
* Maintainers: UNMAINTAINED
  var close = prompt("Result of debate?")
+
*/
  var f = document.editform, t = f.wpTextbox1;
+
 
  t.value = t.value.split('{{REMOVE THIS TEMPLATE WHEN CLOSING THIS AfD').join('{{ns:0');
+
/* set up the words in your language */
  t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "\~\~\~\~" + '\n' + '\n' + t.value;
+
var NavigationBarHide = '[' + collapseCaption + ']';
  if (t.value.length > 0)
+
var NavigationBarShow = '[' + expandCaption + ']';
    t.value += '\n';
+
 
  t.value += "{{subst:" + "ab" + "}}";
+
/**
  f.wpSummary.value = "Closing debate; result was " + close;
+
* Shows and hides content and picture (if available) of navigation bars
}
+
* Parameters:
+
*    indexNavigationBar: the index of navigation bar to be toggled
function autoafd_relist()
+
  **/
{
+
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
  var f = document.editform, t = f.wpTextbox1;
+
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
  if (t.value.length > 0)
+
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
    t.value += '\n';
+
    var NavChild;
  t.value += "{{subst:" + "relist" + "|" + "\~\~\~\~\}\}";
+
 
  f.wpSummary.value = "Relisting debate";
+
    if ( !NavFrame || !NavToggle ) {
}
+
        return false;
+
    }
function autoafd_add_afd_tabs()
+
 
{
+
    /* if shown now */
  // Only add for pages with the right string somewhere in the title
+
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
+
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
    {
+
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
      addPortletLink('p-cactions', 'javascript:autoafd_result()', "close");
+
                NavChild.style.display = 'none';
      addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist");
+
            }
 +
        }
 +
    NavToggle.firstChild.data = NavigationBarShow;
 +
 
 +
    /* if hidden now */
 +
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
 +
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 +
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
 +
                NavChild.style.display = 'block';
 +
            }
 +
        }
 +
        NavToggle.firstChild.data = NavigationBarHide;
 +
    }
 +
 
 +
    event.preventDefault();
 +
};
 +
 
 +
/* adds show/hide-button to navigation bars */
 +
function createNavigationBarToggleButton() {
 +
    var indexNavigationBar = 0;
 +
    var NavFrame;
 +
    var NavChild;
 +
    /* iterate over all < div >-elements */
 +
    var divs = document.getElementsByTagName( 'div' );
 +
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
 +
        /* if found a navigation bar */
 +
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {
 +
 
 +
            indexNavigationBar++;
 +
            var NavToggle = document.createElement( 'a' );
 +
            NavToggle.className = 'NavToggle';
 +
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
 +
            NavToggle.setAttribute( 'href', '#' );
 +
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );
 +
 
 +
            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
 +
            /**
 +
            * Check if any children are already hidden. This loop is here for backwards compatibility:
 +
            * the old way of making NavFrames start out collapsed was to manually add style="display:none"
 +
            * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
 +
            * the content visible without JavaScript support), the new recommended way is to add the class
 +
            * "collapsed" to the NavFrame itself, just like with collapsible tables.
 +
            */
 +
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
 +
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 +
                    if ( NavChild.style.display === 'none' ) {
 +
                        isCollapsed = true;
 +
                    }
 +
                }
 +
            }
 +
            if ( isCollapsed ) {
 +
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
 +
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
 +
                        NavChild.style.display = 'none';
 +
                    }
 +
                }
 +
            }
 +
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
 +
            NavToggle.appendChild( NavToggleText );
 +
 
 +
            /* 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 ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
 +
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
 +
                    NavFrame.childNodes[j].appendChild( NavToggle );
 +
                }
 +
            }
 +
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
 +
        }
 
     }
 
     }
 
}
 
}
+
 
addOnloadHook(autoafd_add_afd_tabs);
+
$(document).ready( createNavigationBarToggleButton );
 
//end AfD closing script
 
 
function addLink(where, url, name, id, title, key, after) {
 
    // addLink() accepts either an id or a DOM node, addPortletLink() only takes a node
 
    if (after && !after.cloneNode)
 
        after = document.getElementById(after);
 
 
    return addPortletLink(where, url, name, id, title, key, after);
 
}
 
 
//Interiot's javascript edit counter
 
if (document.title.indexOf('User:Interiot/Tool2/code.js') != -1) {
 
  document.write('<script type="text/javascript" src="'
 
    + 'http://en.wikipedia.org/w/index.php?title=User:Interiot/Tool2/code.js'
 
    + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }
 
 
importScript('User:Animum/headers.js');
 
importScript('Wikipedia:WikiProject User scripts/Scripts/warn.js');
 
importScript('Wikipedia:WikiProject User scripts/Scripts/Add toolbox link');
 
importScript('Wikipedia:WikiProject User scripts/Scripts/Add tab');
 
 
 
//
 
 
// STATUS CHANGER
 
addOnloadHook(function (){
 
  var subpage = "/Status";
 
  var scheme = "/StatusTemplate";
 
  var subpagelink = wgServer + "/wiki/User:" + wgUserName + subpage;
 
  var logout = document.getElementById( 'pt-logout' );
 
  //Add the links
 
  addPortletLink("p-personal", subpagelink + "?action=edit&newstatus=in", "in", "pt-status-in", "I'm in!", "", logout);
 
  addPortletLink("p-personal", subpagelink + "?action=edit&newstatus=busy", "busy", "pt-status-busy", "I'm busy!", "", logout);
 
  addPortletLink("p-personal", subpagelink + "?action=edit&newstatus=out", "out", "pt-status-out", "I'm out!", "", logout);
 
  if (location.href.indexOf("?action=edit&newstatus=") == -1) return; //Are we here to auto-edit the status?
 
  //Get new status
 
  var statusRegExp = /\?action=edit&newstatus=(.*)/;
 
  var status = statusRegExp.exec(location.href)[1];
 
  //Modify the form
 
  document.getElementById('wpTextbox1').value = "{{User:"+wgUserName+scheme+"|"+status+"}}";
 
  document.getElementById('wpSummary').value = "Status: "+status;
 
  document.getElementById('wpMinoredit').checked = 'checked';
 
  //Submit it!
 
  document.getElementById('editform').submit();
 
});
 
 
//
 
 
function MainPageReadonly() {
 
    if( wgTitle == "Main Page" && wgAction=="edit" && document.getElementById("newarticletext") ) {
 
      if( userIsInGroup( 'sysop' ) ) {
 
        var noeditform = document.getElementById("editform");
 
        noeditform.style.display="none";
 
        var protwarning = document.getElementById("protectedpagewarning");
 
        protwarning.style.display="none"; }
 
      var replaceContent = document.getElementById("bodyContent");
 
      replaceContent.innerHTML="<br/><br/><center style='color:red;font-size:300%;font-weight:bold;line-height:3em'>" + "ERROR: The main page is currently unavailable. However, you are welcome to edit any other article we have." + "</center>";
 
        if( userIsInGroup( 'sysop' ) ) { replaceContent.innerHTML += "<center style='color:red;font-size:200%;font-weight:bold;line-height:3em'>" + wgUserName + ", <a href='http://en.wikipedia.org/wiki/Special:Undelete/Main_Page'>undelete this page</a>."; }
 
      }
 
}
 
addOnloadHook(MainPageReadonly);
 
 
function makeDocLink() {
 
  if( wgCanonicalNamespace == "Template" && document.getElementById("doc_editlinks") ) {
 
    var editsection = document.getElementById("doc_editlinks");
 
    editsection.innerHTML = '[<a href="' + wgServer + '/wiki/' + wgPageName + '/doc">view</a>]' + "&nbsp;" + '[<a href="'+ wgServer + wgScript + '?title=' + wgPageName + '/doc&action=edit" title="Edit the template documentation for this page">edit</a>]';
 
  }
 
}
 
 
addOnloadHook(makeDocLink);
 
 
function addPurgeLinkToToolbox() {
 
    addToolboxLink('http://en.wikipedia.org/w/index.php?title=' + wgPageName + '&action=purge', "Purge this page", '', '', '', "Purge the cache for this page.");
 
}
 
 
addOnloadHook(addPurgeLinkToToolbox);
 
 
function tagArticle() {
 
    var template = prompt("What tag to place?");
 
    document.editform.wpTextbox1.value = "\{\{" + template + "\}\}\n" + document.editform.wpTextbox1.value;
 
    document.editform.wpSummary.value = "\+\{\{" + template.toLowerCase() + "\}\}";
 
    document.editform.wpMinoredit.checked = true;
 
    document.editform.wpSave.click();
 
}
 
 
function addTagLink() {
 
  if( (wgNamespaceNumber != -1) && wgAction == "edit") {
 
    addToolboxLink('javascript:tagArticle()', "Tag page", '', '', '', "Tag this page with a template"); }
 
}
 
 
addOnloadHook(addTagLink);
 
 
function addSubpageLink() {
 
  var subpagename = wgPageName.split( '/' )[1];
 
    if( wgNamespaceNumber != 0 && !subpagename ) {
 
      addToolboxLink(wgServer + wgScript + "?title=Special:Prefixindex/" + wgPageName + "/", "Subpages", '', '', '', 'View the <a href="http://en.wikipedia.org/wiki/Wikipedia:Subpages">subpages</a> of this page'); }
 
}
 
 
addOnloadHook(addSubpageLink);
 
 
function addRightsLink() {
 
    var subpagename = wgPageName.split( '/' )[1];
 
    if( ( wgNamespaceNumber == "3" || wgNamespaceNumber == "2" ) && !subpagename ) {
 
      addToolboxLink("http://en.wikipedia.org/w/index.php?title=Special%3AListusers&username=" + wgTitle + "&group=&limit=1", "User\'s rights", '', '', "View the access roles to which this user has access"); }
 
}
 
 
addOnloadHook(addRightsLink);
 
 
addOnloadHook(function() {
 
    var subpagename = wgPageName.split( '/' )[1];
 
    if( ( wgNamespaceNumber == "3" || wgNamespaceNumber == "2" ) && !subpagename ) {
 
    addToolboxLink("http://en.wikipedia.org/w/index.php?title=Special:DeletedContributions&target=" + wgTitle, 'Deleted Contributions', 'Foo2', 'Foo3', 'Foo4'); }
 
});
 
 
 
importScript('User:Voice_of_All/replacetxt.js');
 
//wierd stuff
 
importScript('User:Voice_of_All/Specialadmin/monobook.js');
 
//crat stuff
 
importScript('User:Voice_of_All/Bureaucrat/monobook.js');
 
importScript('User:Voice_of_All/History/monobook.js');
 
//Protection stuff
 
importScript('User:Voice_of_All/Protection/monobook.js');
 
importScript('User:Steel359/protection.js');
 
//rollback
 
importScript('User:Voice_of_All/Revert.js');
 
//New pages tools
 
importScript('User:Voice_of_All/Sleeper/monobook.js');
 
importScript('User:Voice_of_All/Adminwarnings/monobook.js');
 
importScript('User:Voice_of_All/Deletion/monobook.js');
 
importScript('User:Voice_of_All/Google/monobook.js');
 
importScript('User:Voice of All/Addtabs/monobook.js');
 
Mvaluejs_class = 'cashews';
 
Rvaluejs_class = 'cashews';
 
Uvaluejs_class = 'cashews';
 
 
importScript('User:Ais523/votesymbols.js');
 
 
addOnloadHook(function()
 
{
 
    var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0];
 
    addlilink(tb, '/wiki/Special:Newpages', 'New pages', 'newpages-ln');
 
    addlilink(tb, '/wiki/Wikipedia:Usernames_for_administrator_attention', 'Usernames', 'uaa-ln');
 
    addlilink(tb, '/wiki/Wikipedia:List_of_protected pages', 'Protected pages', 'pp-ln');
 
    addlilink(tb, '/wiki/Wikipedia:Administrator_intervention_against_vandalism','Vandalism','aiv-ln');
 
    addlilink(tb, '/wiki/Category:Candidates_for_speedy_deletion','Speedy deletions','speedy-ln');
 
    addlilink(tb, '/wiki/Wikipedia:Requests for page protection','Protection requests','rfpp-ln');
 
    addlilink(tb, '/wiki/Wikipedia:Administrators%27_noticeboard','Noticeboard','AN-ln');
 
});
 
 
function PortletMenu( id ) // Taken from [[User:KnowledgeOfSelf/monobook-normal.js]]
 
{
 
this.menu = document.getElementById( id );
 
this.list = this.menu.getElementsByTagName( 'ul' )[ 0 ]; // bypass "<h5>Views</h5>", etc.
 
 
var LIs = this.list.getElementsByTagName( 'li' );
 
 
for ( var i = 0; i < LIs.length; i++ )
 
{
 
this[ LIs[ i ].id ] = LIs[ i ];
 
}
 
 
this.newItem = function( id, txt, url )
 
{ var li = document.createElement( 'li' ); li.id  = id;
 
var  a = document.createElement( 'a'  );  a.href = url;
 
 
  a.appendChild( document.createTextNode( txt ) );
 
li.appendChild( a );
 
 
this[ id ] = li; // watch this!!!
 
 
return li;
 
}
 
 
this.append = function( id, txt, url )
 
{ this.list.appendChild( this.newItem( id, txt, url ) );
 
}
 
 
this.insertBefore = function( old, id, txt, url )
 
{ this.list.insertBefore( this.newItem( id, txt, url ), this[ old ] );
 
}
 
 
this.getText = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data }
 
this.setText = function( id, txt ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].firstChild.data = txt }
 
 
this.getHref = function( id      ) { return this[ id ].getElementsByTagName( 'a' )[ 0 ].href      }
 
this.setHref = function( id, url ) {        this[ id ].getElementsByTagName( 'a' )[ 0 ].href = url }
 
 
}
 
 
addOnloadHook(function() {
 
  usermenu = new PortletMenu('p-personal');
 
    document.getElementById('p-personal').getElementsByTagName('ul')[0].style.textTransform = 'none';
 
    usermenu.setText('pt-mytalk', 'talk');
 
    usermenu.setText('pt-preferences', 'preferences');
 
    usermenu.setText('pt-watchlist', 'watchlist');
 
    usermenu.setText('pt-mycontris', 'contribs');
 
    usermenu.setText('pt-logout', 'logout');
 
if(document.getElementById('ca-addsection')) document.getElementById('ca-addsection').firstChild.innerHTML = '<b>+</b>';
 
});
 
 
importScript('User:Animum/easyblock.js');
 
importScript('User:Animum/rfavote.js'); //Joke script for laughs.
 
//</nowiki></pre>
 

Última revisió del 10:29 16 abr 2014

/* Se carregarà per a tots els usuaris, i per a qualsevol pàgina, el còdic JavaScript que hi haja després d'esta llínia. */

/* Any JavaScript here will be loaded for all users on every page load. */

 function LinkFA() 
 {
    if ( document.getElementById( "p-lang" ) ) {
        var InterwikiLinks = document.getElementById( "p-lang" ).getElementsByTagName( "li" );
 
        for ( var i = 0; i < InterwikiLinks.length; i++ ) {
            if ( document.getElementById( InterwikiLinks[i].className + "-fa" ) ) {
                InterwikiLinks[i].className += " FA"
                InterwikiLinks[i].title = "Ca artiklo havas traktita stando.";
            }
        }
    }
 }
 
 $(document).ready( LinkFA );
 
 /**
 * 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';

window.collapseTable = function ( tableIndex ) {
    var Button = document.getElementById( 'collapseButton' + tableIndex );
    var Table = document.getElementById( 'collapsibleTable' + tableIndex );

    if ( !Table || !Button ) {
        return false;
    }

    var Rows = Table.rows;
    var i;

    if ( Button.firstChild.data === collapseCaption ) {
        for ( i = 1; i < Rows.length; i++ ) {
            Rows[i].style.display = 'none';
        }
        Button.firstChild.data = expandCaption;
    } else {
        for ( 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 = {};
    var Tables = document.getElementsByTagName( 'table' );
    var i;

    function handleButtonLink( index, e ) {
        window.collapseTable( index );
        e.preventDefault();
    }

    for ( i = 0; i < Tables.length; i++ ) {
        if ( $( Tables[i] ).hasClass( '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', '#' );
            $( ButtonLink ).on( 'click', $.proxy( handleButtonLink, ButtonLink, tableIndex ) );
            ButtonLink.appendChild( ButtonText );

            Button.appendChild( document.createTextNode( '[' ) );
            Button.appendChild( ButtonLink );
            Button.appendChild( document.createTextNode( ']' ) );

            Header.insertBefore( Button, Header.firstChild );
            tableIndex++;
        }
    }

    for ( i = 0;  i < tableIndex; i++ ) {
        if ( $( NavigationBoxes[i] ).hasClass( 'collapsed' ) || ( tableIndex >= autoCollapse && $( NavigationBoxes[i] ).hasClass( 'autocollapse' ) ) ) {
            window.collapseTable( i );
        } 
        else if ( $( NavigationBoxes[i] ).hasClass ( 'innercollapse' ) ) {
            var element = NavigationBoxes[i];
            while ((element = element.parentNode)) {
                if ( $( element ).hasClass( 'outercollapse' ) ) {
                    window.collapseTable ( i );
                    break;
                }
            }
        }
    }
}

$(document).ready( createCollapseButtons );
 
 /**
 * Dynamic Navigation Bars (experimental)
 *
 * Description: See [[Wikipedia:NavFrame]].
 * Maintainers: UNMAINTAINED
 */

/* set up the words in your language */
var NavigationBarHide = '[' + collapseCaption + ']';
var NavigationBarShow = '[' + expandCaption + ']';

/**
 * Shows and hides content and picture (if available) of navigation bars
 * Parameters:
 *     indexNavigationBar: the index of navigation bar to be toggled
 **/
window.toggleNavigationBar = function ( indexNavigationBar, event ) {
    var NavToggle = document.getElementById( 'NavToggle' + indexNavigationBar );
    var NavFrame = document.getElementById( 'NavFrame' + indexNavigationBar );
    var NavChild;

    if ( !NavFrame || !NavToggle ) {
        return false;
    }

    /* if shown now */
    if ( NavToggle.firstChild.data === NavigationBarHide ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'none';
            }
        }
    NavToggle.firstChild.data = NavigationBarShow;

    /* if hidden now */
    } else if ( NavToggle.firstChild.data === NavigationBarShow ) {
        for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
            if ( $( NavChild ).hasClass( 'NavContent' ) || $( NavChild ).hasClass( 'NavPic' ) ) {
                NavChild.style.display = 'block';
            }
        }
        NavToggle.firstChild.data = NavigationBarHide;
    }

    event.preventDefault();
};

/* adds show/hide-button to navigation bars */
function createNavigationBarToggleButton() {
    var indexNavigationBar = 0;
    var NavFrame;
    var NavChild;
    /* iterate over all < div >-elements */
    var divs = document.getElementsByTagName( 'div' );
    for ( var i = 0; (NavFrame = divs[i]); i++ ) {
        /* if found a navigation bar */
        if ( $( NavFrame ).hasClass( 'NavFrame' ) ) {

            indexNavigationBar++;
            var NavToggle = document.createElement( 'a' );
            NavToggle.className = 'NavToggle';
            NavToggle.setAttribute( 'id', 'NavToggle' + indexNavigationBar );
            NavToggle.setAttribute( 'href', '#' );
            $( NavToggle ).on( 'click', $.proxy( window.toggleNavigationBar, window, indexNavigationBar ) );

            var isCollapsed = $( NavFrame ).hasClass( 'collapsed' );
            /**
             * Check if any children are already hidden.  This loop is here for backwards compatibility:
             * the old way of making NavFrames start out collapsed was to manually add style="display:none"
             * to all the NavPic/NavContent elements.  Since this was bad for accessibility (no way to make
             * the content visible without JavaScript support), the new recommended way is to add the class
             * "collapsed" to the NavFrame itself, just like with collapsible tables.
             */
            for ( NavChild = NavFrame.firstChild; NavChild != null && !isCollapsed; NavChild = NavChild.nextSibling ) {
                if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                    if ( NavChild.style.display === 'none' ) {
                        isCollapsed = true;
                    }
                }
            }
            if ( isCollapsed ) {
                for ( NavChild = NavFrame.firstChild; NavChild != null; NavChild = NavChild.nextSibling ) {
                    if ( $( NavChild ).hasClass( 'NavPic' ) || $( NavChild ).hasClass( 'NavContent' ) ) {
                        NavChild.style.display = 'none';
                    }
                }
            }
            var NavToggleText = document.createTextNode( isCollapsed ? NavigationBarShow : NavigationBarHide );
            NavToggle.appendChild( NavToggleText );

            /* 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 ( $( NavFrame.childNodes[j] ).hasClass( 'NavHead' ) ) {
                    NavToggle.style.color = NavFrame.childNodes[j].style.color;
                    NavFrame.childNodes[j].appendChild( NavToggle );
                }
            }
            NavFrame.setAttribute( 'id', 'NavFrame' + indexNavigationBar );
        }
    }
}

$(document).ready( createNavigationBarToggleButton );