add new custome element for link to mail

This commit is contained in:
Jonas Leder 2021-04-12 20:43:43 +02:00
parent 15c99a4e0c
commit 520ca7abdc
6 changed files with 19 additions and 8 deletions

View file

@ -0,0 +1,14 @@
class contactMailButton extends HTMLElement {
constructor() {
super();
this.addButton();
}
async addButton(){
let sitekey = await (await fetch("/API/config.php?name=sitekey")).text();
this.innerHTML = `E-Mail: <button id="emailButton" class="h-captcha" data-sitekey="${sitekey}" data-callback="onSubmit">laden</button><br>`;
}
}
customElements.define("jl-contact_mail_button", contactMailButton);

View file

@ -24,7 +24,6 @@ class newComment extends HTMLElement {
<p>Mit dem Klick auf den obigen Button erkl&auml;ren sie sich mit der <a href="/datenschutzerklaerung.html">Datenschutzerkl&auml;rung</a> einverstanden.</p>
</form>
`;
}
}

View file

@ -10,4 +10,5 @@ require("./customElements/svgLoader");
require("./customElements/blogFooter");
require("./customElements/blogIndex");
require("./customElements/commentsDisplay");
require("./customElements/newComment");
require("./customElements/newComment");
require("./customElements/contactMailButton");

View file

@ -4,9 +4,6 @@ require "./lib/config.php";
$configValue = $_GET['name'];
switch ($configValue){
case "contactmail":
echo($contactmail);
break;
case "sitekey":
echo($sitekey);
break;

View file

@ -1,5 +1,5 @@
<?php
include("./config.php");
include("./lib/config.php");
$data = array(
'secret' => $secretkey,
'response' => $_POST['h-captcha-response']

View file

@ -8,7 +8,7 @@ getHeader("Impressum", "");
<script src='https://www.hCaptcha.com/1/api.js' async defer></script>
<h2>Impressum</h2>
<p>Jonas Leder</p>
E-Mail: <button id="emailButton" class="h-captcha" data-sitekey="<?php echo($sitekey); ?>" data-callback="onSubmit">laden</button><br>
<jl-contact_mail_button></jl-contact_mail_button>
Matrix: <a href="https://matrix.jonasled.de/invite/#/@jonasled:jonasled.de">@matrix:jonasled.de</a>
<h2>Haftungsausschluss</h2>
@ -33,7 +33,7 @@ getHeader("Impressum", "");
button.parentNode.replaceChild(emailElement, button);
}
};
xmlhttp.open("POST", "/internal/getMail.php", true);
xmlhttp.open("POST", "/API/getMail.php", true);
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send("h-captcha-response=" + token);
};