diff --git a/index.html b/index.html index 8843182..9d2879d 100644 --- a/index.html +++ b/index.html @@ -418,8 +418,7 @@ diff --git a/script.js b/script.js index ee2ff43..5b75cbc 100644 --- a/script.js +++ b/script.js @@ -583,7 +583,6 @@ var si = 0, var form = document.getElementById('bizForm'); if (!form) return; var success = document.getElementById('bizSuccess'); - var downloadBtn = document.getElementById('bizDownloadBtn'); var submitBtn = document.getElementById('bizSubmitBtn'); form.addEventListener('submit', function (e) { @@ -600,30 +599,35 @@ var si = 0, submitBtn.textContent = 'Generating...'; submitBtn.disabled = true; - fetch('https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/report', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ - description: description, - goals: goals, - challenges: challenges, - has_homepage: hasHomepage, - uses_odoo: usesOdoo, - has_developer: hasDeveloper - }) - }) - .then(function (r) { return r.json().catch(function () { return {}; }); }) - .then(function (data) { - form.style.display = 'none'; - success.style.display = 'block'; - if (data.download_url) { - downloadBtn.href = data.download_url; - downloadBtn.style.display = 'inline-block'; - } - }) - .catch(function () { - submitBtn.textContent = 'Generate My Project Plan \u2192'; - submitBtn.disabled = false; - }); + /* Create a hidden form to POST to the webhook and open response in new window */ + var f = document.createElement('form'); + f.method = 'POST'; + f.action = 'https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/report'; + f.target = '_blank'; + f.style.display = 'none'; + + var fields = { + description: description, + goals: goals, + challenges: challenges, + has_homepage: hasHomepage ? 'true' : 'false', + uses_odoo: usesOdoo ? 'true' : 'false', + has_developer: hasDeveloper ? 'true' : 'false' + }; + for (var key in fields) { + var inp = document.createElement('input'); + inp.type = 'hidden'; + inp.name = key; + inp.value = fields[key]; + f.appendChild(inp); + } + + document.body.appendChild(f); + f.submit(); + f.remove(); + + /* Show success message — download will start automatically */ + form.style.display = 'none'; + success.style.display = 'block'; }); })();