« Utilisateur:François Melchior/common.js » : différence entre les versions

Un livre de Wikilivres.
Contenu supprimé Contenu ajouté
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 2 : Ligne 2 :


advtitleNamespaces = [0,2,4,12]
advtitleNamespaces = [0,2,4,12]
advtitleSlashInName = /G[Nn][Uu]\/(?:Linux|Hurd)|TCP\/IP|[Tt]cp\/[Ii]p|I\/O|E\/S|[Ee]ntrées?\/sortie|PS\/2|PL\/SQL|P\/Invoke/ //non-capt = JS 1.5
advtitleSlashInName = /G[Nn][Uu]\/(?:Linux|Hurd)|TCP\/IP|[Tt]cp\/[Ii]p|I\/O|E\/S|[Ee]ntrées?\/sortie|PS\/2|PL\/SQL|P\/Invoke|\b[Ff]\/\d/ //non-capt = JS 1.5


//advtitleSeparator = ' — – − ― - '
//advtitleSeparator = ' — – − ― - '

Version du 14 novembre 2013 à 11:55

//<nowiki>

advtitleNamespaces = [0,2,4,12]
advtitleSlashInName = /G[Nn][Uu]\/(?:Linux|Hurd)|TCP\/IP|[Tt]cp\/[Ii]p|I\/O|E\/S|[Ee]ntrées?\/sortie|PS\/2|PL\/SQL|P\/Invoke|\b[Ff]\/\d/ //non-capt = JS 1.5

//advtitleSeparator = '&emsp;—&ensp;–&ensp;− ― -&emsp;'
//advtitleSeparator = '&emsp;&mdash;&ensp;&ndash;&ensp;&#x2012;&ensp;&minus;&emsp;'
advtitleSeparator = '&ensp;&mdash;&ensp;'

function addSpecialChar(tagBegin,tagEnd,defaultValue,showedText,separe)
  {
  var specialchars=document.getElementById('specialchars');
  if (!specialchars) return;
  var caracteresSpeciaux=specialchars.previousSibling.parentNode.getElementsByTagName('p')[0];
  var nouveauA=document.createElement("a");
  nouveauA.setAttribute('href','#');
  nouveauA.setAttribute('onClick','insertTags(\''+tagBegin+'\',\''+tagEnd+'\',\''+defaultValue+'\')\;return false');
  nouveauA.appendChild(document.createTextNode(showedText));
  //nextNode=caracteresSpeciaux.getElementsByTagName('small')[0].previousSibling; //ici, c'est expérimental: si la page change, il faut changer.
  if(separe)
    caracteresSpeciaux.appendChild(document.createTextNode(' · '));
  caracteresSpeciaux.appendChild(nouveauA);
  }

/*function dontFollowUserTalkPages()
  {
  if(document.editform==undefined||
     document.editform.wpWatchthis==undefined
     ||wgCanonicalNamespace!="User_talk") return;
  document.editform.wpWatchthis.checked=false
  }*/
/*
function customOnload()
  {
  addSpecialChar('“','„','','“ „',true); //″“„
  //dontFollowUserTalkPages();
  /*
  var saveButton=document.getElementById('wpSave');
  var parentOfButtons=saveButton.parentNode;
  var prevButton=parentOfButtons.removeChild(document.getElementById('wpPreview'));
  parentOfButtons.insertBefore(prevButton,saveButton);
  var saveButton=document.getElementById('wpSave');
  var prevButton=document.getElementById('wpPreview');
  var saveButtonIndex=saveButton.getAttribute('tabindex');
  var prevButtonIndex=prevButton.getAttribute('tabindex');
  saveButton.setAttribute('tabindex',prevButtonIndex);
  prevButton.setAttribute('tabindex',saveButtonIndex);
  *-/
  }*/

//addLoadEvent(customOnLoad) Déprécié
//$(customOnload) //addOnloadHook déprécié aussi!

$(document).ready( function() { //(modified for tests with NS6)
  /*addPortletLink('p-personal',
   '/w/index.php?title=Special:Suivi_des_liens&target=Utilisateur:Fran%C3%A7ois_Melchior/Suivi_personnalis%C3%A9_1&hideminor=0&days=180&limit=10',
                   'Suivi personnalisé');*/
  /*addPortletLink('p-personal',
                          'http://commons.wikimedia.org/wiki/Special:Watchlist',
                          'Commons (liste de suivi)');*/

  mw.util.addPortletLink('p-Navigation', //'p-Biblioth.C3.A8que'
                         '/wiki/Utilisateur:François_Melchior/Bloc-note',
                         'Bloc-note personnel','n-custom-notepad','','','#n-recentchanges')

  addSpecialChar('“','„','','“ „',true) //″“„

  /*addPortletLink('p-Biblioth.C3.A8que', //'p-Navigation'
                          '/wiki/Utilisateur:François_Melchior/Bloc-note',
                          'Bloc-note personnel')*/
  
  var page = mw.config.get('wgPageName')
  if(page.substring(0,37) == 'Utilisateur:François_Melchior/Modèle:')
    mw.util.addPortletLink('p-tb',
                           '/wiki/Spécial:ComparePages?page1=' + page + '&page2=' + page.substring(30),
                           'Comparer avec le modèle')
  
  if(page.substr(-9) == '/Sommaire' //Note: début < 0 pas compatible avec Microsoft's JScript.
     || page.substring(0,32) == 'Modèle:Contenu de sommaire/Style')
    {
    mw.util.$content.find('.editButtons').after('<fieldset id="templatesandbox-editform">\
        <legend>Aperçu de la page avec ce modèle</legend>\
        <input id="wpTemplateSandboxTemplate" type="hidden" value="' + page
      + '" name="wpTemplateSandboxTemplate"/>\
        <span class="mw-templatesandbox-page" id="wpTemplateSandboxPageLabel">\
        <label for="wpTemplateSandboxPage">Titre de la page&#160;:</label></span>\
        <input id="wpTemplateSandboxPage" tabindex="8" size="60" spellcheck="true" name="wpTemplateSandboxPage" value="'
      + (mw.util.$content.find('.previewnote a').attr('title') || '')
      + '"/><input id="wpTemplateSandboxPreview" name="wpTemplateSandboxPreview" type="submit"\
               tabindex="9" value="Afficher l’aperçu"/></fieldset>')
    
    $('#wpTemplateSandboxPage').keypress(function(ev)
      {
      if (ev.which === 13) { $('#wpTemplateSandboxPreview').click(); return false }
      return true;
      });
    }
  
  /*addPortletLink('p-navigation',
                          '/w/index.php?title=Sp%C3%A9cial%3AIndex&prefix=Fran%C3%A7ois+Melchior&namespace=2',
                          'Liste de mes sous-pages')*/
  }
 );

/*obtenir('LiensRouges');
//obtenir('OptimizedSuivi');

//From Utilisateur:Dake
function insertAfter(parent, node, referenceNode) {
  parent.insertBefore(node, referenceNode.nextSibling);
}

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"
                                    
                                        var newElement = document.createElement("a");
                                        newElement.setAttribute("href",stopWatch);
                                        var newText = document.createTextNode("stop");
                                        newElement.appendChild(newText);

                                        var newPar = document.createTextNode(") (")
                                        // séparation des cas (nouvel article, ou déjà existant)
                                        if (aTag[0].childNodes[0].data == "diff") {
                                                insertAfter(elem, newPar, aTag[1]); 
                                        } else {
                                                insertAfter(elem, newPar, aTag[0]); 
                                        }
                                        
                                        insertAfter(elem, newElement, newPar);
                                }       
                        }
                }
        }
}

addLoadEvent(OptimizedSuivi);
//end (From Utilisateur:Dake)

//Params pour AdvancedResearch (Gadget)
adSearchSametab=true;
adSearchButtons=Array('w','l','reset','c');
adSearchDefault='w';

document.writeln('<'+'script type="text/javascript" src="http://fr.wikipedia.org/w/index.php?title=Utilisateur:François_Melchior/CatHelp.js&action=raw&ctype=text/javascript&dontcountme=s" />');
*/

//document.writeln('<'+'script type="text/javascript" src="http://fr.wikibooks.org/w/index.php?title=Utilisateur:François_Melchior/ToggleBox.js&action=raw&ctype=text/javascript&dontcountme=s" />');

//document.writeln('<'+'script type="text/javascript" src="http://fr.wikibooks.org/w/index.php?title=Utilisateur:François_Melchior/ToggleBox.jQuery.js&action=raw&ctype=text/javascript&dontcountme=s" />');

removeOnloadHook(IconesDeTitre);


//Note importante: les 'float:right' DOIVENT être définis dans une feuille de style pour pouvoir être “flippés„ en cas de langue RtL.
                        //TODO: common.css: .topicons { float:right;bottom:30px }
                        //                  .topicons .topicon { float:right;display:block;padding-left:9px }
                        //                  .topicon { display:none }
$(document).ready( function() {
  var icons = $('<div style="height:0;position:relative;bottom:30px" class="titleIcons"></div>')
  //icons.append('#mw-content-text .topicon')
  mw.util.$content.find('div.icone_de_titre').each( function() {
    icons.append(this)
    $(this).css('display','block') //Use CSS
    //this.css('float',dir)
    //this.style.borderWidth = '1px'
    //this.style.borderStyle = 'solid'
    //this.style.borderColor = 'white'
    });
  icons.insertAfter('h1:first')
});
removeOnloadHook(RedirectCommonsFile);

mw.loader.load('//fr.wikibooks.org/w/index.php?title=Utilisateur:François_Melchior/ToggleBox.jQuery.js&action=raw&ctype=text/javascript');

mw.loader.load('//fr.wikibooks.org/w/index.php?title=Utilisateur:François_Melchior/MediaWiki:Gadget-AdvancedTitle.js&action=raw&ctype=text/javascript');

mw.loader.load('//fr.wikibooks.org/w/index.php?title=Utilisateur:François_Melchior/MediaWiki:Gadget-AdvancedTitle.css&action=raw&ctype=text/css','text/css');

mw.loader.load('//fr.wikibooks.org/w/index.php?title=Utilisateur:François_Melchior/MediaWiki:Gadget-PPLimitReport.js&action=raw&ctype=text/javascript');

// &dontcountme=s : see http://www.mail-archive.com/wikibugs-l@lists.wikimedia.org/msg08824.html

//</nowiki>