Fix JavaScript to properly handle dropped albums status
- Updated filter logic to recognize "Dropped" status albums - Fixed statistics counting for dropped albums - Added proper CSS class and formatting for dropped status - Updated rank validation to handle extended range (1-523) - Added dropdown arrow icon (⤵) for dropped albums - Now properly shows dropped count and filters work correctly 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
5401dd22e0
commit
3cf9d74eae
1 changed files with 6 additions and 4 deletions
10
script.js
10
script.js
|
|
@ -192,6 +192,7 @@ function getStatusClass(status) {
|
||||||
if (status === 'No change') return 'status-no-change';
|
if (status === 'No change') return 'status-no-change';
|
||||||
if (status.startsWith('+')) return 'status-improved';
|
if (status.startsWith('+')) return 'status-improved';
|
||||||
if (status.startsWith('-')) return 'status-dropped';
|
if (status.startsWith('-')) return 'status-dropped';
|
||||||
|
if (status.startsWith('Dropped')) return 'status-dropped';
|
||||||
return 'status-no-change';
|
return 'status-no-change';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -201,6 +202,7 @@ function formatStatus(status) {
|
||||||
if (status === 'No change') return 'No Change';
|
if (status === 'No change') return 'No Change';
|
||||||
if (status.startsWith('+')) return `↗ ${status}`;
|
if (status.startsWith('+')) return `↗ ${status}`;
|
||||||
if (status.startsWith('-')) return `↘ ${status}`;
|
if (status.startsWith('-')) return `↘ ${status}`;
|
||||||
|
if (status.startsWith('Dropped')) return `⤵ ${status}`;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +237,7 @@ function handleFilter(event) {
|
||||||
} else if (filterValue === 'improved') {
|
} else if (filterValue === 'improved') {
|
||||||
filteredData = albumsData.filter(album => album.Status.startsWith('+'));
|
filteredData = albumsData.filter(album => album.Status.startsWith('+'));
|
||||||
} else if (filterValue === 'dropped') {
|
} else if (filterValue === 'dropped') {
|
||||||
filteredData = albumsData.filter(album => album.Status.startsWith('-'));
|
filteredData = albumsData.filter(album => album.Status.startsWith('-') || album.Status.startsWith('Dropped'));
|
||||||
} else {
|
} else {
|
||||||
filteredData = albumsData.filter(album => album.Status === filterValue);
|
filteredData = albumsData.filter(album => album.Status === filterValue);
|
||||||
}
|
}
|
||||||
|
|
@ -318,7 +320,7 @@ function updateStats() {
|
||||||
const total = filteredData.length;
|
const total = filteredData.length;
|
||||||
const newAlbums = filteredData.filter(album => album.Status === 'New in 2023').length;
|
const newAlbums = filteredData.filter(album => album.Status === 'New in 2023').length;
|
||||||
const improved = filteredData.filter(album => album.Status.startsWith('+')).length;
|
const improved = filteredData.filter(album => album.Status.startsWith('+')).length;
|
||||||
const dropped = filteredData.filter(album => album.Status.startsWith('-')).length;
|
const dropped = filteredData.filter(album => album.Status.startsWith('-') || album.Status.startsWith('Dropped')).length;
|
||||||
|
|
||||||
document.getElementById('totalAlbums').textContent = total;
|
document.getElementById('totalAlbums').textContent = total;
|
||||||
document.getElementById('newAlbums').textContent = newAlbums;
|
document.getElementById('newAlbums').textContent = newAlbums;
|
||||||
|
|
@ -415,8 +417,8 @@ function handleJumpToRank() {
|
||||||
jumpToRank.value = '1';
|
jumpToRank.value = '1';
|
||||||
} else {
|
} else {
|
||||||
rank = parseInt(inputValue);
|
rank = parseInt(inputValue);
|
||||||
if (isNaN(rank) || rank < 1 || rank > 500) {
|
if (isNaN(rank) || rank < 1 || rank > 523) {
|
||||||
alert('Please enter a valid rank between 1 and 500');
|
alert('Please enter a valid rank between 1 and 523');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue