Skip to content

Commit

Permalink
Radio Browser: Length limitation /station name) and removal of duplic…
Browse files Browse the repository at this point in the history
…ate values (countries)
  • Loading branch information
schreibfaul1 committed Aug 18, 2024
1 parent af65796 commit 461f5a0
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/index.h
Original file line number Diff line number Diff line change
Expand Up @@ -1521,11 +1521,17 @@ function gotItems (data) { // fill select countries
stations.options.length = 1
// sort data
const options = Array.from(select.options);
options.sort((a, b) => a.text.localeCompare(b.text));

const uniqueOptions = options.filter((option, index, self) => {
return self.findIndex(o => o.text === option.text) === index;
});

uniqueOptions.sort((a, b) => a.text.localeCompare(b.text));
select.options.length = 0; // clear select
options.forEach(option => select.appendChild(option));
uniqueOptions.forEach(option => select.appendChild(option));
select.selectedIndex = 0; // set default

const selectElement = document.getElementById("stations");
selectElement.options.length = 0;
}

function gotStations (data) { // fill select stations
Expand All @@ -1542,6 +1548,11 @@ function gotStations (data) { // fill select stations
// sort data
const options = Array.from(select.options);
options.sort((a, b) => a.text.localeCompare(b.text));
options.forEach(option => {
if (option.text.length > 70) {
option.text = option.text.substring(0, 67) + '...'; // max length
}
});
select.options.length = 0; // clear select
options.forEach(option => select.appendChild(option));
select.selectedIndex = 0; // set default
Expand Down

0 comments on commit 461f5a0

Please sign in to comment.