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;
|
||||
|
||||
interface PriceRow {
|
||||
quality: number
|
||||
order: number
|
||||
row: HTMLTableRowElement
|
||||
}
|
||||
var priceRows: PriceRow[]= [];
|
||||
@@ -214,7 +214,7 @@ async function inject() {
|
||||
const qualityName = itemQualities[quality as unknown as keyof typeof itemQualities].toString()
|
||||
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
|
||||
@@ -231,7 +231,7 @@ async function inject() {
|
||||
|
||||
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()
|
||||
return
|
||||
}))
|
||||
@@ -251,7 +251,7 @@ async function inject() {
|
||||
|
||||
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()
|
||||
return
|
||||
}))
|
||||
@@ -267,7 +267,7 @@ async function inject() {
|
||||
|
||||
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()
|
||||
return
|
||||
}))
|
||||
@@ -275,14 +275,10 @@ async function inject() {
|
||||
|
||||
Promise.all(promises).then(() => {
|
||||
priceRows.sort((a, b) => {
|
||||
// Sort 6 first always, then numerically
|
||||
if (a.quality === 6) {
|
||||
return -1;
|
||||
} else if (b.quality === 6) {
|
||||
return 1;
|
||||
} else {
|
||||
return a.quality == b.quality ? a.quality < b.quality ? -1 : 1 : 0;
|
||||
if (a.category != b.category) {
|
||||
return a.category - b.category;
|
||||
}
|
||||
return a.order - b.order;
|
||||
}).reverse().forEach((element) => {
|
||||
priceInfoboxHeadingRow.insertAdjacentElement('afterend', element.row);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user