From b9b4e25aecbcf0b6e3b1637002b9f670edde1fc1 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Fri, 26 Nov 2021 22:29:19 -0700 Subject: [PATCH] Add ability to select category via url in management page --- public/scripts/manage.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/public/scripts/manage.js b/public/scripts/manage.js index de4a6e2..32ca8dd 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -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]); };