From 304c20e618d87d226fb3b8bc06ad0fd91e6ce737 Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 12:13:24 +0200 Subject: [PATCH 1/2] setup method to handle logs of submissions --- assets/js/kontaktformular.js | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/assets/js/kontaktformular.js b/assets/js/kontaktformular.js index 449ebe0..a47ef94 100644 --- a/assets/js/kontaktformular.js +++ b/assets/js/kontaktformular.js @@ -107,9 +107,9 @@ function handleMouseMove(event) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = - subjectField.value === "I promised." || -// or if messageField Has string "Hi, this is" in it - messageField.value.startsWith("Hi, this is") || + subjectField.value === 'I promised.' || + // or if messageField Has string "Hi, this is" in it + messageField.value.startsWith('Hi, this is') || !userInteracted || interactionCount === 0 || honeypotInput1.value !== '' || @@ -146,6 +146,26 @@ function checkForBotBehavior() { messageField.value ) } + +// function logSubmission() { +// console.log('in logSubmission()') +// const data = { logData: 'Hi, this is some log data from JavaScript.' } +// fetch('/php/log.php', { +// method: 'POST', +// headers: { +// 'Content-Type': 'application/json', +// }, +// body: JSON.stringify(data), +// }) +// .then((response) => response.json()) +// .then((data) => { +// console.log('Success:', data) +// }) +// .catch((error) => { +// console.error('Error:', error) +// }) +// } +// function handleSubmit(e) { e.preventDefault() @@ -160,6 +180,10 @@ function handleSubmit(e) { const formDataEncoded = new URLSearchParams(formData).toString() const formURL = form.action + '.json' + // logSubmission() + // fakeOut() + // return false + fetch(formURL, { method: 'POST', headers: { From 5c401526bb25f86784ddc3c5ae8e2ece436fb0bf Mon Sep 17 00:00:00 2001 From: Andreas Hnida Date: Mon, 13 May 2024 12:17:54 +0200 Subject: [PATCH 2/2] fixed bestellformular --- assets/js/bestellformular.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/assets/js/bestellformular.js b/assets/js/bestellformular.js index b7c81c8..0467bdd 100644 --- a/assets/js/bestellformular.js +++ b/assets/js/bestellformular.js @@ -43,8 +43,6 @@ const captchaInput = document.querySelectorAll('.captcha-input') const captchaVerifyButton = document.querySelectorAll('.captcha-verify') // Form fields -const subjectField = document.getElementById('subject') -const messageField = document.getElementById('description') const botBadge = document.createElement('div') if (debugEnabled) { @@ -117,9 +115,6 @@ function validateZSRNumber(form) { function checkForBotBehavior() { let timeSpent = (Date.now() - startTime) / 1000 botDetected = - subjectField.value === "I promised." || -// or if messageField Has string "Hi, this is" in it - messageField.value.startsWith("Hi, this is") || !userInteracted || interactionCount === 0 || timeSpent < interactionThreshold ||