mirror of
https://github.com/badlogic/heissepreise.git
synced 2024-06-16 05:34:21 +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 unit = item.unit || "";
|
||||
if (quantity >= 1000 && (unit == "g" || unit == "ml")) {
|
||||
if (quantity >= 1000 && (unit === "g" || unit === "ml")) {
|
||||
quantity = parseFloat((0.001 * quantity).toFixed(2));
|
||||
unit = unit == "ml" ? "l" : "kg";
|
||||
unit = unit === "ml" ? "l" : "kg";
|
||||
}
|
||||
let percentageChange = "";
|
||||
if (prevPrice != -1) {
|
||||
|
@ -284,8 +284,8 @@ class ItemsList extends View {
|
|||
let showUnitPrice = this.elements.unitPrice.checked;
|
||||
let priceUnit = "";
|
||||
if (showUnitPrice) {
|
||||
if (item.unit == "g") priceUnit = " / kg";
|
||||
else if (item.unit == "ml") priceUnit = " / l";
|
||||
if (item.unit === "g") priceUnit = " / kg";
|
||||
else if (item.unit === "ml") priceUnit = " / l";
|
||||
else priceUnit = " / stk";
|
||||
}
|
||||
|
||||
|
@ -395,7 +395,7 @@ class ItemsList extends View {
|
|||
|
||||
elements.up.addEventListener("click", () => {
|
||||
const index = itemDom.rowIndex - 1;
|
||||
if (index == 0) return;
|
||||
if (index === 0) return;
|
||||
let otherItem = this.model.items[index - 1];
|
||||
this.model.items[index - 1] = item;
|
||||
this.model.items[index] = otherItem;
|
||||
|
@ -408,7 +408,7 @@ class ItemsList extends View {
|
|||
|
||||
elements.down.addEventListener("click", () => {
|
||||
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];
|
||||
this.model.items[index + 1] = item;
|
||||
this.model.items[index] = otherItem;
|
||||
|
@ -432,11 +432,11 @@ class ItemsList extends View {
|
|||
elements.nameSimilarity.removeAttribute("disabled");
|
||||
} else {
|
||||
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];
|
||||
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");
|
||||
} else {
|
||||
if (!this._noSort) {
|
||||
|
@ -444,7 +444,7 @@ class ItemsList extends View {
|
|||
items = this.sort(items);
|
||||
}
|
||||
}
|
||||
if (items.length == 0) {
|
||||
if (items.length === 0) {
|
||||
elements.chart.classList.add("hidden");
|
||||
elements.options.classList.add("hidden");
|
||||
elements.itemsTable.classList.add("hidden");
|
||||
|
@ -462,7 +462,7 @@ class ItemsList extends View {
|
|||
const batches = [];
|
||||
let batch = [];
|
||||
items.forEach((item) => {
|
||||
if (batch.length == 25) {
|
||||
if (batch.length === 25) {
|
||||
batches.push(batch);
|
||||
batch = [];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user