Browse Source

Say hi

hkremer/rebranding
Hopper Kremer 4 years ago
parent
commit
03bcca77f4
  1. 60
      static/app.js

60
static/app.js

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
//Hopper says hi
// Get the modal
const modal = document.getElementById("myModal");
@ -9,10 +9,12 @@ const btn = document.getElementById("myBtn"); @@ -9,10 +9,12 @@ const btn = document.getElementById("myBtn");
const span = document.getElementsByClassName("close")[0];
var mode = new URLSearchParams(window.location.search).get("mode");
const archiveLink = document.querySelector("#archive-link")
const pendingLink = document.querySelector("#pending-link")
const statusLink = document.querySelector("#status-link")
function handleForm(event) { event.preventDefault(); }
const archiveLink = document.querySelector("#archive-link");
const pendingLink = document.querySelector("#pending-link");
const statusLink = document.querySelector("#status-link");
function handleForm(event) {
event.preventDefault();
}
function main() {
archiveLink.classList.remove("active");
@ -30,22 +32,21 @@ function main() { @@ -30,22 +32,21 @@ function main() {
break;
default:
console.log("No mode");
mode = "verifications"
mode = "verifications";
archiveLink.classList.add("active");
break;
}
document.getElementById("main-app").innerHTML = '';
document.getElementById("main-app").innerHTML = "";
fetch(`https://thanos.nightmare.haus/api/${mode}`)
.then(response => response.json())
.then(data => processData(data));
.then((response) => response.json())
.then((data) => processData(data));
}
function statusPage() {
document.getElementById("main-app").innerHTML = '';
document.getElementById("main-app").innerHTML = "";
fetch(`https://thanos.nightmare.haus/api/config`)
.then(response => response.json())
.then(data => {
.then((response) => response.json())
.then((data) => {
var node = document.createElement("config-status");
var upTime = document.createElement("div");
@ -54,26 +55,21 @@ function statusPage() { @@ -54,26 +55,21 @@ function statusPage() {
node.appendChild(upTime);
var bumpTime = document.createElement("div");
bumpTime.setAttribute("slot", "lastbump")
bumpTime.setAttribute("slot", "lastbump");
bumpTime.innerText = new Date(data.BumpTime).toLocaleString();
node.appendChild(bumpTime);
node.setData(data);
document.getElementById("main-app").appendChild(node);
});
}
function searchPage() {
var search = document.getElementById("search-bar");
fetch('https://thanos.nightmare.haus/api/verifications')
.then(response => response.json())
.then(data => {
fetch("https://thanos.nightmare.haus/api/verifications")
.then((response) => response.json())
.then((data) => {
var searchData = [];
for (user of data) {
var match = false;
@ -96,7 +92,7 @@ function searchPage() { @@ -96,7 +92,7 @@ function searchPage() {
}
function processData(data) {
document.getElementById("main-app").innerHTML = '';
document.getElementById("main-app").innerHTML = "";
if (data.length == 0) {
alert("No data.");
return;
@ -111,7 +107,10 @@ function processData(data) { @@ -111,7 +107,10 @@ function processData(data) {
var joinDate = document.createElement("div");
joinDate.setAttribute("slot", "join-date");
joinDate.innerText = mode == "pending" ? new Date(user.Submitted).toLocaleString() : new Date(user.Closed).toLocaleString();
joinDate.innerText =
mode == "pending"
? new Date(user.Submitted).toLocaleString()
: new Date(user.Closed).toLocaleString();
node.appendChild(joinDate);
var discordSlot = document.createElement("div");
@ -123,7 +122,12 @@ function processData(data) { @@ -123,7 +122,12 @@ function processData(data) {
picSlot.setAttribute("slot", "pic-link");
var aNode = document.createElement("a");
aNode.setAttribute("href", mode == "pending" ? user.Photo : `https://thanos.nightmare.haus/${user.Photo}`);
aNode.setAttribute(
"href",
mode == "pending"
? user.Photo
: `https://thanos.nightmare.haus/${user.Photo}`
);
aNode.innerText = "Verification Photo";
picSlot.appendChild(aNode);
@ -135,15 +139,15 @@ function processData(data) { @@ -135,15 +139,15 @@ function processData(data) {
// When the user clicks on <span> (x), close the modal
span.onclick = function () {
modal.style.display = "none";
}
};
// When the user clicks anywhere outside of the modal, close it
window.onclick = function (event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
};
var form = document.getElementById("search-form");
form.addEventListener('submit', handleForm);
form.addEventListener("submit", handleForm);
main();
Loading…
Cancel
Save