add custome element for new comment

This commit is contained in:
Jonas Leder 2021-04-12 20:33:24 +02:00
parent 4fc68e7974
commit fbac380ec4
4 changed files with 35 additions and 22 deletions

View file

@ -0,0 +1,31 @@
class newComment extends HTMLElement {
constructor() {
super();
this.setupForm();
}
async setupForm(){
let sitekey = await (await fetch("/API/config.php?name=sitekey")).text();
this.innerHTML = `
<form action="/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&ouml;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>
<input type="submit" value="Kommentar ver&ouml;ffentlichen"><br>
<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>
`;
}
}
customElements.define("jl-new_comment", newComment);

View file

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

View file

@ -1,5 +1,4 @@
<?php
include "config.php";
$conn = new mysqli($mysqlServer, $mysqlUser, $mysqlPassword, $mysqlDatabase);
// Check connection

View file

@ -2,27 +2,9 @@
function getComments($article){
echo(<<<EOF
<script src='https://www.hCaptcha.com/1/api.js' async defer></script>
<h2>Kommentare:</h2>
<jl-comments_display></jl-comments_display>
<script src='https://www.hCaptcha.com/1/api.js' async defer></script>
<div id="newComment">
<form action="/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&ouml;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>
<input type="submit" value="Kommentar ver&ouml;ffentlichen"><br>
<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>
</div>
<jl-new_comment id="newComment"></jl-new_comment>
EOF);
}