Add thank-you redirect, fix altcha payload read, add /thank-you/ route and page
This commit is contained in:
+9
-15
@@ -34,9 +34,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
|
|
||||||
if (form.elements['website']?.value) return;
|
if (form.elements['website']?.value) return;
|
||||||
|
|
||||||
// Get altcha value from the web component
|
// Get altcha payload -- web component writes a hidden input[name=altcha] into the form
|
||||||
const altchaWidget = document.getElementById('altcha-widget');
|
const altchaInput = form.querySelector('input[name="altcha"]');
|
||||||
const altchaPayload = altchaWidget ? (altchaWidget.value || '') : '';
|
const altchaPayload = altchaInput ? (altchaInput.value || '') : '';
|
||||||
|
if (!altchaPayload) {
|
||||||
|
formStatusDiv.className = 'form-status form-status--error';
|
||||||
|
formStatusDiv.innerHTML = '<p>Spam check not ready. Please wait a moment and try again.</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
name: name,
|
name: name,
|
||||||
@@ -63,18 +68,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
|
|
||||||
if (data.ok) {
|
if (data.ok) {
|
||||||
formStatusDiv.className = 'form-status form-status--success';
|
window.location.href = '/thank-you/';
|
||||||
formStatusDiv.innerHTML = '<p>Thank you! Your message has been sent. We\'ll be in touch soon.</p>';
|
|
||||||
form.reset();
|
|
||||||
if (formLoadedAtInput) {
|
|
||||||
formLoadedAtInput.value = Date.now().toString();
|
|
||||||
}
|
|
||||||
if (window.altcha) {
|
|
||||||
window.altcha = new Altcha({
|
|
||||||
challengeUrl: '/altcha-challenge/',
|
|
||||||
element: document.getElementById('altcha-widget')
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
formStatusDiv.className = 'form-status form-status--error';
|
formStatusDiv.className = 'form-status form-status--error';
|
||||||
formStatusDiv.innerHTML = '<p>' + (data.error || 'An error occurred. Please try again.') + '</p>';
|
formStatusDiv.innerHTML = '<p>' + (data.error || 'An error occurred. Please try again.') + '</p>';
|
||||||
|
|||||||
@@ -92,6 +92,13 @@ http {
|
|||||||
fastcgi_pass 127.0.0.1:9000;
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
location = /thank-you/ {
|
||||||
|
include fastcgi_params;
|
||||||
|
fastcgi_param SCRIPT_FILENAME /var/www/html/src/api/router.php;
|
||||||
|
fastcgi_param QUERY_STRING type=page&slug=thank-you;
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
}
|
||||||
|
|
||||||
set $router /var/www/html/src/api/router.php;
|
set $router /var/www/html/src/api/router.php;
|
||||||
|
|
||||||
location = / {
|
location = / {
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user