const basicCard = document.createElement('basic-card');
basicCard.innerHTML = `
`;
class UserCard extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.appendChild(basicCard.cloneNode(true));
}
connectedCallback() {
this.shadowRoot.querySelector('#card-container').addEventListener('click', () => this.showModal());
}
showModal() {
const userID = this.shadowRoot.querySelector('#discord-id').assignedNodes()[0].textContent;
const userPic = this.shadowRoot.querySelector("#pic-link").assignedNodes()[0].querySelector("a").getAttribute("href");
fetch('https://thanos.nightmare.haus/api/user?userID=' + userID)
.then(response => response.json())
.then(data => {
if (data === undefined || data === null) {
alert("User not found.");
return;
}
document.querySelector("#myModal").style.display = "block";
document.querySelector('#modal-join').textContent = new Date(data.joined_at).toLocaleString();
document.querySelector('#modal-userID').textContent = data.user.username;
document.querySelector('#modal-avatar').src = `https://cdn.discordapp.com/avatars/${data.user.id}/${data.user.avatar}.png?size=256`;
document.querySelector('#modal-verification').src = userPic;
document.querySelector('#modal-verification').style = "max-height: 500px;";
});
}
}
window.customElements.define('user-card', UserCard);