Difference between revisions of "MediaWiki:Common.js"

From Dungeon Defenders 2 Wiki
Jump to: navigation, search
m (test)
m
Line 7: Line 7:
 
     element.innerHTML = element.innerHTML.replace(/defender medals?\s*?([\d,]+)|([\d,]+)\s*?defender medals?/gi, '<a href="/wiki/File:Defender_Medal_Icon.png" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2')
 
     element.innerHTML = element.innerHTML.replace(/defender medals?\s*?([\d,]+)|([\d,]+)\s*?defender medals?/gi, '<a href="/wiki/File:Defender_Medal_Icon.png" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2')
 
})
 
})
 
window.tooltips_config = {
 
    waitForImages: true,
 
    noCSS: true,
 
};
 
  
 
window.tooltips_list = [
 
window.tooltips_list = [
 
     {
 
     {
         classname: 'unit-tooltip',
+
         classname: 'custom-tooltip-parse',
        parse: '{'+'{<#unit#>|rank=<#rank#>|size=<#size#>|upgrade=<#upgrade#>|upgrades=<#upgrades#>|upgraded=<#upgraded#>|race=<#race#>|tt=<#tt#>|show=no}}',
+
         parse: '{{:<#tooltip#>}}',
        //onShow: function() { if ((this).getElementsByClassName('template-unit')[0]) {Unit = (this).getElementsByClassName('template-unit')[0]; console.info("Onshow var =",Unit); processunit (Unit);} },
 
    }, {
 
        classname: 'spell-tooltip',
 
        parse: '{'+'{<#spell#>|magnitude=<#magnitude#>|tt=<#tt#>}}',
 
    }, {
 
        classname: 'ability-tooltip',
 
        parse: '{'+'{<#ability#>|<#magnitude#>|duration=<#duration#>|tt=<#tt#>|show=no}}',
 
    }, {
 
        classname: 'structure-tooltip',
 
        parse: '{'+'{<#structure#>}}',
 
    }, {
 
        classname: 'building-tooltip',
 
        parse: '{'+'{<#building#>}}',
 
    }, {
 
        classname: 'damageability-tooltip',
 
         parse: '{'+'{<#ability#>|physical=<#physical#>|spirit=<#spirit#>|blight=<#blight#>|fire=<#fire#>|frost=<#frost#>|shock=<#shock#>|tt=<#tt#>|show=no}}',
 
        onShow: function(handle) { a = handle; writeloc = (this).getElementsByClassName('writedamage')[0]; damagesource = a.parentElement; unitloc = damagesource.parentElement.parentElement; damageCalc (writeloc, damagesource, unitloc); },
 
    }, {
 
        classname: 'protection-tooltip',
 
        parse: '{'+'{Prottable|<#magnitude#>|<#element#>}}',
 
    }, {
 
        classname: 'weakness-tooltip',
 
        parse: '{'+'{Weaktable|<#magnitude#>|<#element#>}}',
 
 
     }
 
     }
 
];
 
];

Revision as of 09:58, 13 April 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?\s*?([\d,]+)|([\d,]+)\s*?gems?/gi, '<a href="/wiki/File:Gem_Icon.png" 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\s*?([\d,]+)|([\d,]+)\s*?gold/gi, '<a href="/wiki/File:Gold_Icon.png" 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?\s*?([\d,]+)|([\d,]+)\s*?defender medals?/gi, '<a href="/wiki/File:Defender_Medal_Icon.png" class="image"><img alt="Defender Medal Icon.png" src="/images/a/a7/Defender_Medal_Icon.png" width="18"></a> $1$2')
})

window.tooltips_list = [
    {
        classname: 'custom-tooltip-parse',
        parse: '{{:<#tooltip#>}}',
    }
];