MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Wiki The-West DE
Zur Navigation springen
KKeine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(31 dazwischenliegende Versionen von 3 Benutzern werden nicht angezeigt)
Zeile 1: Zeile 1:
/* Das folgende JavaScript wird für alle Benutzer geladen. */
/* Das folgende JavaScript wird für alle Benutzer geladen. */


document.write("<script src='/index.php?title=Global.js&action=raw&smaxage=0&ctype=text/javascript' type='text/javascript'></script>");
//Popup item
if ($('.item_container').length || $('.set_icon').length) {
  $('.item_container').each(function() {
    var url=$(this).attr('data-url');
    $(this).append('<img src="//westde.innogamescdn.com/images/items/'+url+(url.indexOf('.png')<0?'.png':'')+'">');
  });
  $.getJSON("/wiki/Evsets.json?action=raw",function(e){evsets=e});
  $.getScript("/wiki/Popup.js?action=raw");
}


importScript_ = importScript;
//set favicon
$('head').append('<link rel="icon" href="https://www.google.com/s2/favicons?sz=64&domain=the-west.net" type="image/x-icon">');


//Popup item
mw.config.set('tableSorterCollation',{'ä':'ae','ö':'oe','ß':'ss','ü':'ue'});
$(document).mousemove(function(e) {
    if ($('.popup_window:visible').length !== 0) {
        var width;
        var height;
        var parent_left = $('.item_container:hover').offset().left;
        var parent_top = $('.item_container:hover').offset().top;
        var w = e.pageX;
        if (e.clientX < ($(window).width()) / 2) {
            width = w + 20 - parent_left;
        } else {
            width = w - 20 - $('.popup_window:visible').outerWidth() - parent_left;
        }
        var h = e.pageY;
        var h2 = $('.popup_window:visible').outerHeight();
        var h3 = $(window).height();
        if (e.clientY < (h3 / 2)) {
            height = h + 20 - parent_top;
            if (e.clientY + h2 + 10 > h3) height = h - e.clientY - parent_top + h3 - h2 + 10;
        } else {
            height = h - h2 - parent_top;
            if (e.clientY - h2 < 10) height = h - e.clientY - parent_top + 10;
        }
        $('.popup_window:visible').css({
            top: height,
            left: width
        });
    }
});


//Input level
//craft products count
if ($("#input_level").length == 1) {
if ($('.input_calc.craft_nb').length) {
    var input_level = $('<input type="number" class="west" placeholder="Stufe" min="0" max="150">').bind("propertychange keyup input paste", function() {
  $('<input type="number" class="west" style="width:80px;" id="craft_nb" value="1" max="9000">').appendTo($('.craft_nb'));
        if (this.value > 150) {
  var multiplierValue = 1;
            this.value = 150;
  var currentAmountsArray = [];
        } else if (this.value < 0) {
  $('.number').each(function (index) {
            this.value = 0;
    currentAmountsArray[index] = parseInt($(this).text());
        }
  });
        $(".calc").each(function() {
  $("#craft_nb").on('input', function () {
            if (input_level.val() == 0) {
    this.value > 9000
                $(this).html(this.id);
    ? (this.value = 9000)
                 $('.per_level_off').addClass('per_level').removeClass('per_level_off');
    : this.value < 0 && (this.value = 0);
    multiplierValue = this.value;
    $('.number').each(function (index) {
      $(this).text(currentAmountsArray[index] * multiplierValue);
    });
    $('.craft_extra').show();
    $('.craft_extra .item_container').each(function () {
      $(this).children().addClass('OverlayItem');
    });
  });
}
//craft live search - thanks to Criminus from RO
if ($('.input_calc.craft_search').length)
  $('<input type="text" class="west" style="width:180px;" id="craft_search" placeholder="Suche">').appendTo($('.craft_search'));
$("#craft_search").on("input", function() {
    var value = $(this).val();
    $("table tr").each(function(index) {
        if (index !== 0) {
            $row = $(this);
            var id = $.map($row.find('td .item_container'), function(element) {
                 return $(element).attr("data-popup")
            }).join(' ');
            if (id.toLowerCase().indexOf(value.toLowerCase()) < 0) {
                $row.hide();
             } else {
             } else {
                 $(this).html(Math.ceil(Number(this.id) * input_level.val()));
                 $row.show();
                $('.per_level').addClass('per_level_off').removeClass('per_level');
             }
             }
        });
    }).appendTo($("#input_level"));
}
//Search
if ($("#input_search").length == 1) {
    //Add :containsCI selector (contains case insensitive)
    $.extend($.expr[":"], {
        "containsCI": function(elem, i, match, array) {
            return (elem.textContent || elem.innerText || "").toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
         }
         }
     });
     });
    var input_search = $('<input type="search" class="west" placeholder="Search">').bind("propertychange keyup input paste", function() {
});
        if (this.value == '') {
 
            $('.item_container').show();
//craft spoilers
        } else {
var cTogg = $('div[class^="mw-customtoggle-"]');
            $('.item_container').hide();
if (cTogg.length)
            $('.item_container:containsCI("' + this.value + '")').show();
  cTogg.click(function(){$(this).toggleClass('toggle-expanded')})
        }
 
    }).appendTo($("#input_search"));
//Calculate box
}
if ($('.calculate_box').length)
//Switch weapons
  $.getScript('/wiki/Calculate.js?action=raw');
if ($("#switch").length == 1) {
 
    $("#fire").hide();
//File overview when not logged in
    $("#switch").on("click", function() {
if (location.pathname.startsWith("/wiki/Datei:") && $("#ca-viewsource").length)
        $('#melee, #fire').toggle()
  $("#content").addClass("file_page");
    });
}

Aktuelle Version vom 25. November 2023, 23:35 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */

//Popup item
if ($('.item_container').length || $('.set_icon').length) {
  $('.item_container').each(function() {
    var url=$(this).attr('data-url');
    $(this).append('<img src="//westde.innogamescdn.com/images/items/'+url+(url.indexOf('.png')<0?'.png':'')+'">');
  });
  $.getJSON("/wiki/Evsets.json?action=raw",function(e){evsets=e});
  $.getScript("/wiki/Popup.js?action=raw");
}

//set favicon
$('head').append('<link rel="icon" href="https://www.google.com/s2/favicons?sz=64&domain=the-west.net" type="image/x-icon">');

mw.config.set('tableSorterCollation',{'ä':'ae','ö':'oe','ß':'ss','ü':'ue'});

//craft products count
if ($('.input_calc.craft_nb').length) {
  $('<input type="number" class="west" style="width:80px;" id="craft_nb" value="1" max="9000">').appendTo($('.craft_nb'));
  var multiplierValue = 1;
  var currentAmountsArray = [];
  $('.number').each(function (index) {
    currentAmountsArray[index] = parseInt($(this).text());
  });
  $("#craft_nb").on('input', function () {
    this.value > 9000
     ? (this.value = 9000)
     : this.value < 0 && (this.value = 0);
    multiplierValue = this.value;
    $('.number').each(function (index) {
      $(this).text(currentAmountsArray[index] * multiplierValue);
    });
    $('.craft_extra').show();
    $('.craft_extra .item_container').each(function () {
      $(this).children().addClass('OverlayItem');
    });
  });
}
//craft live search - thanks to Criminus from RO
if ($('.input_calc.craft_search').length)
  $('<input type="text" class="west" style="width:180px;" id="craft_search" placeholder="Suche">').appendTo($('.craft_search'));
$("#craft_search").on("input", function() {
    var value = $(this).val();
    $("table tr").each(function(index) {
        if (index !== 0) {
            $row = $(this);
            var id = $.map($row.find('td .item_container'), function(element) {
                return $(element).attr("data-popup")
            }).join(' ');
            if (id.toLowerCase().indexOf(value.toLowerCase()) < 0) {
                $row.hide();
            } else {
                $row.show();
            }
        }
    });
});

//craft spoilers
var cTogg =  $('div[class^="mw-customtoggle-"]');
if (cTogg.length)
  cTogg.click(function(){$(this).toggleClass('toggle-expanded')})

//Calculate box
if ($('.calculate_box').length)
  $.getScript('/wiki/Calculate.js?action=raw');

//File overview when not logged in
if (location.pathname.startsWith("/wiki/Datei:") && $("#ca-viewsource").length)
  $("#content").addClass("file_page");