MediaWiki:Common.js

Revisió de 09:33 17 jun 2008 per Admin (Discussió | contribucions) (Pàgina nova, en el contingut: «→‎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.: //<pre><nowiki> ///////////////////...».)
(difs.) ← Revisió anterior | Revisió actual (difs.) | Revisió següent → (difs.)

Nota: Després de guardar, tens que posar al dia la memòria cache del teu navegador per a vore els canvis. Mozilla / Firefox / Safari: Pressiona Shift mentres fas clic Actualisa (Reload), o pressiona Ctrl+Shift+R (Cmd+Shift+R en un Mac Apple); Internet Explorer: pressiona Ctrl mentres fas clic Actualisa (Refresh), o pressiona Ctrl+F5; Konqueror:: simplement fes clic en el botó Recarregar (Reload), o pressiona F5; Opera hauràs de borrar completament la teua memòria cache en Ferramentes→Preferències.

/* 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. */
//<pre><nowiki>
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//    |—————————————————————————————————————————————————————————————————————————————————————————————————————————|    //
//    |-| I feel I am *relatively* good at JavaScript programming, so feel free to ask me questions about any |-|    //
//    |-| 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       |-|    //
//    |-| Firefox ONLY!                                                                                       |-|    //
//    |—————————————————————————————————————————————————————————————————————————————————————————————————————————|    //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
importScript('User:Gracenotes/amelvand.js');
importScript('User:Animum/editsection.js');
importScript('User:Animum/reset.js');
importScript('User:Animum/ais523editcount.js');
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');
//[[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'); 
importStylesheet('Wikipedia:WikiProject User scripts/Scripts/Add LI menu/css');
importScript('User:Animum/count.js');
importScript('Wikipedia:WikiProject User scripts/Scripts/Fix lowercase first letter problem');
 
addOnloadHook(function() {
if(wgAction=="edit") {
  document.forms["editform"].wpWatchthis.checked = false;
}
});
 
//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]]
 
function autoafd_result()
{
  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');
  t.value = "{{subst:" + "at" + "}} '''" + close + "'''. " + "\~\~\~\~" + '\n' + '\n' + t.value;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "ab" + "}}";
  f.wpSummary.value = "Closing debate; result was " + close;
}
 
function autoafd_relist()
{
  var f = document.editform, t = f.wpTextbox1;
  if (t.value.length > 0)
    t.value += '\n';
  t.value += "{{subst:" + "relist" + "|" + "\~\~\~\~\}\}";
  f.wpSummary.value = "Relisting debate";
}
 
function autoafd_add_afd_tabs()
{
  // Only add for pages with the right string somewhere in the title
  if (document.title.indexOf("Editing Wikipedia:Articles for deletion/") != -1)
    {
      addPortletLink('p-cactions', 'javascript:autoafd_result()', "close");
      addPortletLink('p-cactions', 'javascript:autoafd_relist()', "relist");
    }
}
 
addOnloadHook(autoafd_add_afd_tabs);
 
//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>