Skip to content

Commit 9e12b9f

Browse files
committed
modify so that cannot sort
1 parent 4aa00f4 commit 9e12b9f

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

FO2/MarketTracker/FO2MarketTrack.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ <h1>Fantasy Online 2 Market Tracker</h1>
3737
<option value="TimeLeft" selected>Time Left</option>
3838
<option value="Listed">Recently Listed</option>
3939
</select>
40-
</div> -->
41-
<!-- <div class="filter-group">
40+
</div>
41+
<div class="filter-group">
4242
<label for="sort-direction">Direction:</label>
4343
<select id="sort-direction">
4444
<option value="ASC">Ascending</option>
@@ -89,7 +89,7 @@ <h1>Fantasy Online 2 Market Tracker</h1>
8989
<div class="item-details-column" id="item-details-column">
9090
<div class="item-details-header">Item Details</div>
9191
<div class="item-details-content">
92-
<img src="../..images/AI-DEN_Cowboy.png" class="item-details-icon pixelated" id="details-icon" alt="Item Icon">
92+
<img src='../../images/AI-DEN_Cowboy.png' class="item-details-icon pixelated" id="details-icon" alt="Item Icon">
9393
<div class="item-details-name" id="details-name"><span class="item-details-placeholder">Select an item from the left</span></div>
9494

9595
<ul class="item-details-stats" id="details-stats">

FO2/MarketTracker/market-track.js

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
const API_BASE_URL = 'https://fantasyonline2.com/api/public';
22
const API_KEY = process.env.API_KEY; // Replace with your actual key if needed
3-
43
let embeddedItemData = null; // Initialize as null
54

65
// Load the JSON file and assign its contents to embeddedItemData
@@ -146,7 +145,7 @@ async function loadItemDatabase() {
146145
console.warn("Item missing or has invalid 'Item ID':", item);
147146
}
148147
});
149-
console.log('Database load successfully:', (validItems), 'items loaded');
148+
console.log('Database load successfully:', (validItems));
150149
// databaseStatus.innerHTML = `<div class="database-status"><span>Item database loaded successfully (${validItems} items)</span></div>`;
151150
return true;
152151
} catch (error) {
@@ -510,8 +509,8 @@ function updateSortIndicators() {
510509
searchButton.disabled = disable;
511510
refreshButton.disabled = disable;
512511
showProfitableButton.disabled = disable; // Always disable during any load/search
513-
sortBySelect.disabled = disable;
514-
sortDirectionSelect.disabled = disable;
512+
// sortBySelect.disabled = disable;
513+
// sortDirectionSelect.disabled = disable;
515514
searchInput.disabled = disable;
516515

517516
// Keep pagination disabled during comprehensive search display
@@ -741,26 +740,36 @@ nextPageButton.addEventListener('click', function() {
741740
if (currentPage < totalPages) { currentPage++; searchMarket(); }
742741
});
743742

744-
sortBySelect.addEventListener('change', () => {
745-
if (isLoading || isComprehensiveSearchActive) return;
746-
currentSort = sortBySelect.value; currentPage = 1;
747-
updateSortIndicators(); searchMarket();
748-
});
749-
sortDirectionSelect.addEventListener('change', () => {
750-
if (isLoading || isComprehensiveSearchActive) return;
751-
currentDirection = sortDirectionSelect.value; currentPage = 1;
752-
updateSortIndicators(); searchMarket();
753-
});
743+
// sortBySelect.addEventListener('change', () => {
744+
// if (isLoading || isComprehensiveSearchActive) return;
745+
// currentSort = sortBySelect.value; currentPage = 1;
746+
// updateSortIndicators(); searchMarket();
747+
// });
748+
// sortDirectionSelect.addEventListener('change', () => {
749+
// if (isLoading || isComprehensiveSearchActive) return;
750+
// currentDirection = sortDirectionSelect.value; currentPage = 1;
751+
// updateSortIndicators(); searchMarket();
752+
// });
754753

755754
resultsTable.querySelector('thead').addEventListener('click', (e) => {
756755
if (isLoading || isComprehensiveSearchActive) return;
756+
757757
const th = e.target.closest('th');
758758
if (th && th.dataset.sort) {
759759
const column = th.dataset.sort;
760-
if (currentSort === column) { currentDirection = currentDirection === 'ASC' ? 'DESC' : 'ASC'; }
761-
else { currentSort = column; currentDirection = 'ASC'; }
762-
sortBySelect.value = currentSort; sortDirectionSelect.value = currentDirection;
763-
updateSortIndicators(); currentPage = 1; searchMarket();
760+
761+
// Toggle the sort direction if the same column is clicked, otherwise reset to ascending
762+
if (currentSort === column) {
763+
currentDirection = currentDirection === 'ASC' ? 'DESC' : 'ASC';
764+
} else {
765+
currentSort = column;
766+
currentDirection = 'ASC';
767+
}
768+
769+
// Update the sort indicators and fetch the sorted data
770+
updateSortIndicators();
771+
currentPage = 1;
772+
searchMarket();
764773
}
765774
});
766775

0 commit comments

Comments
 (0)