MediaWiki:Common.js : Différence entre versions

Ligne 22 : Ligne 22 :
 
/* fonction pour créer des scripts persos */
 
/* fonction pour créer des scripts persos */
  
$(function jsperso() {
+
(function jsperso() {
 
   $('#mw-mywiki-example').html('<button>Try it</button>');
 
   $('#mw-mywiki-example').html('<button>Try it</button>');
 
}());
 
}());
  
$(function jsperso1() {
+
(function jsperso1() {
 
   $('#mw-mywiki-example1').html( mw.loader.load( 'http://wiki.metin2.fr/index.php?title=MediaWiki:Scriptsperso.js&action=raw&ctype=text/javascript' ) );
 
   $('#mw-mywiki-example1').html( mw.loader.load( 'http://wiki.metin2.fr/index.php?title=MediaWiki:Scriptsperso.js&action=raw&ctype=text/javascript' ) );
 
}());
 
}());
  
$(function jsperso2() {
+
(function jsperso2() {
 
   $('#mw-mywiki-example2').mw.loader.load( 'http://wiki.metin2.fr/index.php?title=MediaWiki:Scriptsperso.js&action=raw&ctype=text/javascript' );
 
   $('#mw-mywiki-example2').mw.loader.load( 'http://wiki.metin2.fr/index.php?title=MediaWiki:Scriptsperso.js&action=raw&ctype=text/javascript' );
 
}());
 
}());
  
$(function jsperso3() {
+
(function jsperso3() {
 
   $('#mw-mywiki-example3').html(<button>Try it</button>);
 
   $('#mw-mywiki-example3').html(<button>Try it</button>);
 
}());
 
}());

Version du 10 septembre 2018 à 03:36

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

$('div#content').append( "<div class='content-footer'></div>" );

(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();
})();


/* fonction pour créer des scripts persos */

(function jsperso() {
  $('#mw-mywiki-example').html('<button>Try it</button>');
}());

(function jsperso1() {
  $('#mw-mywiki-example1').html( mw.loader.load( 'http://wiki.metin2.fr/index.php?title=MediaWiki:Scriptsperso.js&action=raw&ctype=text/javascript' ) );
}());

(function jsperso2() {
  $('#mw-mywiki-example2').mw.loader.load( 'http://wiki.metin2.fr/index.php?title=MediaWiki:Scriptsperso.js&action=raw&ctype=text/javascript' );
}());

(function jsperso3() {
  $('#mw-mywiki-example3').html(<button>Try it</button>);
}());