2021-04-12 20:33:24 +02:00
|
|
|
class newComment extends HTMLElement {
|
|
|
|
constructor() {
|
|
|
|
super();
|
2021-09-10 21:16:11 +02:00
|
|
|
this.innerHTML = `
|
|
|
|
<button class="bigButton" id="showCommentButton">Neues Kommentar verfassen</button>
|
|
|
|
`;
|
|
|
|
document.getElementById("showCommentButton").onclick = this.setupForm;
|
2021-04-12 20:33:24 +02:00
|
|
|
}
|
|
|
|
|
2021-09-10 21:22:24 +02:00
|
|
|
async setupForm() {
|
2021-04-12 20:33:24 +02:00
|
|
|
let sitekey = await (await fetch("/API/config.php?name=sitekey")).text();
|
|
|
|
|
2021-09-10 21:22:24 +02:00
|
|
|
let script = document.createElement('script');
|
|
|
|
script.src = "https://hCaptcha.com/1/api.js";
|
|
|
|
script.type = 'text/javascript';
|
|
|
|
script.onload = () => {
|
2021-11-09 12:22:31 +01:00
|
|
|
let pageName = window.location.pathname.split("/").pop();
|
2021-09-10 21:22:24 +02:00
|
|
|
this.parentElement.innerHTML = `
|
|
|
|
<form action="/API/newComment.php" method="post">
|
|
|
|
<label for="name">Name:</label><br>
|
|
|
|
<input type="text" id="name" name="name"><br><br>
|
|
|
|
|
|
|
|
<label for="email">E-Mail: (wird nicht veröffentlicht)</label><br>
|
|
|
|
<input type="text" id="email" name="email"><br><br>
|
|
|
|
|
|
|
|
<label for="comment">Kommentar:</label><br>
|
|
|
|
<textarea name="comment" id="comment"></textarea><br><br>
|
|
|
|
|
|
|
|
<div class="h-captcha" data-theme="dark" data-sitekey="${sitekey}"></div><br>
|
|
|
|
|
2021-11-09 12:18:22 +01:00
|
|
|
<input type="hidden" name="pagename" id="pagename" value="${pageName}">
|
2021-09-10 21:22:24 +02:00
|
|
|
<input type="submit" value="Kommentar veröffentlichen"><br>
|
|
|
|
<p>Mit dem Klick auf den obigen Button erklären sie sich mit der <a href="/datenschutzerklaerung.html">Datenschutzerklärung</a> einverstanden.</p>
|
|
|
|
</form>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
document.body.append(script);
|
2021-04-12 20:33:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-09 12:18:22 +01:00
|
|
|
customElements.define("jl-new_comment", newComment);
|