MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus GreenWay2 WIKI
Zur Navigation springen Zur Suche springen
(Item/Monster-Bilder automatisch laden)
 
(VNUM mit fuehrenden Nullen (5 Stellen))
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 1: Zeile 1:
/* GreenWay2 Wiki - Item-Bilder laden */
/* GreenWay2 Wiki - Item/Monster-Bilder laden */
$(document).ready(function() {
mw.hook('wikipage.content').add(function($content) {
    // Item-Bilder von externem Pfad laden
     $content.find('.item-image').each(function() {
     $('.item-image').each(function() {
         var vnum = $(this).attr('data-vnum');
         var $this = $(this);
         if (vnum && vnum !== '0') {
        var vnum = $this.data('vnum');
            // VNUM auf 5 Stellen mit fuehrenden Nullen
         if (vnum) {
             var vnumPadded = ('00000' + vnum).slice(-5);
             var imgUrl = 'https://greenway2.de/wiki/images/items/' + vnum + '.png';
            var img = document.createElement('img');
             $this.html('<img src="' + imgUrl + '" width="64" height="64" alt="Item ' + vnum + '" onerror="this.style.display=\'none\'">');
            img.src = 'https://greenway2.de/wiki/images/items/' + vnumPadded + '.png';
             img.width = 64;
            img.height = 64;
            img.alt = 'Item ' + vnum;
            img.onerror = function() { this.style.display = 'none'; };
            $(this).append(img);
         }
         }
     });
     });


    // Monster-Bilder von externem Pfad laden
     $content.find('.monster-image').each(function() {
     $('.monster-image').each(function() {
         var vnum = $(this).attr('data-vnum');
         var $this = $(this);
         if (vnum && vnum !== '0') {
        var vnum = $this.data('vnum');
             var vnumPadded = ('00000' + vnum).slice(-5);
         if (vnum) {
            var img = document.createElement('img');
             var imgUrl = 'https://greenway2.de/wiki/images/monsters/' + vnum + '.png';
            img.src = 'https://greenway2.de/wiki/images/monsters/' + vnumPadded + '.png';
             $this.html('<img src="' + imgUrl + '" width="64" height="64" alt="Monster ' + vnum + '" onerror="this.style.display=\'none\'">');
             img.width = 64;
            img.height = 64;
            img.alt = 'Monster ' + vnum;
            img.onerror = function() { this.style.display = 'none'; };
            $(this).append(img);
         }
         }
     });
     });
});
});

Aktuelle Version vom 20. Februar 2026, 23:40 Uhr

/* GreenWay2 Wiki - Item/Monster-Bilder laden */
mw.hook('wikipage.content').add(function($content) {
    $content.find('.item-image').each(function() {
        var vnum = $(this).attr('data-vnum');
        if (vnum && vnum !== '0') {
            // VNUM auf 5 Stellen mit fuehrenden Nullen
            var vnumPadded = ('00000' + vnum).slice(-5);
            var img = document.createElement('img');
            img.src = 'https://greenway2.de/wiki/images/items/' + vnumPadded + '.png';
            img.width = 64;
            img.height = 64;
            img.alt = 'Item ' + vnum;
            img.onerror = function() { this.style.display = 'none'; };
            $(this).append(img);
        }
    });

    $content.find('.monster-image').each(function() {
        var vnum = $(this).attr('data-vnum');
        if (vnum && vnum !== '0') {
            var vnumPadded = ('00000' + vnum).slice(-5);
            var img = document.createElement('img');
            img.src = 'https://greenway2.de/wiki/images/monsters/' + vnumPadded + '.png';
            img.width = 64;
            img.height = 64;
            img.alt = 'Monster ' + vnum;
            img.onerror = function() { this.style.display = 'none'; };
            $(this).append(img);
        }
    });
});