mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
fix(n8n Form Node): Redirection update (no-changelog) (#13104)
Co-authored-by: Dana <152518854+dana-gill@users.noreply.github.com>
This commit is contained in:
@@ -28,6 +28,8 @@
|
||||
<body>
|
||||
{{#if responseText}}
|
||||
{{{responseText}}}
|
||||
{{else if redirectUrl}}
|
||||
<div>Redirecting to <a href='{{redirectUrl}}'>{{redirectUrl}}</a></div>
|
||||
{{else}}
|
||||
<div class='container'>
|
||||
<section>
|
||||
@@ -73,9 +75,40 @@
|
||||
</section>
|
||||
</div>
|
||||
{{/if}}
|
||||
<script>
|
||||
fetch('', { method: 'POST', body: {}, }).catch(() => {});
|
||||
</script>
|
||||
{{#if redirectUrl}}
|
||||
<a id='redirectUrl' href='{{redirectUrl}}' style='display: none;'></a>
|
||||
{{/if}}
|
||||
<script>
|
||||
fetch('', {
|
||||
method: 'POST',
|
||||
body: {}
|
||||
})
|
||||
.then(async function (response) {
|
||||
if (response.status === 200) {
|
||||
const redirectUrl = document.getElementById("redirectUrl");
|
||||
if (redirectUrl) {
|
||||
window.location.replace(redirectUrl.href);
|
||||
}
|
||||
}
|
||||
|
||||
const text = await response.text();
|
||||
let json;
|
||||
|
||||
try {
|
||||
json = JSON.parse(text);
|
||||
} catch (e) {}
|
||||
|
||||
if (json?.redirectURL) {
|
||||
const url = json.redirectURL.includes("://")
|
||||
? json.redirectURL
|
||||
: "https://" + json.redirectURL;
|
||||
window.location.replace(url);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -779,14 +779,20 @@
|
||||
if (json?.redirectURL) {
|
||||
const url = json.redirectURL.includes("://") ? json.redirectURL : "https://" + json.redirectURL;
|
||||
window.location.replace(url);
|
||||
} else if (json?.formSubmittedText) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (json?.formSubmittedText) {
|
||||
form.style.display = 'none';
|
||||
document.querySelector('#submitted-form').style.display = 'block';
|
||||
document.querySelector('#submitted-content').textContent = json.formSubmittedText;
|
||||
} else {
|
||||
document.body.innerHTML = text;
|
||||
return;
|
||||
}
|
||||
|
||||
if (text) {
|
||||
document.body.innerHTML = text;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.status === 200) {
|
||||
@@ -814,18 +820,6 @@
|
||||
.catch(function (error) {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
|
||||
const isWaitingForm = window.location.href.includes('form-waiting');
|
||||
if(isWaitingForm) {
|
||||
const interval = setInterval(function() {
|
||||
const isSubmited = document.querySelector('#submitted-form').style.display;
|
||||
if(isSubmited === 'block') {
|
||||
clearInterval(interval);
|
||||
return;
|
||||
}
|
||||
window.location.reload();
|
||||
}, 2000);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user