website/js/customElements/contactMailButton.js

26 lines
847 B
JavaScript
Raw Normal View History

class contactMailButton extends HTMLElement {
constructor() {
super();
this.addButton();
}
2021-09-26 22:40:39 +02:00
async addButton() {
2022-03-08 09:54:38 +01:00
var graphql = JSON.stringify({
query: "query {\r\n sitekey\r\n}"
})
var requestOptions = {
method: 'POST',
body: graphql,
};
let sitekey = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.sitekey;
2021-05-24 18:19:25 +02:00
console.log(sitekey);
this.innerHTML = `E-Mail: <button id="emailButton" class="h-captcha" data-sitekey="${sitekey}" data-callback="onSubmit">laden</button><br>`;
2021-09-26 22:40:39 +02:00
const script = document.createElement("script");
script.src = "https://hCaptcha.com/1/api.js";
document.head.append(script);
}
}
customElements.define("jl-contact_mail_button", contactMailButton);