MediaWiki:Common.js : Différence entre versions

Ligne 44 : Ligne 44 :
  
 
/*test*/
 
/*test*/
 
mw.loader.load( '/w/index.php?title=MediaWiki:Test.js&action=raw&ctype=text/javascript' );
 
  
 
(function () {
 
(function () {

Version du 22 septembre 2021 à 22:15

/* Tout JavaScript ici sera chargé avec chaque page accédée par n’importe quel utilisateur. */

/*Favicon*/

$('link[rel="shortcut icon"]').attr('href', 'https://gf1.geo.gfsrv.net/cdn98/191b803adbf82f4b8febe3a2c38c2c.ico');

/*Tabber*/

function onTabClick(event) {
  
  var tabberFrere = event.currentTarget.parentElement.nextElementSibling;
  
  tabberActive = tabberFrere.parentElement.querySelectorAll(".tabber-active");
    
  tabberActive.forEach(function(tab) {
    
    tab.className = tab.className.replace('tabber-active', '');
    
  });
  
   event.currentTarget.className += ' tabber-active';
  
   tabberFrere.children[parseInt(event.currentTarget.id)].className += ' tabber-active';
  
}

(function(){
  
  var tabberContainer = document.querySelectorAll("#tabber-container");
  
  tabberContainer.forEach(function(e){
    
    var classButton = e.querySelectorAll(".button");
    
    classButton.forEach(function(e) {
      
      e.addEventListener('click', onTabClick, false);
      
    });
    
});
  
})();

/*test*/

(function () {
      var myElement = document.getElementById('mw-rendu-maths');
      myElement.insertAdjacentHTML('afterend', '<form name="a" action="#"><tr><td>test</td><td><input name="c" id="c" type="text" size="2" value="2" /></td><td><input name="d" type="text" size="5" value="5"/></td><td><input name="b" type="text" size="5" /></td><td><input type="button" value="Calculer" onclick="Calculer();"></td></tr></form>');
})();

(function Calculer() {
      var element1 = document.getElementById('b');
      var element2 = document.getElementById('c');
      var element3 = document.getElementById('d');
      element3.value = element1.value + element2.value;
})();


/* Pour les cookies */

(function () {
    var req = new XMLHttpRequest();
    req.addEventListener('load', function (ev) {
        if (this.status >= 200 && this.status < 300) {
            var data = JSON.parse(this.responseText);
            if (data.hasOwnProperty('version')) {
                var gdpr = document.createElement("script");
                gdpr.src = "https://s3-static.geo.gfsrv.net/cookiebanner/" + data.version + "/cookie.min.js";
                document.head.appendChild(gdpr);
            }
        }
    });
    req.open('GET', "https://s3-static.geo.gfsrv.net/cookiebanner/version.json");
    req.send();
})();