26 lines
No EOL
837 B
JavaScript
26 lines
No EOL
837 B
JavaScript
class contactMailButton extends HTMLElement {
|
|
constructor() {
|
|
super();
|
|
this.addButton();
|
|
|
|
}
|
|
|
|
async addButton() {
|
|
var graphql = JSON.stringify({
|
|
query: "query {sitekey}"
|
|
})
|
|
var requestOptions = {
|
|
method: 'POST',
|
|
body: graphql,
|
|
};
|
|
|
|
let sitekey = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.sitekey;
|
|
console.log(sitekey);
|
|
this.innerHTML = `E-Mail: <button id="emailButton" class="h-captcha" data-sitekey="${sitekey}" data-callback="onSubmit">laden</button><br>`;
|
|
const script = document.createElement("script");
|
|
script.src = "https://hCaptcha.com/1/api.js";
|
|
document.head.append(script);
|
|
}
|
|
}
|
|
|
|
customElements.define("jl-contact_mail_button", contactMailButton); |