website/js/customElements/skills.js

20 lines
No EOL
666 B
JavaScript

class Skill extends HTMLElement {
constructor() {
super();
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if (xhr.readyState == 4 && xhr.status == 200) {
JSON.parse(xhr.responseText).forEach(skill => {
const image = document.createElement("img");
image.classList.add("skills");
image.src = "/API/getFile.php?filename=" + skill;
this.appendChild(image);
});
}
}
xhr.open("GET", "/API/skills.php");
xhr.send();
}
}
customElements.define("jl-skills", Skill);