Files
Inventory-Manager/public/javascripts/header.js
T
Miles 45cb9fac99 Lots of updates and added functionality.
Added TODO list to readme as well as instructions.
2025-01-23 10:02:08 +00:00

57 lines
1.8 KiB
JavaScript

"use strict";
document.addEventListener('DOMContentLoaded', () => {
const brandNav = document.querySelector('#brandNav');
if (brandNav) {
brandNav.addEventListener('click', () => {
window.location.href = '/';
});
}
const homeNav = document.querySelector('#homeNav');
if (homeNav) {
homeNav.addEventListener('click', () => {
window.location.href = '/';
});
}
const inventoryNav = document.querySelector('#inventoryNav');
if (inventoryNav) {
inventoryNav.addEventListener('click', () => {
window.location.href = '/inventory';
});
}
const loginNav = document.querySelector('#loginNav');
if (loginNav) {
loginNav.addEventListener('click', () => {
window.location.href = '/login';
});
}
const settingsNav = document.querySelector('#settingsNav');
if (settingsNav) {
settingsNav.addEventListener('click', () => {
window.location.href = '/settings';
});
}
const ordersNav = document.querySelector('#ordersNav');
if (ordersNav) {
ordersNav.addEventListener('click', () => {
window.location.href = '/orders';
});
}
const boxesNav = document.querySelector('#boxesNav');
if (boxesNav) {
boxesNav.addEventListener('click', () => {
window.location.href = '/boxes';
});
}
const logoutNav = document.querySelector('#logoutNav');
if (logoutNav) {
logoutNav.addEventListener('click', (event) => {
event.preventDefault(); // Prevent default link behavior
$.get('/auth/logout', function (data) {
window.location.href = '/login';
}).fail((jqXHR) => {
alert('Logout failed: ' + jqXHR.responseText);
});
});
}
});