MediaWiki:Common.js

De Wiki The-West FR
Aller à la navigation

Note : après avoir publié vos modifications, il se peut que vous deviez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

  • Firefox / Safari : maintenez la touche Maj (Shift) en cliquant sur le bouton Actualiser ou appuyez sur Ctrl + F5 ou Ctrl + R (⌘ + R sur un Mac).
  • Google Chrome : appuyez sur Ctrl + Maj + R (⌘ + Shift + R sur un Mac).
  • Internet Explorer / Edge : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl + F5.
  • Opera : appuyez sur Ctrl + F5.
// Reset to version 2 mai 2021 à 09:32‎ Hudra - .net changes removed

$('.tbbox-logo').wrap('<a href="/wiki/Accueil"></a>');
if ($('.item_container').length!==0) {
    $.getScript("https://wiki.the-west.fr/wiki/Popup.js?action=raw");
    $('.item_container').each(function() {
        $(this).append('<img src="https://westzz.innogamescdn.com/images/items/' + $(this).attr('data-url') + ($(this).attr('data-cache')?"?"+$(this).attr('data-cache'):"")+'">');
    });
} 
$('#navbar a, .set_icon a').removeAttr("title");
$(window).scroll(function() {
    if ($(this).scrollTop() > $("#right_menu").offset().top + $('#right_menu').height() - $( window ).height() + 120) {
        $('#back-top').fadeIn();
    } else {
        $('#back-top').fadeOut();
    }
});
// Scroll body to top on click
$('#back-top a').click(function() {
    $('body,html').animate({
        scrollTop: 0
    }, 800);
    return false;
});
// Embed youtube videos
if ($('.youtube_video').length !== 0) {
    $('.youtube_video').each(function() {
        $(this).html('<iframe width="100%" height="100%" src="https://www.youtube.com/embed/' + $(this).attr('data-id') + '?cc_load_policy=1&cc_lang_pref=' + $(this).attr('data-subtitles') + '" frameborder="0" allowfullscreen></iframe>');
    });
}
//Configuration du tri des diacritique dans les tables de class "sortable"
mw.config.set( 'tableSorterCollation', {'à':'a', 'â':'a', 'æ':'ae', 'é':'e', 'è':'e', 'ê':'e', 'î':'i', 'ï':'i', 'ô':'o', 'œ':'oe', 'û':'u', 'ç':'c',  } );
if ($('#calcLvlLoss').length !== 0) {
  var context = $('#calcLvlLoss');
  var input_character_level = $('<input type="number" style="width:150px;" class="west" placeholder="Niveau" min="0" max="150">').bind("propertychange keyup input paste", function() {
    if (this.value > 150) {
      this.value = 150;
    } else if (this.value < 0) {
      this.value = 0;
    }
    calcLvlLoss();
  }).appendTo(context.find(".character_level"));
  var input_duel_level = $('<input type="number" style="width:150px;" class="west" placeholder="Niveau de duel" min="0" max="450">').bind("propertychange keyup input paste", function() {
    if (this.value > 450) {
      this.value = 450;
    } else if (this.value < 0) {
      this.value = 0;
    }
    calcLvlLoss();
  }).appendTo(context.find(".duel_level"));
  function calcLvlLoss() {
    var duel_lvl = parseInt(input_duel_level.val()),
      char_lvl = parseInt(input_character_level.val());
    if (isNaN(duel_lvl) || isNaN(char_lvl) || duel_lvl < char_lvl) {
      context.find('.result').html('');
    } else {
      var getXp = function(lvl) {
          return Math.ceil(Math.pow((lvl) / 0.1, 1 / 0.6));
        },
        getLvl = function(xp, perc) {
          return char_lvl + Math.floor(Math.pow(xp * (perc || 1), 0.6) * 0.1);
        };
      var minXp = getXp(duel_lvl - char_lvl),
        maxXp = duel_lvl === 450 ? '∞' : getXp(duel_lvl + 1 - char_lvl),
        minLvl = getLvl(minXp, 0.9),
        maxLvl = duel_lvl === 450 ? 450 : getLvl(maxXp, 0.9);
      context.find('.result').html('Expérience de duel actuelle : ' + minXp + ' - ' + maxXp + '<br/>Niveau de duel après avoir pris la potion : ' + minLvl + (maxLvl > minLvl ? ' - ' + maxLvl : ''));
    }
  }
}

//Navigation bar change
(function($) {
    $(document).ready(function() {
        var $navigationDummy = $("<div>", {
            id: "navigationDummy",
            html: ""
        });
        $navigationDummy.insertBefore("#mw-navigation");
        var elementToMove = $("#module-site-navigation").detach();
        elementToMove.appendTo($navigationDummy);
    });
})(jQuery);