|
1 | 1 | const API_BASE_URL = 'https://fantasyonline2.com/api/public'; |
2 | 2 | const API_KEY = process.env.API_KEY; // Replace with your actual key if needed |
3 | | - |
4 | 3 | let embeddedItemData = null; // Initialize as null |
5 | 4 |
|
6 | 5 | // Load the JSON file and assign its contents to embeddedItemData |
@@ -146,7 +145,7 @@ async function loadItemDatabase() { |
146 | 145 | console.warn("Item missing or has invalid 'Item ID':", item); |
147 | 146 | } |
148 | 147 | }); |
149 | | - console.log('Database load successfully:', (validItems), 'items loaded'); |
| 148 | + console.log('Database load successfully:', (validItems)); |
150 | 149 | // databaseStatus.innerHTML = `<div class="database-status"><span>Item database loaded successfully (${validItems} items)</span></div>`; |
151 | 150 | return true; |
152 | 151 | } catch (error) { |
@@ -510,8 +509,8 @@ function updateSortIndicators() { |
510 | 509 | searchButton.disabled = disable; |
511 | 510 | refreshButton.disabled = disable; |
512 | 511 | 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; |
515 | 514 | searchInput.disabled = disable; |
516 | 515 |
|
517 | 516 | // Keep pagination disabled during comprehensive search display |
@@ -741,26 +740,36 @@ nextPageButton.addEventListener('click', function() { |
741 | 740 | if (currentPage < totalPages) { currentPage++; searchMarket(); } |
742 | 741 | }); |
743 | 742 |
|
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 | +// }); |
754 | 753 |
|
755 | 754 | resultsTable.querySelector('thead').addEventListener('click', (e) => { |
756 | 755 | if (isLoading || isComprehensiveSearchActive) return; |
| 756 | + |
757 | 757 | const th = e.target.closest('th'); |
758 | 758 | if (th && th.dataset.sort) { |
759 | 759 | 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(); |
764 | 773 | } |
765 | 774 | }); |
766 | 775 |
|
|
0 commit comments