mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-06-24 09:25:53 +02:00
Percentage change in price dom.
This commit is contained in:
parent
00c396644d
commit
b9cf3f9e3c
|
@ -102,7 +102,12 @@ function itemToDOM(item) {
|
|||
let storeDom = dom("td", item.store);
|
||||
let nameDom = dom("td", itemToStoreLink(item));
|
||||
let unitDom = dom("td", item.unit ? item.unit : "");
|
||||
let priceDomText = item.price + (item.priceHistory.length > 1 ? (item.priceHistory[0].price > item.priceHistory[1].price ? " 📈" : " 📉") + " (" + (item.priceHistory.length - 1) + ")" : "");
|
||||
let increase = "";
|
||||
if (item.priceHistory.length > 1) {
|
||||
let percentageChange = Math.round((item.priceHistory[0].price - item.priceHistory[1].price) / item.priceHistory[1].price * 100);
|
||||
increase = (percentageChange > 0 ? "+" + percentageChange : percentageChange) + "%";
|
||||
}
|
||||
let priceDomText = item.price + (item.priceHistory.length > 1 ? (item.priceHistory[0].price > item.priceHistory[1].price ? " 📈" : " 📉") + " " + increase + " (" + (item.priceHistory.length - 1) + ")" : "");
|
||||
let pricesText = "";
|
||||
for (let i = 0; i < item.priceHistory.length; i++) {
|
||||
const date = item.priceHistory[i].date;
|
||||
|
|
Loading…
Reference in New Issue
Block a user