Widget:Calculator/Magic/Aurum: Difference between revisions
Jump to navigation
Jump to search
Created page with "<html> <form oninput="profit.value = parseFloat(price.value) * parseFloat(quantity.value)"> Price: <input name="price" type="number" step="any"><br> Quantity: <input name="quantity" type="number" step="any"><br> Profit: <output name="profit"></output> </form> </html>" |
No edit summary |
||
Line 1: | Line 1: | ||
<html> | <html> | ||
<form | <form id="aurum-controls"> | ||
Price: <input | Scroll Price: <input type="number" id="scrollPrice" value="100"><br> | ||
Quantity: <input | Quantity: <input type="number" id="quantity" value="1"><br> | ||
</form> | </form> | ||
<table id="aurum-table" border="1"> | |||
<thead> | |||
<tr> | |||
<th>Item</th> | |||
<th>Buy Price</th> | |||
<th>Minor Profit</th> | |||
<th>Major Profit</th> | |||
<th>Total Profit (qty)</th> | |||
</tr> | |||
</thead> | |||
<tbody> | |||
<tr data-buyprice="500"> | |||
<td>Item A</td> | |||
<td>500</td> | |||
<td class="minorProfit"></td> | |||
<td class="majorProfit"></td> | |||
<td class="totalProfit"></td> | |||
</tr> | |||
<tr data-buyprice="1200"> | |||
<td>Item B</td> | |||
<td>1200</td> | |||
<td class="minorProfit"></td> | |||
<td class="majorProfit"></td> | |||
<td class="totalProfit"></td> | |||
</tr> | |||
</tbody> | |||
</table> | |||
<script> | |||
function calculateProfits() { | |||
const scrollPrice = parseFloat(document.getElementById('scrollPrice').value); | |||
const quantity = parseInt(document.getElementById('quantity').value); | |||
document.querySelectorAll('#aurum-table tbody tr').forEach(row => { | |||
const buyPrice = parseFloat(row.dataset.buyprice); | |||
const minorProfit = 1500 - buyPrice - scrollPrice; | |||
const majorProfit = 3000 - buyPrice - (scrollPrice * 3); | |||
const totalProfit = (majorProfit * quantity); // you could switch to minor here | |||
row.querySelector('.minorProfit').textContent = minorProfit.toFixed(2); | |||
row.querySelector('.majorProfit').textContent = majorProfit.toFixed(2); | |||
row.querySelector('.totalProfit').textContent = totalProfit.toFixed(2); | |||
}); | |||
} | |||
document.getElementById('scrollPrice').addEventListener('input', calculateProfits); | |||
document.getElementById('quantity').addEventListener('input', calculateProfits); | |||
calculateProfits(); // Initial call | |||
</script> | |||
</html> | </html> |
Revision as of 11:57, 26 June 2025
Item | Buy Price | Minor Profit | Major Profit | Total Profit (qty) |
---|---|---|---|---|
Item A | 500 | |||
Item B | 1200 |