Widget:Calculator/Magic/Aurum: Difference between revisions

From HighSpell Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:
     const majorEach = Math.round(itemPrice * 0.5);
     const majorEach = Math.round(itemPrice * 0.5);


     // Profit after scroll cost × quantity
     // Total values
     const minorTotal = Math.round((minorEach - scrollPrice) * quantity);
     const minorTotal = Math.round((minorEach - scrollPrice) * quantity);
     const majorTotal = Math.round((majorEach - (scrollPrice * 3)) * quantity);
     const majorTotal = Math.round((majorEach - (scrollPrice * 3)) * quantity);


     // Helper to apply value and negative styling
     // Helper: wrap in red span if value < 0
     function set(cell, value) {
     function wrapValue(value) {
       cell.textContent = value;
       return value < 0
      cell.style.color = value < 0 ? '#ee4231 !important' : '';
        ? `<span style="color: #ee4231">${value}</span>`
        : `${value}`;
     }
     }


     set(row.querySelector('.aurumMinorEach'), minorEach);
     row.querySelector('.aurumMinorEach').innerHTML = wrapValue(minorEach);
     set(row.querySelector('.aurumMajorEach'), majorEach);
     row.querySelector('.aurumMajorEach').innerHTML = wrapValue(majorEach);
     set(row.querySelector('.aurumMinorTotal'), minorTotal);
     row.querySelector('.aurumMinorTotal').innerHTML = wrapValue(minorTotal);
     set(row.querySelector('.aurumMajorTotal'), majorTotal);
     row.querySelector('.aurumMajorTotal').innerHTML = wrapValue(majorTotal);
   });
   });
}
}
Line 37: Line 38:
document.getElementById('scrollPrice').addEventListener('input', calculateProfits);
document.getElementById('scrollPrice').addEventListener('input', calculateProfits);
document.getElementById('quantity').addEventListener('input', calculateProfits);
document.getElementById('quantity').addEventListener('input', calculateProfits);
document.addEventListener('DOMContentLoaded', calculateProfits);
document.addEventListener('DOMContentLoaded', calculateProfits);
</script>
</script>
</html>
</html>

Revision as of 14:23, 26 June 2025

Scroll Price:
Quantity: