From 31575212ad0ef0e733ac8007b5a407282e3b62b6 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Mon, 22 Nov 2021 18:42:02 -0700 Subject: [PATCH] Allow "Add new..." button to redirect to webpages per category --- public/scripts/manage.js | 8 +++++--- views/manage.pug | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/public/scripts/manage.js b/public/scripts/manage.js index 04656eb..2f24fc4 100644 --- a/public/scripts/manage.js +++ b/public/scripts/manage.js @@ -2,6 +2,7 @@ import * as Data from "./data.js"; const categoryDropdown = document.getElementById('category-dropdown'); const itemsListTable = document.getElementById('items-list'); +const addNewButton = document.getElementById('add-new-button'); function getGenderLetter(genderName) { @@ -50,7 +51,7 @@ CATEGORIES.push(new Category( row.appendChild(spacerCell); }, async function addSeason() { - // + window.location.href = "manage/addseason"; }, async function editSeason() { @@ -267,7 +268,7 @@ CATEGORIES.push(new Category( row.appendChild(dateCell); }, async function addGame() { - // + window.location.href = "manage/addgame"; }, async function editSeason() { @@ -313,4 +314,5 @@ listItems(CATEGORIES[categoryDropdown.selectedIndex]); categoryDropdown.onchange = () => { listItems(CATEGORIES[categoryDropdown.selectedIndex]); -}; \ No newline at end of file +}; +addNewButton.addEventListener('click', () => CATEGORIES[categoryDropdown.selectedIndex].addItem()); \ No newline at end of file diff --git a/views/manage.pug b/views/manage.pug index 7977824..c43dcf9 100644 --- a/views/manage.pug +++ b/views/manage.pug @@ -20,7 +20,7 @@ block content div h2#table-header table#items-list - button Add new... + button#add-new-button Add new... block scripts script(src='/scripts/manage.js' type="module") \ No newline at end of file