MediaWiki:Common.js: Unterschied zwischen den Versionen

Aus GreenWay2 WIKI
Zur Navigation springen Zur Suche springen
(Item/Monster-Bilder automatisch laden)
 
(mw.hook fuer Bilder)
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');
             var img = document.createElement('img');
         if (vnum) {
            img.src = 'https://greenway2.de/wiki/images/items/' + vnum + '.png';
             var imgUrl = 'https://greenway2.de/wiki/images/items/' + vnum + '.png';
             img.width = 64;
             $this.html('<img src="' + imgUrl + '" width="64" height="64" alt="Item ' + vnum + '" onerror="this.style.display=\'none\'">');
            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 img = document.createElement('img');
         if (vnum) {
            img.src = 'https://greenway2.de/wiki/images/monsters/' + vnum + '.png';
             var imgUrl = 'https://greenway2.de/wiki/images/monsters/' + vnum + '.png';
             img.width = 64;
             $this.html('<img src="' + imgUrl + '" width="64" height="64" alt="Monster ' + vnum + '" onerror="this.style.display=\'none\'">');
            img.height = 64;
            img.alt = 'Monster ' + vnum;
            img.onerror = function() { this.style.display = 'none'; };
            $(this).append(img);
         }
         }
     });
     });
});
});

Version vom 20. Februar 2026, 23:29 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') {
            var img = document.createElement('img');
            img.src = 'https://greenway2.de/wiki/images/items/' + vnum + '.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 img = document.createElement('img');
            img.src = 'https://greenway2.de/wiki/images/monsters/' + vnum + '.png';
            img.width = 64;
            img.height = 64;
            img.alt = 'Monster ' + vnum;
            img.onerror = function() { this.style.display = 'none'; };
            $(this).append(img);
        }
    });
});