User:Grondin/monobook.js

From translatewiki.net
Jump to: navigation, search

Note: After saving, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/*<pre>*/


/**
 * Installation d'une nouvelle fonction de cette façon :
 * aOnloadFunctions[aOnloadFunctions.length] = nom_de_la_fonction; // (sans parenthèses)
 */
if (!window.aOnloadFunctions) { 
  var aOnloadFunctions = new Array(); 
}

window.onload = function() 
{
  if (window.aOnloadFunctions) {
    for (var _i=0; _i<aOnloadFunctions.length; _i++) {
      aOnloadFunctions[_i]();
    }
  }
}


/**
 * Ajouter une nouvelle fonction à excuter au chargement de la page.
 */ 
function addLoadEvent(func) 
{
  if (window.addEventListener) 
    window.addEventListener("load", func, false);
  else if (window.attachEvent)
    window.attachEvent("onload", func);
}

//////////BARRE EDITION BOUTON//////////////////////////////////

function DeluxeBar() {
  if (document.createTextNode) {
        var toolbar = document.getElementById("toolbar"); 
        if (!toolbar) return;
        

        var messages = new Array()
        var images = new Array()
        var commentaires = new Array()
        var a=-1;

//Le décompte commence à -1 avec une incrementation sur le premier message, pour éviter tout probleme en cas d'inversion ou suppression du premier message

        // le texte a été splitté sinon Mediawiki casse tout...

        messages[++a] = "* {{" + "PleaseCommit|fr|" + "}}" + " --" + "~~" + "~~" ;
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/9/90/Button_save_changes.png";
        commentaires[a] = "Translations to be committed";

        messages[++a] = "{{" + "subst:CommitLanguage\\n|type=\\n|lang=\\n" + "}}"  ;
        images[a] = "http://upload.wikimedia.org/wikipedia/commons/1/17/Button_indevelopment.png";
        commentaires[a] = "Extensions or core committed";


       ////////////////////////////////

for (var i=0;i<messages.length;i++) {
                var img = document.createElement("img");
                img.setAttribute("src", images[i]);
                
                var ref = document.createElement("a");
                ref.setAttribute("href", "javascript:insertTags('', \"" + messages[i] + "\", '');" + 
                                 "javascript:changeSummary(\"" + commentaires[i] + "\");" ); 
                ref.appendChild(img); 
                
                toolbar.appendChild(ref);
        }
  }
}

function changeSummary(sampleText) {
        document.editform.wpSummary.value = sampleText;
}

addLoadEvent(DeluxeBar);


function addToSummary(str)
{
        document.editform.wpSummary.value += " " + str
}

function DeluxeSummary()
{
        var sumLbl = document.getElementById("wpSummaryLabel")
        if (sumLbl)
        {
                //élargissement boite de résumé
                var sumInput = document.getElementById("wpSummary")
                sumInput.style.width = "90%"

                var titles = new Array()
                titles.push("ébauche")
                titles.push("cat")
                titles.push("image")
                titles.push("interwiki")
                titles.push("lien int")
                titles.push("lien ext")
                titles.push("corr interwiki")
                titles.push("corr rint")
                titles.push("corr ext")
                titles.push("ext -> int")
                titles.push("int -> interwiki")
                titles.push("redir")
                titles.push("ortho/gram")
                titles.push("retouches")
                titles.push("ajInfo")
                titles.push("recat")
                titles.push("création")
                titles.push("tentative")
                titles.push("redir db")
                titles.push("publié")
                titles.push("trad fr")
                titles.push("update")
                titles.push("date")

                var inputs = new Array()
                inputs.push("- bandeau ébauche ")
                inputs.push("- category ")
                inputs.push("- image ")
                inputs.push("- Interwiki link ")
                inputs.push("- intra-wiki link ")
                inputs.push("- extra-wiki linki ")
                inputs.push("correcting interwiki link ")
                inputs.push("correcting intra-wiki link ")
                inputs.push("correcting extra-wiki link ")
                inputs.push("converting extra-wiki into intra-wiki link ")
                inputs.push("converting intra-wiki into interwiki link ")
                inputs.push("Redirect ")
                inputs.push("correcting ortho/gramm ")
                inputs.push("some updating ")
                inputs.push("Add info ")
                inputs.push("change category ")
                inputs.push("Init page ")
                inputs.push("Try to translate in french language waiting better one")
                inputs.push("Correcting double redirect ")
                inputs.push("Request for committing done")
                inputs.push("Translating in french ")
                inputs.push("Updating french translation ")
                inputs.push("- du "+ TodayDate())

                var str = ""
                for (var cpt = 0; cpt < titles.length; cpt ++)
                {
                        str += "<a href=\"javascript:addToSummary('" + inputs[cpt] + "')\""
                                + " class=\"sumLink\" title=\"Ajouter '" + inputs[cpt] +"' dans la boîte de résumé\">"
                                + titles[cpt]
                                + " ·</a> "
                }
                sumLbl.innerHTML = str + "<br />" + sumLbl.innerHTML
        }
}

addLoadEvent(DeluxeSummary)

///////////////////////////////////////////////////

////////////////Ajout de liens internes (bistro, PàS, etc.) dans la boîte de navigation à gauche/////////////////////

function OptimizedNavig() 
{
  var a = document.getElementById("lire");

  if (a) 
  {
    b = a.getElementsByTagName("ul");
    if(b.length > 0)
    { 
      var startUrl = '/w/index.php?title='
      var endUrl = '&action=purge'

      // liste des URLs
      var urls = new Array()
      urls[0] = 'Wikisource:Pages à supprimer'
      urls[1] = 'Special:Newpages'
      urls[2] = 'Special:Blockip'
      urls[3] = 'Special:Log/delete'
      urls[4] = 'Special:Unusedcategories'
      urls[5] = 'Special:Export'
      urls[6] = 'Special:Import'
      urls[7] = 'b:Special:Import'
      urls[8] = 'v:Special:Import'
      urls[9] = 'q:Special:Import'
      urls[10] = 'w:Special:Import'
      urls[11] = 'wikt:Special:Import'
      urls[12] = 'MediaWiki:Monobook.js'
      urls[13] = 'MediaWiki:Edittools'



      var labels = new Array()
      labels[0] = 'PàS'
      labels[1] = 'nPage'
      labels[2] = 'Block'
      labels[3] = 'Log/Del'
      labels[4] = 'unCat'
      labels[5] = 'Export'
      labels[6] = 'Import'
      labels[7] = 'b:Import'
      labels[8] = 'v:Import'
      labels[9] = 'q:Import'
      labels[10] = 'w:Import'
      labels[11] = 'wikt:Import'
      labels[12] = 'monobook'
      labels[13] = 'Edittools'


      for (var i=0;i<urls.length;i+=2) {
        tableHTML = '<table valign="top" cellspacing="0" cellpadding="0">'
        tableHTML += '<tr>'
        tableHTML += '<li><td><a href="' + startUrl + urls[i] + endUrl + '">' + labels[i] + ' | </a></td>'
        tableHTML += '<td><a href="' + startUrl + urls[i+1] + endUrl + '">' + labels[i+1] + '</a></td></li>'
        tableHTML += '</tr>'
        tableHTML += '</table>' 
        b[0].innerHTML = b[0].innerHTML + tableHTML
      }

    }
  }
}

addLoadEvent(OptimizedNavig);


/*************************
 * Navigation Pop-ups    *
 *************************/

document.write('<script type="text/javascript" src="' 
		+ 'http://en.wikipedia.org/w/index.php?title=User:Lupin/popups.js' 
		+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
document.write('<script type="text/javascript" src="' 
		+ 'http://fr.wikipedia.org/w/index.php?title=User:Leag/popups-strings-fr.js' 
		+ '&action=raw&ctype=text/javascript&dontcountme=s"></script>');
simplePopups=true;
popupStructure='menus';
popupDelay=0;
popupAdminLinks=true;
popupImages=false;
popupMaxWidth=false;
popupOnlyArticleLinks=false;
popupMaxWidth=false;


////FONCTION TODAYDATE///
function TodayDate()
{
        var m = new Array("janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre")
        var today = new Date()
        var day = today.getDate()
        var year = today.getYear()

        if (year < 2000)
                year += 1900

        return (day + " " + m[today.getMonth()] + " " + year)
}


/*</pre>*/