website/js/customElements/ebkBanner.js

27 lines
923 B
JavaScript
Raw Normal View History

class ebkBanner extends HTMLElement {
constructor(){
super();
2022-03-08 13:42:03 +01:00
this.generateBanner();
}
2022-03-08 13:42:03 +01:00
async generateBanner() {
var graphql = JSON.stringify({
query: 'query { ebayKleinanzeigen{ count }}',
})
var requestOptions = {
method: 'POST',
body: graphql,
2022-04-07 09:24:06 +02:00
headers: { 'Content-Type': 'application/json' }
2022-03-08 13:42:03 +01:00
};
2022-03-15 08:49:36 +01:00
let elementCount = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.count;
2022-03-08 13:42:03 +01:00
if(elementCount > 0) {
const h2 = document.createElement("h2");
h2.classList.add("red");
2022-03-18 08:13:51 +01:00
h2.innerHTML = "Ich biete aktuell verschiedene Artikel zum verkauf an, eine genaue Übersicht ist <a class=\"red\" href=\"/selling.html\">hier</a> zu sehen."
2022-03-08 13:42:03 +01:00
this.appendChild(h2);
}
}
}
2022-02-09 14:42:31 +01:00
customElements.define("jl-ebk-banner", ebkBanner);