« MediaWiki:Common.js » : différence entre les versions

Kims (discussion | contributions)
Aucun résumé des modifications
Balise : Révoqué
Kims (discussion | contributions)
Aucun résumé des modifications
 
(3 versions intermédiaires par le même utilisateur non affichées)
Ligne 1 : Ligne 1 :
/* Tout JavaScript ici sera chargé pour chaque page visitée par n’importe quel utilisateur. */
/* ═══ Barre inter-sites Fallout Génération (Wiki actif) ═══ */
(function () {
    'use strict';
    function mount() {
        if (document.getElementById('xbar')) return;
        var svg = '<svg viewBox="0 0 127.14 96.36" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">'
            + '<path fill="currentColor" d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z"/></svg>';
        var html = [
            '<nav id="xbar" class="xbar" aria-label="Sites de la communauté Fallout Génération">',
            '<span class="xb-brand"><span class="xb-name">FALLOUT GÉNÉRATION</span></span>',
            '<a href="https://fallout-generation.com/" target="_blank" rel="noopener">Forum</a>',
            '<span class="xb-sep">·</span>',
            '<a href="https://fallout-wiki.com/" class="actif">',
            '<span class="xb-long">Wiki — Archives de Vault-Tec</span><span class="xb-short">Wiki</span></a>',
            '<span class="xb-sep">·</span>',
            '<a href="https://fallout-maps.com/" target="_blank" rel="noopener">',
            '<span class="xb-long">Carte interactive</span><span class="xb-short">Carte</span></a>',
            '<a class="xb-discord" href="https://discord.gg/2wFBScdhdH" target="_blank" rel="noopener"',
            ' data-guild="181800470082355200" title="Rejoindre le Discord">',
            svg,
            '<span class="xb-join">Rejoindre</span>',
            '<span class="xb-count" hidden><b></b><span class="xb-long"> en ligne</span> <span class="xb-dot"></span></span>',
            '</a></nav>'
        ].join('');
        document.body.insertAdjacentHTML('afterbegin', html);
 
        var a = document.querySelector('#xbar .xb-discord');
        if (!a || !a.dataset.guild) return;
        var run = function () {
            fetch('https://fallout-maps.com/discord_count.php?g=' + encodeURIComponent(a.dataset.guild))
                .then(function (r) { return r.ok ? r.json() : null; })
                .then(function (j) {
                    if (j && typeof j.presence_count === 'number') {
                        var c = a.querySelector('.xb-count');
                        c.querySelector('b').textContent = j.presence_count;
                        c.hidden = false;
                    }
                })
                .catch(function () {});
        };
        (window.requestIdleCallback || function (cb) { setTimeout(cb, 0); })(run);
    }
    if (document.body) { mount(); } else { document.addEventListener('DOMContentLoaded', mount); }
})();


/* ######################################################################## */
/* ######################################################################## */
Ligne 25 : Ligne 68 :


});
});
  // Construction du bandeau
  var banner = document.createElement( 'div' );
  banner.id = 'vt-discord-banner';
  banner.innerHTML = iconSVG
    + '<span class="vt-banner-text">'
    +  '<strong>Communauté française</strong> — Rejoignez-nous sur Discord pour discuter, jouer, poser vos questions et contribuer au wiki !'
    + '</span>'
    + '<a class="vt-banner-btn" href="' + DISCORD_URL + '" target="_blank" rel="noopener noreferrer">'
    +  '↗ Rejoindre'
    + '</a>'
    + '<button class="vt-banner-close" aria-label="Fermer">×</button>';
  document.body.appendChild( banner );
  // Animation d'entrée (légère)
  requestAnimationFrame( function () {
    banner.style.opacity = '0';
    banner.style.transform = 'translateY(100%)';
    requestAnimationFrame( function () {
      banner.style.transition = 'transform 0.35s ease, opacity 0.35s ease';
      banner.style.opacity = '';
      banner.style.transform = '';
    } );
  } );
  // Fermeture
  banner.querySelector( '.vt-banner-close' ).addEventListener( 'click', function () {
    banner.classList.add( 'vt-banner-hidden' );
    localStorage.setItem( STORAGE_KEY, '1' );
    setTimeout( function () { banner.remove(); }, 350 );
  } );
}() );
/* LCP — fetchpriority=high sur la première image de l'article */
( function () {
    var img = document.querySelector( '#mw-content-text .mw-file-element' );
    if ( img && !img.complete ) {
        img.setAttribute( 'fetchpriority', 'high' );
    }
} )();

Dernière version du 10 juillet 2026 à 07:55

/* ═══ Barre inter-sites Fallout Génération (Wiki actif) ═══ */
(function () {
    'use strict';
    function mount() {
        if (document.getElementById('xbar')) return;
        var svg = '<svg viewBox="0 0 127.14 96.36" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">'
            + '<path fill="currentColor" d="M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1A105.25,105.25,0,0,0,126.6,80.22h0C129.24,52.84,122.09,29.11,107.7,8.07ZM42.45,65.69C36.18,65.69,31,60,31,53s5-12.74,11.43-12.74S54,46,53.89,53,48.84,65.69,42.45,65.69Zm42.24,0C78.41,65.69,73.25,60,73.25,53s5-12.74,11.44-12.74S96.23,46,96.12,53,91.08,65.69,84.69,65.69Z"/></svg>';
        var html = [
            '<nav id="xbar" class="xbar" aria-label="Sites de la communauté Fallout Génération">',
            '<span class="xb-brand"><span class="xb-name">FALLOUT GÉNÉRATION</span></span>',
            '<a href="https://fallout-generation.com/" target="_blank" rel="noopener">Forum</a>',
            '<span class="xb-sep">·</span>',
            '<a href="https://fallout-wiki.com/" class="actif">',
            '<span class="xb-long">Wiki — Archives de Vault-Tec</span><span class="xb-short">Wiki</span></a>',
            '<span class="xb-sep">·</span>',
            '<a href="https://fallout-maps.com/" target="_blank" rel="noopener">',
            '<span class="xb-long">Carte interactive</span><span class="xb-short">Carte</span></a>',
            '<a class="xb-discord" href="https://discord.gg/2wFBScdhdH" target="_blank" rel="noopener"',
            ' data-guild="181800470082355200" title="Rejoindre le Discord">',
            svg,
            '<span class="xb-join">Rejoindre</span>',
            '<span class="xb-count" hidden><b></b><span class="xb-long"> en ligne</span> <span class="xb-dot"></span></span>',
            '</a></nav>'
        ].join('');
        document.body.insertAdjacentHTML('afterbegin', html);

        var a = document.querySelector('#xbar .xb-discord');
        if (!a || !a.dataset.guild) return;
        var run = function () {
            fetch('https://fallout-maps.com/discord_count.php?g=' + encodeURIComponent(a.dataset.guild))
                .then(function (r) { return r.ok ? r.json() : null; })
                .then(function (j) {
                    if (j && typeof j.presence_count === 'number') {
                        var c = a.querySelector('.xb-count');
                        c.querySelector('b').textContent = j.presence_count;
                        c.hidden = false;
                    }
                })
                .catch(function () {});
        };
        (window.requestIdleCallback || function (cb) { setTimeout(cb, 0); })(run);
    }
    if (document.body) { mount(); } else { document.addEventListener('DOMContentLoaded', mount); }
})();

/* ######################################################################## */
/* ### IMAGEMAPEDIT                                                     ### */
/* ### ---------------------------------------------------------------- ### */
/* ### Description: permet de connaître les coordonnées d'une image.    ### */
/* ###              utile pour imagemap                                 ### */
/* ######################################################################## */

if (mw.config.get('wgNamespaceNumber')==6 && mw.config.get('wgAction')=='view') {
	mw.loader.load('//tools.wmflabs.org/imagemapedit/ime.js');
}
/* Tout code JavaScript placé ici sera chargé avec les pages accédées par les utilisateurs de l’habillage Vector */

// Ajout d'une icone devant les liens interlangues.
$(function() {

    // Icône pour EN
    $('li.interwiki-en > .interlanguage-link-target')
        .prepend('<img style="margin-right:5px;" src="https://images.fallout.wiki/3/37/Wiki.webp" width="25" height="25">');

    // Icône pour DE
    $('li.interwiki-de > .interlanguage-link-target')
        .prepend('<img style="margin-right:5px;" src="https://vaultpedia.de/images/b/b7/Fallout-Wiki_Icon.png" width="25" height="25">');

});