add deleteAllCookies util function,
add functionality to nav buttons Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
0a2ba085ce
commit
78edc9e0a3
@ -11,8 +11,8 @@
|
||||
<body>
|
||||
<header>
|
||||
<nav class="btn-group">
|
||||
<button class="active">INSTANCES</button>
|
||||
<button>LOGOUT</button>
|
||||
<button id="instances" class="active">INSTANCES</button>
|
||||
<button id="logout">LOGOUT</button>
|
||||
</nav>
|
||||
</header>
|
||||
<main><div id="instance-container" class="center-div"></div></main>
|
||||
|
@ -1,9 +1,20 @@
|
||||
import {request, goToPage} from "./utils.js";
|
||||
import {request, goToPage, deleteAllCookies} from "./utils.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
async function init () {
|
||||
await populateInstances();
|
||||
|
||||
let instances = document.querySelector("nav #instances");
|
||||
instances.addEventListener("click", () => {
|
||||
goToPage("index.html");
|
||||
});
|
||||
|
||||
let logout = document.querySelector("nav #logout");
|
||||
logout.addEventListener("click", () => {
|
||||
deleteAllCookies();
|
||||
goToPage("login.html");
|
||||
});
|
||||
}
|
||||
|
||||
async function populateInstances () {
|
||||
|
@ -1,8 +1,9 @@
|
||||
import {requestTicket, setTicket, ResponseError, NetworkError, goToPage} from "./utils.js";
|
||||
import {requestTicket, setTicket, ResponseError, NetworkError, goToPage, deleteAllCookies} from "./utils.js";
|
||||
|
||||
window.addEventListener("DOMContentLoaded", init);
|
||||
|
||||
function init (){
|
||||
deleteAllCookies();
|
||||
let formSubmitButton = document.querySelector("#submit");
|
||||
let status = document.querySelector("#status");
|
||||
formSubmitButton.addEventListener("click", async (e) => {
|
||||
|
@ -86,4 +86,8 @@ export function goToPage (page, data={}) {
|
||||
export function getURIData () {
|
||||
let url = new URL(window.location.href);
|
||||
return Object.fromEntries(url.searchParams);
|
||||
}
|
||||
|
||||
export function deleteAllCookies () {
|
||||
document.cookie.split(";").forEach(function(c) { document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
|
||||
}
|
Loading…
Reference in New Issue
Block a user