Widget:Calculator/Magic/Aurum: Difference between revisions
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); | ||
// | // 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 | // Helper: wrap in red span if value < 0 | ||
function | function wrapValue(value) { | ||
return value < 0 | |||
? `<span style="color: #ee4231">${value}</span>` | |||
: `${value}`; | |||
} | } | ||
row.querySelector('.aurumMinorEach').innerHTML = wrapValue(minorEach); | |||
row.querySelector('.aurumMajorEach').innerHTML = wrapValue(majorEach); | |||
row.querySelector('.aurumMinorTotal').innerHTML = wrapValue(minorTotal); | |||
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