Compare commits

...

2 Commits

Author SHA1 Message Date
Hopper Kremer 5b8b01e31a Say hi again 4 years ago
Hopper Kremer 03bcca77f4 Say hi 4 years ago
  1. 60
      static/app.js
  2. 1
      static/components.js

60
static/app.js

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

1
static/components.js

@ -1,3 +1,4 @@
//Hopper says hi again
const basicCard = document.createElement('basic-card'); const basicCard = document.createElement('basic-card');
const configStatus = document.createElement('status'); const configStatus = document.createElement('status');
const style = ` const style = `

Loading…
Cancel
Save