add deleteAllCookies util function,
add functionality to nav buttons Signed-off-by: Arthur Lu <learthurgo@gmail.com>
This commit is contained in:
parent
78dd24d6cc
commit
9d0e0db27d
@ -11,8 +11,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<nav class="btn-group">
|
<nav class="btn-group">
|
||||||
<button class="active">INSTANCES</button>
|
<button id="instances" class="active">INSTANCES</button>
|
||||||
<button>LOGOUT</button>
|
<button id="logout">LOGOUT</button>
|
||||||
</nav>
|
</nav>
|
||||||
</header>
|
</header>
|
||||||
<main><div id="instance-container" class="center-div"></div></main>
|
<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);
|
window.addEventListener("DOMContentLoaded", init);
|
||||||
|
|
||||||
async function init () {
|
async function init () {
|
||||||
await populateInstances();
|
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 () {
|
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);
|
window.addEventListener("DOMContentLoaded", init);
|
||||||
|
|
||||||
function init (){
|
function init (){
|
||||||
|
deleteAllCookies();
|
||||||
let formSubmitButton = document.querySelector("#submit");
|
let formSubmitButton = document.querySelector("#submit");
|
||||||
let status = document.querySelector("#status");
|
let status = document.querySelector("#status");
|
||||||
formSubmitButton.addEventListener("click", async (e) => {
|
formSubmitButton.addEventListener("click", async (e) => {
|
||||||
|
@ -87,3 +87,7 @@ export function getURIData () {
|
|||||||
let url = new URL(window.location.href);
|
let url = new URL(window.location.href);
|
||||||
return Object.fromEntries(url.searchParams);
|
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