-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui-update.js
39 lines (32 loc) · 1.18 KB
/
ui-update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
let UIUpdate = {};
UIUpdate.loggedIn = function(token) {
UIUpdate.alertBox(`Just logged in<br>Token:<br>${localStorage.getItem("access_token")}`);
loginModalBtn.classList.add("d-none");
logoutBtn.classList.remove("d-none");
};
UIUpdate.loggedOut = function() {
localStorage.removeItem("access_token");
loginModalBtn.classList.remove("d-none");
logoutBtn.classList.add("d-none");
};
UIUpdate.routeChange = function() {
if (document.querySelector(".navbar-nav li.active")) {
document.querySelector(".navbar-nav li.active").classList.remove("active");
}
document.querySelector(".navbar [data-route='#" + window.location.hash.replace("#", "") + "']").classList.add("active");
};
UIUpdate.updateCat = function(status) {
const httpCat = document.querySelector("#httpcat");
httpCat.src = "http://http.cat/" + status;
};
UIUpdate.alertBox = function(message) {
const alertBox = document.querySelector(".alert");
alertBox.innerHTML = message;
};
UIUpdate.getUsernamePassword = function() {
return {
username: document.querySelector("#username").value,
password: document.querySelector("#password").value
}
};
window.addEventListener("hashchange", UIUpdate.routeChange);