Refine resale sorting and cache version

This commit is contained in:
2026-05-21 12:32:42 +09:00
parent 707da3b402
commit 11ec940e48
4 changed files with 37 additions and 77 deletions

View File

@@ -249,7 +249,7 @@ document.addEventListener('DOMContentLoaded', () => {
const gameTitleEl = document.getElementById('gameTitle');
gameTitleEl.className =
'text-3xl font-bold tracking-tight text-gray-900 sm:text-4xl flex items-center justify-center gap-2';
gameTitleEl.innerHTML = `${game.sale?.priceVerified ? `${VERIFIED_PRICE_MARK} ` : ''}<span>${game.no}. ${displayTitle}</span>`;
gameTitleEl.innerHTML = `${game.sale?.priceVerified ? `${VERIFIED_PRICE_MARK} ` : ''}<span>${displayTitle}</span>`;
document.getElementById('gameTags').textContent = convertTags(game.tags);
document.getElementById('infoTitle').textContent = currentTexts.infoTitle;
document.getElementById('purchaseTitle').textContent = currentTexts.purchaseTitle;

View File

@@ -1,6 +1,6 @@
import NSW_DB from '../db/nsw.resale.db.js?v=20260521-price-pending';
import NSW_DB from '../db/nsw.resale.db.js?v=20260521-badges-v2';
window.NSW_APP_VERSION = '20260521-price-pending';
window.NSW_APP_VERSION = '20260521-badges-v2';
const SHOW_SOLD_BY_DEFAULT = false;
const SHOW_RECOMMENDED_PRICE_RANGE_BY_DEFAULT = false;
@@ -32,8 +32,6 @@ document.addEventListener('DOMContentLoaded', () => {
status: '판매 상태',
},
sortOptions: {
sortByNoDesc: '순번 최신순',
sortByNo: '순번 과거순',
sortByDateDesc: '발매일 최신순',
sortByDate: '발매일 과거순',
sortByPriceDesc: '판매가 높은순',
@@ -62,8 +60,6 @@ document.addEventListener('DOMContentLoaded', () => {
status: '販売状態',
},
sortOptions: {
sortByNoDesc: '番号降順',
sortByNo: '番号昇順',
sortByDateDesc: '発売日降順',
sortByDate: '発売日昇順',
sortByPriceDesc: '販売価格降順',
@@ -88,7 +84,7 @@ document.addEventListener('DOMContentLoaded', () => {
cero: [],
},
searchText: '',
sortBy: 'sortByNoDesc', // 기본 정렬 옵션
sortBy: 'sortByRandom',
};
// UI 텍스트 업데이트 함수
@@ -99,26 +95,30 @@ document.addEventListener('DOMContentLoaded', () => {
document.querySelector('h1').textContent = texts.title;
// 언어 선택 섹션 업데이트
document.querySelector('label.text-base').textContent = texts.languageSelect;
document.querySelector('p.text-sm').textContent = texts.languageDescription;
document.querySelector('label[for="ko"]').textContent = texts.korean;
document.querySelector('label[for="ja"]').textContent = texts.japanese;
setTextContent('label.text-base', texts.languageSelect);
setTextContent('p.text-sm', texts.languageDescription);
setTextContent('label[for="ko"]', texts.korean);
setTextContent('label[for="ja"]', texts.japanese);
// 테이블 헤더 업데이트
const headers = document.querySelectorAll('th');
headers[0].textContent = texts.tableHeaders.title;
headers[1].textContent = texts.tableHeaders.info;
headers[2].textContent = texts.tableHeaders.status;
if (headers[0]) headers[0].textContent = texts.tableHeaders.title;
if (headers[1]) headers[1].textContent = texts.tableHeaders.info;
if (headers[2]) headers[2].textContent = texts.tableHeaders.status;
// 로딩 텍스트 업데이트
loading.textContent = texts.loading;
document.getElementById('priceProgressNotice').textContent = texts.listIntro;
setTextContent('#priceProgressNotice', texts.listIntro);
// 필터 텍스트 업데이트
document.getElementById('resetFilters').textContent = texts.filter.reset;
document.querySelector('label[for="korean-support"]').textContent = texts.filter.koreanSupport;
document.querySelector('label[for="korean-not-support"]').textContent =
texts.filter.koreanNotSupport;
setTextContent('#resetFilters', texts.filter.reset);
setTextContent('label[for="korean-support"]', texts.filter.koreanSupport);
setTextContent('label[for="korean-not-support"]', texts.filter.koreanNotSupport);
}
function setTextContent(selector, text) {
const element = document.querySelector(selector);
if (element) element.textContent = text;
}
// 언어 변경 이벤트 리스너
@@ -777,7 +777,7 @@ document.addEventListener('DOMContentLoaded', () => {
</div>
<div class="ml-4 min-w-0 flex-1">
<div class="font-medium leading-5 text-gray-900 flex items-center gap-1">
${game.sale?.priceVerified ? `${VERIFIED_PRICE_MARK} ` : ''}<span>${game.no}. ${game.formattedTitle}</span>
${game.sale?.priceVerified ? `${VERIFIED_PRICE_MARK} ` : ''}<span>${game.formattedTitle}</span>
</div>
<div class="mt-2">
${renderInfoBadges(game)}
@@ -853,7 +853,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
// 필터 초기화 버튼 이벤트 리스너 설정
document.getElementById('resetFilters').addEventListener('click', resetFilters);
document.getElementById('resetFilters')?.addEventListener('click', resetFilters);
// 필터 체크박스 이벤트 리스너 설정
function setupFilterListeners() {
@@ -1100,43 +1100,39 @@ document.addEventListener('DOMContentLoaded', () => {
// 정렬 함수
function sortGames(games) {
switch (filterState.sortBy) {
case 'sortByNoDesc':
return [...games].sort((a, b) => b.no - a.no);
case 'sortByNo':
return [...games].sort((a, b) => a.no - b.no);
case 'sortByDateDesc':
return [...games].sort((a, b) => {
const aDate = new Date(a.release.replace(/年|月/g, '/').replace(/日/g, '')).toUTCString();
const bDate = new Date(b.release.replace(/年|月/g, '/').replace(/日/g, '')).toUTCString();
const dateDiff = new Date(bDate) - new Date(aDate);
return dateDiff === 0 ? b.no - a.no : dateDiff;
return dateDiff === 0 ? compareTitles(a, b) : dateDiff;
});
case 'sortByDate':
return [...games].sort((a, b) => {
const aDate = new Date(a.release.replace(/年|月/g, '/').replace(/日/g, '')).toUTCString();
const bDate = new Date(b.release.replace(/年|月/g, '/').replace(/日/g, '')).toUTCString();
const dateDiff = new Date(aDate) - new Date(bDate);
return dateDiff === 0 ? b.no - a.no : dateDiff;
return dateDiff === 0 ? compareTitles(a, b) : dateDiff;
});
case 'sortByPriceDesc':
return [...games].sort((a, b) => {
const aPrice = getSuggestedPriceValue(a);
const bPrice = getSuggestedPriceValue(b);
if (aPrice === null && bPrice === null) return b.no - a.no;
if (aPrice === null && bPrice === null) return compareTitles(a, b);
if (aPrice === null) return 1;
if (bPrice === null) return -1;
const priceDiff = bPrice - aPrice;
return priceDiff === 0 ? b.no - a.no : priceDiff;
return priceDiff === 0 ? compareTitles(a, b) : priceDiff;
});
case 'sortByPrice':
return [...games].sort((a, b) => {
const aPrice = getSuggestedPriceValue(a);
const bPrice = getSuggestedPriceValue(b);
if (aPrice === null && bPrice === null) return b.no - a.no;
if (aPrice === null && bPrice === null) return compareTitles(a, b);
if (aPrice === null) return 1;
if (bPrice === null) return -1;
const priceDiff = aPrice - bPrice;
return priceDiff === 0 ? b.no - a.no : priceDiff;
return priceDiff === 0 ? compareTitles(a, b) : priceDiff;
});
case 'sortByRandom':
return [...games].sort(() => Math.random() - 0.5);
@@ -1145,6 +1141,10 @@ document.addEventListener('DOMContentLoaded', () => {
}
}
function compareTitles(a, b) {
return a.formattedTitle.localeCompare(b.formattedTitle, filterState.language === 'ko' ? 'ko' : 'ja');
}
// 정렬 UI 초기화
function setupSortUI() {
const sortButton = document.getElementById('sort-button');