Add overnight button

This commit is contained in:
Julian
2022-02-12 21:42:33 +01:00
parent 01e9a263e6
commit b4ca08cb43
2 changed files with 23 additions and 5 deletions

View File

@@ -166,9 +166,9 @@
</span>
</div>
</div>
<div class="row animate-box overnight">
<input type="checkbox" id="overnight" name="overnight" checked>
<label for="overnight">Übernachtungsangebot</label>
<div class="row animate-box overnight" id="overnight-div">
<input class="overnight-js" type="checkbox" name="overnight" checked>
<label for="overnight">Braucht Ihr einen Schlafplatz?</label>
</div>
<div class="row animate-box">
<div class="col-md-4 col-md-offset-4 text-center fh5co-heading">

View File

@@ -306,6 +306,16 @@
$(window).stellar({ horizontalScrolling: false });
};
var defaultUncheckedInputCheckboxes = function() {
var inputs = document.getElementsByTagName('input');
for (var i=0; i<inputs.length; i++) {
if (inputs[i].type == 'checkbox') {
inputs[i].checked = false;
}
}
}
$(function(){
mobileMenuOutsideClick();
@@ -320,6 +330,7 @@
counter();
counterWayPoint();
addField();
defaultUncheckedInputCheckboxes();
});
@@ -366,9 +377,15 @@ document.getElementById("js-submitbtn").addEventListener("click", async function
return;
}
let overnightRequired = false;
if ($('.overnight-js').is(":checked")) {
overnightRequired = true;
}
let family = {
name: lastname,
overnight: true,
overnight: overnightRequired,
telephonenumber: telephonenumber,
email: eMail,
members: []
@@ -418,7 +435,7 @@ document.getElementById("js-submitbtn").addEventListener("click", async function
redirect: 'follow', // manual, *follow, error
referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url
body: JSON.stringify(family) // body data type must match "Content-Type" header
});
}).catch(function (timeout) { SubmitError("API error. Call the phone number."); });
if(response.ok)
{
let jsonResponse = await response.json();
@@ -477,6 +494,7 @@ document.getElementById("js-submitbtn").addEventListener("click", async function
}).catch(function (timeout) { });
document.getElementById("attentant-container").remove();
document.getElementById("overnight-div").remove();
document.getElementById("js-submitbtn").disabled = 'true';
document.getElementById("js-submitbtn").textContent = await translator.getTranslationByKey(document.documentElement.lang,"already_participating");
return;