Add ability to select category via url in management page

main
sudoer777 2021-11-26 22:29:19 -07:00
parent 1388891ef5
commit b9b4e25aec
1 changed files with 9 additions and 1 deletions

View File

@ -367,10 +367,18 @@ async function listItems(category) {
itemsListTable.appendChild(row);
});
}
if(window.location.hash) {
let correctIndex;
let index = 0;
CATEGORIES.forEach(category => {
if(window.location.hash == '#' + category.name) correctIndex = index;
index++;
})
if(correctIndex || correctIndex === 0) categoryDropdown.selectedIndex = correctIndex;
}
listItems(CATEGORIES[categoryDropdown.selectedIndex]);
categoryDropdown.onchange = () => {
listItems(CATEGORIES[categoryDropdown.selectedIndex]);
};