MediaWiki:Common.js: Διαφορά μεταξύ των αναθεωρήσεων

Από Wiki The-West GR
Jump to navigation
Χωρίς σύνοψη επεξεργασίας
Χωρίς σύνοψη επεξεργασίας
Γραμμή 146: Γραμμή 146:
         }, oPui.init();
         }, oPui.init();
});
});
$("div").addClass("smooth-scroll-wrapper");
const body = document.body,
                scrollWrap = document.getElementsByClassName("smooth-scroll-wrapper")[1],
                height = scrollWrap.getBoundingClientRect().height - 1,
                speed = 0.04;
            var offset = 0;
            body.style.height = Math.floor(height) + "px";
            function smoothScroll() {
                offset += (window.pageYOffset - offset) * speed;
                var scroll = "translateY(-" + offset + "px) translateZ(0)";
                scrollWrap.style.transform = scroll;
                callScroll = requestAnimationFrame(smoothScroll);
            }
            smoothScroll();

Αναθεώρηση της 15:08, 18 Απριλίου 2022

/* Any JavaScript here will be loaded for all users on every page load. */
$('.tbbox-logo').wrap('<a href="/wiki/Main_Page"></a>');
if ($('.item_container').length!==0) {
    $('.item_container').each(function() {
        $(this).append('<img src="https://westgr.innogamescdn.com/images/items/' + $(this).attr('data-url') + '">');
    });
    $.getScript("https://wiki.the-west.gr/wiki/Popup.js?action=raw");
}

$(window).scroll(function() {
    if ($(this).scrollTop() > 100) {
        $('#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;
});


if ($('#navbar').length !== 0) {
    $('#navbar a').removeAttr("title");
}
// 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="Επίπεδο χαρακτήρα" 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="Επίπεδο μονομαχίας" 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('Τρέχουσα εμπειρία μονομαχίας: <b><i>' + minXp + '</b></i> - <b><i>' + maxXp + '</b></i><br/>Επίπεδο μονομαχίας μετά τη λήψη του φίλτρου: <b><i>' + minLvl + (maxLvl > minLvl ? '</b></i> - <b><i>' + maxLvl : ''));
    }
  }
}
$(document).ready(function() {
    $('.clignote a').removeAttr('title');
    $('[title]').hover(function(et){
        var customtitle = $(this).attr('title');
        $(this).attr('custom-title', customtitle);
        $(this).removeAttr('title');
        
    });
        oPui = {

            toolup: {
                content: "",
                delay: 200,
                active: !1,
                show: function(t) {
                    oPui.toolup.content =  oPui.toolup.createPopup($(t).attr("custom-title")), oPui.toolup.active = !0, oPui.toolup.setTimeout(), oPui.toolup.getContainer().html(oPui.toolup.content)
                },
                hide: function() {
                    oPui.toolup.getEl().css({
                        display: "none",
                        top: 0,
                        left: 0
                    }), oPui.toolup.active = !1, oPui.toolup.clearTimeout()
                },
                setTimeout: function() {
                    oPui.toolup.clearTimeout(), oPui.toolup.timer = window.setTimeout(function() {
                        oPui.toolup.getEl().css("display", "block")
                    }, oPui.toolup.delay)
                },
                clearTimeout: function() {
                    oPui.toolup.timer && window.clearTimeout(oPui.toolup.timer)
                },
                getEl: function() {
                    return $(".overlay-popup")
                },
                getContainer: function() {
                    return $(".overlay-contents")
                },
                createPopup: function (t) {
                    var s = '<div class="oPtitle">'+t+'</div>';
                    return s;
                },
                setPosition: function(t) {
                    var e, i, a = $(window).width(),
                        s = $(window).height(),
                        p = oPui.toolup.getEl().outerWidth(),
                        n = oPui.toolup.getEl().outerHeight(),
                        o = t.clientX,
                        l = t.clientY;
                    i = o + p + 20 > a ? o - p - 20 + (t.pageX - t.clientX) : o + 20 + (t.pageX - t.clientX), e = l + n + 20 > s ? s - n + (t.pageY - t.clientY) : l + 20 + (t.pageY - t.clientY), oPui.toolup.getEl().css({
                        top: e,
                        left: i
                    })
                },
                init: function() {
                    $("body").append('<div class="overlay-popup"><div class="popup_front"><div class="tw_bg_tl"></div><div class="tw_bg_tr"></div><div class="tw_bg_bl"></div><div class="tw_bg_br"></div></div><div class="overlay-contents"></div></div>'), $(document).on("mouseenter", "[custom-title]", function(t) {
                        oPui.toolup.show(this), oPui.toolup.setPosition(t)
                    }), $(document).on("mouseleave", "[custom-title]", function() {
                        oPui.toolup.hide()
                    }), $(document).on("mousemove", "[custom-title]", function(t) {
                        oPui.toolup.setPosition(t)
                    }), $(".item_level").mousedown(function(t) {
                        t.preventDefault()
                    })
                }
            },
            init: function() {
                oPui.toolup.init()
            }
        }, oPui.init();
});