Utilisateur:Anakin/monobook.js

Un article de Wikipédia, l'encyclopédie libre.

Note : Après avoir publié la page, vous devrez forcer son rechargement pour voir les changements : Mozilla / Konqueror / Firefox : Shift-Ctrl-R, Internet Explorer / Opera : Ctrl-F5, Safari : Cmd-R.

/***********************************************************/
/* Variables pour activer/desactiver les fonctionnalitées  */
 
var deactivateAll = false;
 
var activateImageUse = true;
var activateCategoryUse = true;
var activateGlobalSearch = false;
var activateOptimizedSuivi = false;
var activateDeluxeBar = true;
var activateResumeDeluxe = true;
 
// Tout désactiver
if (deactivateAll)
{
  activateImageUse = false;
  activateCategoryUse = false;
  activateGlobalSearch = false;
  activateOptimizedSuivi = false;
  activateDeluxeBar = false;
  activateResumeDeluxe = true;
}
 
/***********************************************************/
 
// Auteur : Anakin
// Dernière mise à jour : 11 décembre 2005
 
function ImageUse()
{
  var element = document.getElementById('ca-nstab-image');
  if (element)
  {
    var imagename = element.firstChild.href;
 
    var indexofname;
    if (imagename.indexOf("http://") != -1)
      indexofname = imagename.indexOf(":", 6);
    else
      indexofname = imagename.indexOf(":");
 
    imagename = imagename.substring(indexofname + 1);
 
    var indexofampersand = imagename.indexOf("&");
    if (indexofampersand != -1)
      imagename = imagename.substring(0, indexofampersand);
 
    var li = document.createElement('li');
    li.id = 'ca-imageuse';
 
    var a = document.createElement('a');
    a.appendChild(document.createTextNode("Voir l'utilisation"));
    a.href = 'http://www.juelich.de/avatar/check-usage/check-usage.php?filename=' + imagename + '&template';
 
    li.appendChild(a);
 
    document.getElementById('ca-nstab-image').parentNode.appendChild(li);
  }
}
if (activateImageUse)
  addLoadEvent(ImageUse);
 
/***********************************************************/
 
// Auteur : Anakin
// Dernière mise à jour : 11 décembre 2005
 
function CategoryTree()
{
  var element = document.getElementById('ca-nstab-category');
  if (element)
  {
    var categoryname = element.firstChild.href;
    categoryname = categoryname.substring(7);
 
    var wikiname = categoryname.substring(0, categoryname.indexOf('.'));
 
    var indexofname = categoryname.indexOf(":") + 1;
    categoryname = categoryname.substring(indexofname);
 
    var indexofampersand = categoryname.indexOf("&");
    if (indexofampersand != -1)
      categoryname = categoryname.substring(0, indexofampersand);
 
    var li = document.createElement('li');
    li.id = 'ca-categorytree';
 
    var a = document.createElement('a');
    a.appendChild(document.createTextNode("Arborescence"));
    a.href = 'http://tools.wikimedia.de/~daniel/WikiSense/CategoryTree.php?wiki=' + wikiname + '&art=on&cat=' + categoryname;
 
    li.appendChild(a);
 
    document.getElementById('ca-nstab-category').parentNode.appendChild(li);
  }
}
if (activateCategoryUse)
  addLoadEvent(CategoryTree);
 
/***********************************************************/
 
function DeluxeBar()
{
  if (document.createTextNode)
  {
    var toolbar = document.getElementById("toolbar"); 
    if (!toolbar)
      return;
 
    ///// zone personnalisable ////
    var messages = new Array()
 
    // le texte a été splitté sinon Mediawiki casse tout...
    messages[0] = "{{subst:" + "Bienvenue sur ta page"  + "}}" +  "~~" + "~~";
    messages[1] = "{{subst:" + "Bienvenue" + "}}" +  "~~" + "~~";
    messages[2] = "{{" + "suppression" + "}}";
    messages[3] = "{{" + "orthographe" + "}}";
    messages[4] = "{{" + "Modèle:Désormais sur Commons" + "}}";
 
    var images = new Array()
    images[0] = "http://upload.wikimedia.org/wikipedia/fr/1/12/Button_accueilA.png";
    images[1] = "http://upload.wikimedia.org/wikipedia/fr/e/eb/Button_accueilB.png";
    images[2] = "http://upload.wikimedia.org/wikipedia/fr/f/f8/Button_suppr.png";
    images[3] = "http://upload.wikimedia.org/wikipedia/fr/a/ae/Button_trait%C3%A9conserver.png";
    images[4] = "http://upload.wikimedia.org/wikipedia/commons/4/4c/Commons-logo-en.png";
 
    var commentaires = new Array()
    commentaires[0] = "Bienvenue sur ta page !"
    commentaires[1] = "Bienvenue !"
    commentaires[2] = "Proposé à la suppression";
    commentaires[3] = "Vérifier l'orthographe";
    commentaires[4] = "Désormais sur commons";
 
    ////////////////////////////////
 
    toolbar.appendChild(document.createElement("br"));
    for (var i = 0; i < messages.length; i++)
    {
      var img = document.createElement("img");
      img.setAttribute("src", images[i]);
      img.setAttribute("width", "23");
      img.setAttribute("height", "22");
      img.setAttribute("alt", commentaires[i]);
      img.setAttribute("title", commentaires[i]);
 
      var ref = document.createElement("a");
      ref.setAttribute("href", "javascript:insertTags('', \"" + messages[i] + "\", '');" + 
                               "javascript:changeSummary(\"" + commentaires[i] + "\");" ); 
      ref.appendChild(img); 
 
      toolbar.appendChild(ref);
    }
  }
}
if (activateDeluxeBar)
  addLoadEvent(DeluxeBar);
 
/***********************************************************/
 
// auteur : Utilisateur:Dake
// version corrigée - 18.09.2005 - 13:25 
// cette fonction est incompatible avec le suivi amélioré
function OptimizedSuivi() 
{
  if (document.URL.indexOf("http://fr.wikipedia.org/wiki/Special:Watchlist") == 0
   || document.URL.indexOf("http://fr.wikipedia.org/w/index.php?title=Special:Watchlist") == 0)
  {
    var allDays = document.getElementsByTagName("ul");
 
    for (i = 0; i < allDays.length; i++)
    {
      if (allDays[i].getAttribute("class") == "special")
      {
        var artList = allDays[i].getElementsByTagName("li");
        for (j = 0; j < artList.length; j++)
        {
          var elem = artList[j];
          var aTag = elem.getElementsByTagName("a");
          var articleName = aTag[0].getAttribute("title");
          var stopWatch  = "/w/index.php?title=" + articleName + "&action=unwatch";
          elem.innerHTML = "(<a href=\"" + stopWatch + "\">stop</a>) " + elem.innerHTML;
        }
      }
    }
  }
}
if (activateOptimizedSuivi)
  addLoadEvent(OptimizedSuivi);
 
/***********************************************************/
 
// auteur : Utilisateur:Anakin
// dernière version : 08 décembre 2005
 
function startSearch()
{
  var textsearch = document.getElementById('searchInput').value;
 
  var link = "http://vs.aka-online.de/cgi-bin/globalwpsearch.pl?search=";
  link = link + textsearch;
  link = link + "&timeout=120&minor=1";
 
  window.location = link;
}
 
function globalSearch()
{
  var pSearchElement = document.getElementById('searchform');
 
  var newElement = document.createElement("input");
  newElement.setAttribute("type", "button");
  newElement.setAttribute("name", "globalsearch");
  newElement.setAttribute("class", "searchButton");
  newElement.setAttribute("value", "Recherche globale");
  newElement.setAttribute("onClick", "startSearch()");
 
  pSearchElement.appendChild(newElement);
}
if (activateGlobalSearch)
  addLoadEvent(globalSearch);
 
/***********************************************************/
 
function ResumeDeluxeModif(content)
{
    if (document.editform.wpSummary.value != 0)
        document.editform.wpSummary.value += ' - ';
    document.editform.wpSummary.value += content;
}
 
// Résumé Deluxe 
// Fonction ResumeDeluxeModif
//
// Code : Dake
function ResumeDeluxe()
{
    // vous pouvez ajouter vos messages ci-dessous - attention aux apostrophes et aux 
    // guillemets qui peuvent casser le script
    var messages = new Array()
    messages[0] = "ortho";
    messages[1] = "typo";
    messages[2] = "catégories";
    messages[3] = "interwiki";
    messages[4] = "wikification";
    messages[5] = "bandeau ébauche";
 
    // texte dans les boutons (pour éviter de prendre trop de place)
    var labelBoutons = new Array()
    labelBoutons[0] = "ortho";
    labelBoutons[1] = "typo";
    labelBoutons[2] = "cat";
    labelBoutons[3] = "interwiki";
    labelBoutons[4] = "wiki";
    labelBoutons[5] = "ébauche";
 
    var nombreBoutonsParLigne = 8;
 
    // ne rien toucher ci-dessous
    var mainNode = document.getElementById("wpSummaryLabel");
    if (!mainNode)
        return;
 
    var summaryNode = mainNode;
    var formButtons = document.createElement("form");
 
    for (var i = 0; i < messages.length; i++)
    {
        if (i%nombreBoutonsParLigne == 0)
            formButtons.appendChild(document.createElement("p"));
 
        var nodeInput = document.createElement("input");
        nodeInput.setAttribute("type", "button"); 
        nodeInput.setAttribute("value", labelBoutons[i]); 
        nodeInput.setAttribute("onClick", "ResumeDeluxeModif('" + messages[i] + "')"); 
 
        formButtons.appendChild(nodeInput); 
    }
    summaryNode.appendChild(formButtons);
}
 
addLoadEvent(ResumeDeluxe);