Add sports to single request
parent
cc66467197
commit
1e78e37913
|
@ -1,9 +1,14 @@
|
||||||
import * as Data from "./data.js";
|
import * as Data from "./data.js";
|
||||||
|
|
||||||
export async function populateSports(sportDropdown, selectedSportID = undefined) {
|
export async function populateSports(sportDropdown, selectedSportID = undefined, data = undefined) {
|
||||||
sportDropdown.innerHTML = "";
|
sportDropdown.innerHTML = "";
|
||||||
|
|
||||||
const sportsList = await Data.getSports();
|
let sportsList;
|
||||||
|
if(data) {
|
||||||
|
sportsList = data.sports;
|
||||||
|
} else {
|
||||||
|
sportsList = await Data.getSports();
|
||||||
|
}
|
||||||
|
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
let selectedSportIndex;
|
let selectedSportIndex;
|
||||||
|
@ -13,7 +18,7 @@ export async function populateSports(sportDropdown, selectedSportID = undefined)
|
||||||
option.value = sport.id;
|
option.value = sport.id;
|
||||||
sportDropdown.appendChild(option);
|
sportDropdown.appendChild(option);
|
||||||
|
|
||||||
if(sport.id == selectedSportID) selectedSportIndex = currentIndex;
|
if(sport.id == selectedSportID || (data && sport.id == data.latestGame.sportID)) selectedSportIndex = currentIndex;
|
||||||
currentIndex++;
|
currentIndex++;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -30,7 +35,7 @@ export async function populateSeasons(seasonDropdown, selectedSeasonID = undefin
|
||||||
} else {
|
} else {
|
||||||
seasonsList = await Data.getSeasons();
|
seasonsList = await Data.getSeasons();
|
||||||
}
|
}
|
||||||
console.log(data);
|
|
||||||
let currentIndex = 0;
|
let currentIndex = 0;
|
||||||
let selectedSeasonIndex;
|
let selectedSeasonIndex;
|
||||||
seasonsList.forEach(season => {
|
seasonsList.forEach(season => {
|
||||||
|
|
Reference in New Issue