Difference between revisions of "MediaWiki:Common.js"
From Dungeon Defenders 2 Wiki
(Loosening up the regex to match currency keywords more freely) |
(Having the images link to the page for each currency instead of linking to the icon image page) |
||
Line 3: | Line 3: | ||
/* Replaces currency keywords (gold, gems, defender medals) with their icon in texts which include currency costs */ | /* Replaces currency keywords (gold, gems, defender medals) with their icon in texts which include currency costs */ | ||
Array.from(document.getElementsByClassName('currency-included')).forEach(function (element) { | Array.from(document.getElementsByClassName('currency-included')).forEach(function (element) { | ||
− | element.innerHTML = element.innerHTML.replace(/gems?(\d.+)|(\d.+)gems?/gi, '<a href="/wiki/ | + | element.innerHTML = element.innerHTML.replace(/gems?(\d.+)|(\d.+)gems?/gi, '<a href="/wiki/Gems" class="image"><img alt="Gem Icon.png" src="/images/8/8d/Gem_Icon.png" width="18"></a> $1$2') |
− | element.innerHTML = element.innerHTML.replace(/gold(\d.+)|(\d.+)gold/gi, '<a href="/wiki/ | + | element.innerHTML = element.innerHTML.replace(/gold(\d.+)|(\d.+)gold/gi, '<a href="/wiki/Gold" class="image"><img alt="Gold Icon.png" src="/images/2/26/Gold_Icon.png" width="18"></a> $1$2') |
− | element.innerHTML = element.innerHTML.replace(/defender medals?(\d.+)|(\d.+)defender medals?/gi, '<a href="/wiki/ | + | element.innerHTML = element.innerHTML.replace(/defender medals?(\d.+)|(\d.+)defender medals?/gi, '<a href="/wiki/Defender_Medals" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2') |
}) | }) |
Revision as of 15:43, 27 October 2023
/* Any JavaScript here will be loaded for all users on every page load. */ /* Replaces currency keywords (gold, gems, defender medals) with their icon in texts which include currency costs */ Array.from(document.getElementsByClassName('currency-included')).forEach(function (element) { element.innerHTML = element.innerHTML.replace(/gems?(\d.+)|(\d.+)gems?/gi, '<a href="/wiki/Gems" class="image"><img alt="Gem Icon.png" src="/images/8/8d/Gem_Icon.png" width="18"></a> $1$2') element.innerHTML = element.innerHTML.replace(/gold(\d.+)|(\d.+)gold/gi, '<a href="/wiki/Gold" class="image"><img alt="Gold Icon.png" src="/images/2/26/Gold_Icon.png" width="18"></a> $1$2') element.innerHTML = element.innerHTML.replace(/defender medals?(\d.+)|(\d.+)defender medals?/gi, '<a href="/wiki/Defender_Medals" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2') })