Comité de Protection des Personnes (en recherche biomédicale) CPP Tours Ouest-1

MediaWiki:Common.js : Différence entre versions

De CPP Ouest-1
Aller à : navigation, rechercher
m (1 version : import CPP mediawiki)
 
m (1 révision importée)
 
(Aucune différence)

Version actuelle en date du 13 janvier 2016 à 17:13

/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */
/* popup     <span class="pops">http://jimbojw.com/</span>   */
addOnloadHook( function() {
     var pops = function( elems ) {
         for (var i=0; i<elems.length; i++) {
             if ( !(' '+elems[i].className+' ').match( / pops / ) ) continue;
             var anchs = elems[i].getElementsByTagName('a');
             for (var j=0; j<anchs.length; j++) anchs[j].target = '_blank';
         }
     };
     var bc = document.getElementById('bodyContent');
     var tags = ['span', 'div', 'table', 'td', 'th'];
     for (var i=0; i<tags.length; i++) pops( bc.getElementsByTagName( tags[i] ) );
 } );


function ModifySidebar(action, section, name, link) {
    try {
        switch (section) {
          case "languages":
            var target = "p-lang";
            break;
          case "toolbox":
            var target = "p-tb";
            break;
          case "navigation":
            var target = "p-navigation";
            break;
          default:
            var target = "p-" + section;
            break;
        }
 
        if (action == "add") {
            var node = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];
 
            var aNode = document.createElement('a');
            var liNode = document.createElement('li');
 
            aNode.appendChild(document.createTextNode(name));
            aNode.setAttribute('href', link);
            liNode.appendChild(aNode);
            liNode.className='plainlinks';
            node.appendChild(liNode);
        }
 
        if (action == "remove") {
            var list = document.getElementById(target)
                               .getElementsByTagName('div')[0]
                               .getElementsByTagName('ul')[0];
 
            var listelements = list.getElementsByTagName('li');
 
            for (var i = 0; i < listelements.length; i++) {
                if (listelements[i].getElementsByTagName('a')[0].innerHTML == name ||
                    listelements[i].getElementsByTagName('a')[0].href == link) {
 
                    list.removeChild(listelements[i]);
                }
            }
        }
 
    } catch(e) {
      // lets just ignore what's happened
      return;
    }
}
 
function CustomizeModificationsOfSidebar() {
    //adds [[Special:CategoryTree]] to toolbox
    //ModifySidebar("add", "toolbox", "CategoryTree", "http://localhost/mediawiki/index.php/Special:CategoryTree");
    //removes [[Special:pages spéciales]] from toolbox
    ModifySidebar("remove", "toolbox", "Pages spéciales");
    ModifySidebar("remove", "toolbox", "Téléverser un fichier");

}
 
addOnloadHook(CustomizeModificationsOfSidebar);


/** Extra toolbar options ***************************/
    mwCustomEditButtons.push({
         "imageFile": "http://upload.wikimedia.org/wikipedia/en/1/13/Button_enter.png",
        "speedTip": "Saut de ligne",
        "tagOpen": "<br />",
        "tagClose": "",
        "sampleText": ""
    });
    mwCustomEditButtons.push({
        "imageFile": "http://upload.wikimedia.org/wikipedia/en/6/60/Button_insert_table.png",
        "speedTip": "Insère un tableau",
        "tagOpen": '{| class="wikitable"\n|',
        "tagClose": "\n|}",
        "sampleText": "-\n! header 1\n! header 2\n! header 3\n|-\n| row 1, cell 1\n| row 1, cell 2\n| row 1, cell 3\n|-\n| row 2, cell 1\n| row 2, cell 2\n| row 2, cell 3"
    });


/** Google analytics ***************************/
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-20653866-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();