Widget:Calculator/Magic/Aurum: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 13: | Line 13: | ||
if (isNaN(itemPrice)) return; | if (isNaN(itemPrice)) return; | ||
// Correct logic | // Correct value logic | ||
const minorValue = itemPrice * 0.0375; | const minorValue = itemPrice * 0.0375; | ||
const majorValue = itemPrice * 0.5; | const majorValue = itemPrice * 0.5; | ||
const minorProfit = minorValue - scrollPrice; | const minorProfit = Math.round(minorValue - scrollPrice); | ||
const majorProfit = majorValue - | const majorProfit = Math.round(majorValue - scrollPrice); | ||
const totalProfit = majorProfit * quantity; | const totalProfit = Math.round(majorProfit * quantity); | ||
// | // Helper function to apply red color for negatives | ||
row.querySelector('.minorProfit') | function formatProfit(cell, value) { | ||
row.querySelector('.majorProfit') | cell.textContent = value; | ||
row.querySelector('.totalProfit') | cell.style.color = value < 0 ? '#ee4231' : ''; | ||
} | |||
formatProfit(row.querySelector('.minorProfit'), minorProfit); | |||
formatProfit(row.querySelector('.majorProfit'), majorProfit); | |||
formatProfit(row.querySelector('.totalProfit'), totalProfit); | |||
}); | }); | ||
} | } |
Revision as of 14:06, 26 June 2025