You've already forked tf2wikipricing
refactor: sort price rows by order instead of quality
This commit is contained in:
@@ -188,7 +188,7 @@ async function inject() {
|
|||||||
var updateTime: Date | null = null;
|
var updateTime: Date | null = null;
|
||||||
|
|
||||||
interface PriceRow {
|
interface PriceRow {
|
||||||
quality: number
|
order: number
|
||||||
row: HTMLTableRowElement
|
row: HTMLTableRowElement
|
||||||
}
|
}
|
||||||
var priceRows: PriceRow[]= [];
|
var priceRows: PriceRow[]= [];
|
||||||
@@ -214,7 +214,7 @@ async function inject() {
|
|||||||
const qualityName = itemQualities[quality as unknown as keyof typeof itemQualities].toString()
|
const qualityName = itemQualities[quality as unknown as keyof typeof itemQualities].toString()
|
||||||
const priceRow = createPriceRow(qualityName, data, keyPrice, locale)
|
const priceRow = createPriceRow(qualityName, data, keyPrice, locale)
|
||||||
|
|
||||||
priceRows.push({quality: quality, row: priceRow})
|
priceRows.push({order: quality == 6 ? -1 : quality, row: priceRow)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Check item schema for Australium variant of current defindex
|
// Check item schema for Australium variant of current defindex
|
||||||
@@ -231,7 +231,7 @@ async function inject() {
|
|||||||
|
|
||||||
const priceRow = createPriceRow($T("Australium"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Australium_weapons")
|
const priceRow = createPriceRow($T("Australium"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Australium_weapons")
|
||||||
|
|
||||||
priceRows.push({quality: 99, row: priceRow})
|
priceRows.push({order: 99, row: priceRow)
|
||||||
resolve()
|
resolve()
|
||||||
return
|
return
|
||||||
}))
|
}))
|
||||||
@@ -251,7 +251,7 @@ async function inject() {
|
|||||||
|
|
||||||
const priceRow = createPriceRow($T("Festive"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Festive_weapons")
|
const priceRow = createPriceRow($T("Festive"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Festive_weapons")
|
||||||
|
|
||||||
priceRows.push({quality: 97, row: priceRow})
|
priceRows.push({order: -1, row: priceRow})
|
||||||
resolve()
|
resolve()
|
||||||
return
|
return
|
||||||
}))
|
}))
|
||||||
@@ -267,7 +267,7 @@ async function inject() {
|
|||||||
|
|
||||||
const priceRow = createPriceRow($T("Strange Festive"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Festive_weapons")
|
const priceRow = createPriceRow($T("Strange Festive"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Festive_weapons")
|
||||||
|
|
||||||
priceRows.push({quality: 98, row: priceRow})
|
priceRows.push({order: 11, row: priceRow})
|
||||||
resolve()
|
resolve()
|
||||||
return
|
return
|
||||||
}))
|
}))
|
||||||
@@ -275,14 +275,10 @@ async function inject() {
|
|||||||
|
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
priceRows.sort((a, b) => {
|
priceRows.sort((a, b) => {
|
||||||
// Sort 6 first always, then numerically
|
if (a.category != b.category) {
|
||||||
if (a.quality === 6) {
|
return a.category - b.category;
|
||||||
return -1;
|
|
||||||
} else if (b.quality === 6) {
|
|
||||||
return 1;
|
|
||||||
} else {
|
|
||||||
return a.quality == b.quality ? a.quality < b.quality ? -1 : 1 : 0;
|
|
||||||
}
|
}
|
||||||
|
return a.order - b.order;
|
||||||
}).reverse().forEach((element) => {
|
}).reverse().forEach((element) => {
|
||||||
priceInfoboxHeadingRow.insertAdjacentElement('afterend', element.row);
|
priceInfoboxHeadingRow.insertAdjacentElement('afterend', element.row);
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user