MediaWiki:Common.js: Difference between revisions

From AoP Wiki
No edit summary
No edit summary
Line 16: Line 16:
     document.getElementById('bleedResistance').innerHTML =
     document.getElementById('bleedResistance').innerHTML =
       '<p>Bleed Resistance Calculator:</p>' +
       '<p>Bleed Resistance Calculator:</p>' +
       'Strength: <input id="st" type="number"><br>' +
       'Strength: <input id="st" type="number" style="width: 20px"><br>' +
       'Endurance: <input id="en" type="number" style="width: 130px"><br>' +
       'Endurance: <input id="en" type="number" style="width: 20px"><br>' +
       'Agility: <input id="ag" type="number" style="width: 130px"><br>' +
       'Agility: <input id="ag" type="number" style="width: 20px"><br>' +
       'Luck: <input id="lk" type="number" style="width: 130px"><br>' +
       'Luck: <input id="lk" type="number" style="width: 20px"><br>' +
       '<button type="button" onclick="bleedResistance()">Submit</button>' +
       '<button type="button" onclick="bleedResistance()">Submit</button>' +
       '<p>Bleed Resistance: <a id="bleedRes"></a></p>' +
       '<p>Bleed Resistance: <a id="bleedRes"></a></p>' +

Revision as of 13:39, 18 October 2023

/* Any JavaScript here will be loaded for all users on every page load. */
function bleedResistance() {
  var st = Number(document.getElementById("st").value);
  var en = Number(document.getElementById("en").value);
  var ag = Number(document.getElementById("ag").value);
  var lk = Number(document.getElementById("lk").value);
  var bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2);
  bleedRes = Math.floor((((21 - lk)*lk)/2 - 15 + ag + 2*en + 2*st) / 2);
  var bleedDmg = Math.floor((1.0 - Math.pow(2.0,-1.0/Math.max(1.0,bleedRes/5.0)))*100);
  document.getElementById("bleedRes").innerHTML = bleedRes;
  document.getElementById("bleedDmg").innerHTML = bleedDmg;
}

$(function () {
  if ($('#bleedResistance').length) {
    document.getElementById('bleedResistance').innerHTML =
      '<p>Bleed Resistance Calculator:</p>' +
      'Strength: <input id="st" type="number" style="width: 20px"><br>' +
      'Endurance: <input id="en" type="number" style="width: 20px"><br>' +
      'Agility: <input id="ag" type="number" style="width: 20px"><br>' +
      'Luck: <input id="lk" type="number" style="width: 20px"><br>' +
      '<button type="button" onclick="bleedResistance()">Submit</button>' +
      '<p>Bleed Resistance: <a id="bleedRes"></a></p>' +
      '<p>% of bleed into damage per second: <a id="bleedDmg"></a></p>';
  }
});