mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-06-30 12:27:15 +02:00
perf: ⚡ compare without type casting
This commit is contained in:
parent
495571b8a7
commit
b844232a65
|
@ -272,9 +272,9 @@ class ItemsList extends View {
|
||||||
|
|
||||||
let quantity = item.quantity || "";
|
let quantity = item.quantity || "";
|
||||||
let unit = item.unit || "";
|
let unit = item.unit || "";
|
||||||
if (quantity >= 1000 && (unit == "g" || unit == "ml")) {
|
if (quantity >= 1000 && (unit === "g" || unit === "ml")) {
|
||||||
quantity = parseFloat((0.001 * quantity).toFixed(2));
|
quantity = parseFloat((0.001 * quantity).toFixed(2));
|
||||||
unit = unit == "ml" ? "l" : "kg";
|
unit = unit === "ml" ? "l" : "kg";
|
||||||
}
|
}
|
||||||
let percentageChange = "";
|
let percentageChange = "";
|
||||||
if (prevPrice != -1) {
|
if (prevPrice != -1) {
|
||||||
|
@ -284,8 +284,8 @@ class ItemsList extends View {
|
||||||
let showUnitPrice = this.elements.unitPrice.checked;
|
let showUnitPrice = this.elements.unitPrice.checked;
|
||||||
let priceUnit = "";
|
let priceUnit = "";
|
||||||
if (showUnitPrice) {
|
if (showUnitPrice) {
|
||||||
if (item.unit == "g") priceUnit = " / kg";
|
if (item.unit === "g") priceUnit = " / kg";
|
||||||
else if (item.unit == "ml") priceUnit = " / l";
|
else if (item.unit === "ml") priceUnit = " / l";
|
||||||
else priceUnit = " / stk";
|
else priceUnit = " / stk";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ class ItemsList extends View {
|
||||||
|
|
||||||
elements.up.addEventListener("click", () => {
|
elements.up.addEventListener("click", () => {
|
||||||
const index = itemDom.rowIndex - 1;
|
const index = itemDom.rowIndex - 1;
|
||||||
if (index == 0) return;
|
if (index === 0) return;
|
||||||
let otherItem = this.model.items[index - 1];
|
let otherItem = this.model.items[index - 1];
|
||||||
this.model.items[index - 1] = item;
|
this.model.items[index - 1] = item;
|
||||||
this.model.items[index] = otherItem;
|
this.model.items[index] = otherItem;
|
||||||
|
@ -408,7 +408,7 @@ class ItemsList extends View {
|
||||||
|
|
||||||
elements.down.addEventListener("click", () => {
|
elements.down.addEventListener("click", () => {
|
||||||
const index = itemDom.rowIndex - 1;
|
const index = itemDom.rowIndex - 1;
|
||||||
if (index == this.model.items.length - 1) return;
|
if (index === this.model.items.length - 1) return;
|
||||||
let otherItem = this.model.items[index + 1];
|
let otherItem = this.model.items[index + 1];
|
||||||
this.model.items[index + 1] = item;
|
this.model.items[index + 1] = item;
|
||||||
this.model.items[index] = otherItem;
|
this.model.items[index] = otherItem;
|
||||||
|
@ -432,11 +432,11 @@ class ItemsList extends View {
|
||||||
elements.nameSimilarity.removeAttribute("disabled");
|
elements.nameSimilarity.removeAttribute("disabled");
|
||||||
} else {
|
} else {
|
||||||
elements.nameSimilarity.setAttribute("disabled", "true");
|
elements.nameSimilarity.setAttribute("disabled", "true");
|
||||||
if (this.model.filteredItems.length != 0 && elements.sort.value == "name-similarity") elements.sort.value = "price-asc";
|
if (this.model.filteredItems.length != 0 && elements.sort.value === "name-similarity") elements.sort.value = "price-asc";
|
||||||
}
|
}
|
||||||
|
|
||||||
let items = [...this.model.filteredItems];
|
let items = [...this.model.filteredItems];
|
||||||
if (this.model.lastQuery && this.model.lastQuery.charAt(0) == "!" && this.model.lastQuery.toLowerCase().indexOf("order by") >= 0) {
|
if (this.model.lastQuery && this.model.lastQuery.charAt(0) === "!" && this.model.lastQuery.toLowerCase().indexOf("order by") >= 0) {
|
||||||
elements.sort.parentElement.classList.add("hidden");
|
elements.sort.parentElement.classList.add("hidden");
|
||||||
} else {
|
} else {
|
||||||
if (!this._noSort) {
|
if (!this._noSort) {
|
||||||
|
@ -444,7 +444,7 @@ class ItemsList extends View {
|
||||||
items = this.sort(items);
|
items = this.sort(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (items.length == 0) {
|
if (items.length === 0) {
|
||||||
elements.chart.classList.add("hidden");
|
elements.chart.classList.add("hidden");
|
||||||
elements.options.classList.add("hidden");
|
elements.options.classList.add("hidden");
|
||||||
elements.itemsTable.classList.add("hidden");
|
elements.itemsTable.classList.add("hidden");
|
||||||
|
@ -462,7 +462,7 @@ class ItemsList extends View {
|
||||||
const batches = [];
|
const batches = [];
|
||||||
let batch = [];
|
let batch = [];
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
if (batch.length == 25) {
|
if (batch.length === 25) {
|
||||||
batches.push(batch);
|
batches.push(batch);
|
||||||
batch = [];
|
batch = [];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user