Widget:Calculator/Magic/Aurum: Difference between revisions

From HighSpell Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
   <label>
   <label>
     <span><a href="/w/Alchemy_Scroll" title="Alchemy Scroll">Alchemy Scroll</a> Price:</span>
     <span><a href="/w/Alchemy_Scroll" title="Alchemy Scroll">Alchemy Scroll</a> Price:</span>
     <input type="number" id="scrollPrice" value="350">
     <input type="number" id="scrollPrice" value="350" min="1" max="1000">
   </label>
   </label>
   <label>
   <label>
     <span>Quantity:</span>
     <span>Quantity:</span>
     <input type="number" id="quantity" value="1">
     <input type="number" id="quantity" value="1" min="1" max="99999">
   </label>
   </label>
</form>
</form>
Line 14: Line 14:
   const coinIcon = ' <span class="noviewer" typeof="mw:File"><span><img src="/w/images/thumb/9/9a/Coins_icon.png/16px-Coins_icon.png" decoding="async" width="16" height="16" class="mw-file-element" srcset="/w/images/thumb/9/9a/Coins_icon.png/24px-Coins_icon.png 1.5x, /w/images/9/9a/Coins_icon.png 2x"></span></span>';
   const coinIcon = ' <span class="noviewer" typeof="mw:File"><span><img src="/w/images/thumb/9/9a/Coins_icon.png/16px-Coins_icon.png" decoding="async" width="16" height="16" class="mw-file-element" srcset="/w/images/thumb/9/9a/Coins_icon.png/24px-Coins_icon.png 1.5x, /w/images/9/9a/Coins_icon.png 2x"></span></span>';


   // Get & sanitize scroll price
   // Scroll Price
   let scrollPrice = parseFloat(document.getElementById('scrollPrice').value);
   const scrollInput = document.getElementById('scrollPrice');
   if (isNaN(scrollPrice) || scrollPrice < 0) scrollPrice = 1;
  let scrollPrice = parseFloat(scrollInput.value);
   if (isNaN(scrollPrice) || scrollPrice < 0) {
    scrollPrice = 1;
    scrollInput.value = 1;
  }


   // Get & sanitize quantity
   // Quantity
   let quantity = parseInt(document.getElementById('quantity').value);
   const quantityInput = document.getElementById('quantity');
   if (isNaN(quantity) || quantity < 1) quantity = 1;
  let quantity = parseInt(quantityInput.value);
   if (isNaN(quantity) || quantity < 1) {
    quantity = 1;
    quantityInput.value = 1;
  }


   document.querySelectorAll('#aurum-table tbody tr').forEach(row => {
   document.querySelectorAll('#aurum-table tbody tr').forEach(row => {
Line 27: Line 35:


     const aurumMinor = isNaN(aurumMinorValue) ? 0 : aurumMinorValue - scrollPrice;
     const aurumMinor = isNaN(aurumMinorValue) ? 0 : aurumMinorValue - scrollPrice;
     const aurumMajor = isNaN(aurumMajorValue) ? 0 : aurumMajorValue - scrollPrice * 3;
     const aurumMajor = isNaN(aurumMajorValue) ? 0 : aurumMajorValue - scrollPrice;


     const minorTotal = aurumMinor * quantity;
     const minorTotal = aurumMinor * quantity;

Latest revision as of 15:57, 26 June 2025