Difference between revisions of "MediaWiki:Common.js"

From Dungeon Defenders 2 Wiki
Jump to: navigation, search
Line 2: Line 2:
  
 
/* Replaces the word "gems" with the gem icon in texts where gem costs are mentioned */
 
/* Replaces the word "gems" with the gem icon in texts where gem costs are mentioned */
Array.from(document.getElementsByClassName('gem-cost-included')).forEach(element => {
+
[...document.getElementsByClassName('gem-cost-included')].forEach(function (element) {
 
     element.textContent = element.textContent.replace(/gems\s*?(\d+)|(\d+)\s*?gems/g, '[[File:Gem Icon.png|18px]] $1$2')
 
     element.textContent = element.textContent.replace(/gems\s*?(\d+)|(\d+)\s*?gems/g, '[[File:Gem Icon.png|18px]] $1$2')
 
})
 
})

Revision as of 23:27, 14 February 2023

/* Any JavaScript here will be loaded for all users on every page load. */

/* Replaces the word "gems" with the gem icon in texts where gem costs are mentioned */
[...document.getElementsByClassName('gem-cost-included')].forEach(function (element) {
    element.textContent = element.textContent.replace(/gems\s*?(\d+)|(\d+)\s*?gems/g, '[[File:Gem Icon.png|18px]] $1$2')
})