MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus Wiki The-West DE
Zur Navigation springen
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 16: Zeile 16:
var id = $(this).attr('id');
var id = $(this).attr('id');
var phrase = $(this).text();
var phrase = $(this).text();
var newInput="<input type='number' name='input_nou' value='"+phrase+"' class='target' max='999' min='1' />";
var newInput="<input type='number' name='input_new' value='"+phrase+"' class='target' max='9000' min='' />";
$(this).replaceWith(newInput);
$(this).replaceWith(newInput);
});
});


$(document).on('keyup', 'input[name=input_nou]', function() {
$(document).on('keyup', 'input[name=input_new]', function () {
  var _this = $(this);
    this.value > 9000
  var min = parseInt(_this.attr('min')) || 1; // if min attribute is not defined, 1 is default
        ? (this.value = 9000)
  var max = parseInt(_this.attr('max')) || 100; // if max attribute is not defined, 100 is default
        : this.value < 0 && (this.value = 0);
  var val = parseInt(_this.val()) || (min - 1); // if input char is not a number the value will be (min - 1) so first condition will be true
  if (val < min)
    _this.val(min);
  if (val > max)
    _this.val(max);
});
});


Zeile 38: Zeile 33:
             currentAmountsArray[index] = parseInt($(this).text());
             currentAmountsArray[index] = parseInt($(this).text());
         });
         });
         if ($("input[name='input_nou']").length > 0) {
         if ($("input[name='input_new']").length > 0) {
             $("input[name='input_nou']").change(function() {
             $("input[name='input_new']").change(function() {
                 multiplierValue = $(this).val();
                 multiplierValue = $(this).val();
                 $('.number').each(function(index) {
                 $('.number').each(function(index) {
                     $(this).text(currentAmountsArray[index] * multiplierValue);
                     $(this).text(currentAmountsArray[index] * multiplierValue);
                 });
                 });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                });
             });
             });
             $("input[name='input_nou']").keyup(function() {
             $("input[name='input_new']").keyup(function() {
                 multiplierValue = $(this).val();
                 multiplierValue = $(this).val();
                 $('.number').each(function(index) {
                 $('.number').each(function(index) {
                     $(this).text(currentAmountsArray[index] * multiplierValue);
                     $(this).text(currentAmountsArray[index] * multiplierValue);
                });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                 });
                 });
             });
             });

Version vom 7. April 2022, 17:53 Uhr

/* Das folgende JavaScript wird für alle Benutzer geladen. */
$('.tbbox-logo').wrap('<a href="/"></a>');
//Popup item
if ($('.item_container').length+$('.set_icon').length>0) {
  $('.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.the-west.de/wiki/Evsets.json?action=raw",function(e){evsets=e});
  $.getScript("//wiki.the-west.de/wiki/Popup.js?action=raw");
}

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

$('.target_input p').each(function() {
	var id = $(this).attr('id');
	var phrase = $(this).text();
	var newInput="<input type='number' name='input_new' value='"+phrase+"' class='target' max='9000' min='' />";
	$(this).replaceWith(newInput);
});

$(document).on('keyup', 'input[name=input_new]', function () {
    this.value > 9000
        ? (this.value = 9000)
        : this.value < 0 && (this.value = 0);
});

(function($) {
    $(document).ready(function() {
        var multiplierValue = 1;
        var currentAmountsArray = [];
        $('.number').each(function(index) {
            currentAmountsArray[index] = parseInt($(this).text());
        });
        if ($("input[name='input_new']").length > 0) {
            $("input[name='input_new']").change(function() {
                multiplierValue = $(this).val();
                $('.number').each(function(index) {
                    $(this).text(currentAmountsArray[index] * multiplierValue);
                });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                });

            });
            $("input[name='input_new']").keyup(function() {
                multiplierValue = $(this).val();
                $('.number').each(function(index) {
                    $(this).text(currentAmountsArray[index] * multiplierValue);
                });
                $('.craft_extra').show();
                $('.craft_extra .item_container').each(function() {
                    $(this).children().addClass('OverlayItem');
                });
            });
        }
    });
})(jQuery);