show new comment Form only when clicking button, to prevent hcaptcha from loading

This commit is contained in:
Jonas Leder 2021-09-10 19:16:11 +00:00
parent 6cbb0eccc5
commit e0615bf0ed
2 changed files with 18 additions and 2 deletions

View file

@ -1,13 +1,16 @@
class newComment extends HTMLElement {
constructor() {
super();
this.setupForm();
this.innerHTML = `
<button class="bigButton" id="showCommentButton">Neues Kommentar verfassen</button>
`;
document.getElementById("showCommentButton").onclick = this.setupForm;
}
async setupForm(){
let sitekey = await (await fetch("/API/config.php?name=sitekey")).text();
this.innerHTML = `
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>

View file

@ -65,3 +65,16 @@
.emailBox {
display: inline;
}
.bigButton {
background-color: $accent-color;
color: #fff;
text-transform: uppercase;
padding: 15px;
font-size: 14px;
cursor: pointer;
outline: 0;
border: 0;
transition: background-color $link-hover-animation-time linear;
width: 100%;
}