Files
Inventory-Manager/public/javascripts/header.js
T

56 lines
1.8 KiB
JavaScript
Raw Normal View History

2025-01-14 21:09:25 +00:00
"use strict";
2025-01-12 02:38:12 +00:00
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';
});
}
2025-01-14 21:09:25 +00:00
const settingsNav = document.querySelector('#settingsNav');
if (settingsNav) {
settingsNav.addEventListener('click', () => {
window.location.href = '/settings';
});
}
2025-01-23 10:02:08 +00:00
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';
});
}
2025-01-12 02:38:12 +00:00
const logoutNav = document.querySelector('#logoutNav');
if (logoutNav) {
logoutNav.addEventListener('click', (event) => {
event.preventDefault(); // Prevent default link behavior
2025-01-14 21:09:25 +00:00
$.get('/auth/logout', function (data) {
2025-01-12 02:38:12 +00:00
window.location.href = '/login';
}).fail((jqXHR) => {
alert('Logout failed: ' + jqXHR.responseText);
});
});
}
2025-01-14 21:09:25 +00:00
});