website/js/customElements/svgLoader.js

17 lines
491 B
JavaScript
Raw Normal View History

class svgLoad extends HTMLElement {
constructor(){
super();
let svgName = this.getAttribute("data-name");
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = () => {
if(xhr.readyState === 4 && xhr.status === 200){
this.innerHTML = xhr.responseText;
}
}
2021-05-15 15:04:22 +02:00
xhr.open("GET", "/API/getFile.php?filename=svg/" + svgName + ".svg");
xhr.send();
}
}
customElements.define("jl-svg", svgLoad);