namespace
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
const WEBHOOK_URL = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c76e6b4e-af2f460d0ffc8e3";
|
const TRYNOW_WEBHOOK_URL = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c25169c6-4234-4b47-8e74-612b9539da0a";
|
||||||
|
|
||||||
function createModal() {
|
function tryNow_createModal() {
|
||||||
const modal = document.createElement("div");
|
const modal = document.createElement("div");
|
||||||
modal.id = "buyNowModal";
|
modal.id = "trynowModal";
|
||||||
modal.style.position = "fixed";
|
modal.style.position = "fixed";
|
||||||
modal.style.top = "0";
|
modal.style.top = "0";
|
||||||
modal.style.left = "0";
|
modal.style.left = "0";
|
||||||
@@ -25,7 +25,7 @@ function createModal() {
|
|||||||
font-family: 'Arial', sans-serif;
|
font-family: 'Arial', sans-serif;
|
||||||
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
box-shadow: 0 10px 25px rgba(0,0,0,0.2);
|
||||||
">
|
">
|
||||||
<span id="closeModal" style="
|
<span id="trynowCloseModal" style="
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 15px;
|
top: 15px;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
@@ -37,10 +37,10 @@ function createModal() {
|
|||||||
|
|
||||||
<h2 style="margin-bottom: 20px; font-size: 24px; color: #333;">Order Details</h2>
|
<h2 style="margin-bottom: 20px; font-size: 24px; color: #333;">Order Details</h2>
|
||||||
|
|
||||||
<form id="buyForm" style="display: flex; flex-direction: column; gap: 15px;">
|
<form id="trynowForm" style="display: flex; flex-direction: column; gap: 15px;">
|
||||||
<input type="email" name="email" placeholder="Email" required style="padding: 12px 15px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; outline: none;">
|
<input type="email" name="email" placeholder="Email" required style="padding: 12px 15px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; outline: none;">
|
||||||
|
|
||||||
<select name="location" id="locationSelect" required style="padding: 12px 15px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; outline: none;">
|
<select name="location" id="trynowLocationSelect" required style="padding: 12px 15px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; outline: none;">
|
||||||
<option value="">Select Location</option>
|
<option value="">Select Location</option>
|
||||||
<option value="Boston">Boston</option>
|
<option value="Boston">Boston</option>
|
||||||
<option value="Manchester">Manchester</option>
|
<option value="Manchester">Manchester</option>
|
||||||
@@ -51,7 +51,7 @@ function createModal() {
|
|||||||
<option value="N8N">N8N</option>
|
<option value="N8N">N8N</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<button id="submitBuy" type="submit" style="
|
<button type="submit" style="
|
||||||
padding: 14px;
|
padding: 14px;
|
||||||
background: #007BFF;
|
background: #007BFF;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@@ -64,7 +64,7 @@ function createModal() {
|
|||||||
">Send Order</button>
|
">Send Order</button>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div id="confirmation" style="
|
<div id="trynowConfirmation" style="
|
||||||
display: none;
|
display: none;
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
padding: 20px;
|
padding: 20px;
|
||||||
@@ -75,7 +75,7 @@ function createModal() {
|
|||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
">
|
">
|
||||||
<p>Thank you for your submission! 🎉</p>
|
<p>Thank you for your submission! 🎉</p>
|
||||||
<button id="closeConfirmation" style="
|
<button id="trynowCloseConfirmation" style="
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
padding: 10px 20px;
|
padding: 10px 20px;
|
||||||
background: #007BFF;
|
background: #007BFF;
|
||||||
@@ -92,9 +92,10 @@ function createModal() {
|
|||||||
|
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
document.getElementById("closeModal").onclick = () => { modal.style.display = "none"; };
|
// Close modal handlers
|
||||||
document.getElementById("closeConfirmation").onclick = () => {
|
document.getElementById("trynowCloseModal").onclick = () => { modal.style.display = "none"; };
|
||||||
document.getElementById("confirmation").style.display = "none";
|
document.getElementById("trynowCloseConfirmation").onclick = () => {
|
||||||
|
document.getElementById("trynowConfirmation").style.display = "none";
|
||||||
modal.style.display = "none";
|
modal.style.display = "none";
|
||||||
};
|
};
|
||||||
modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; };
|
modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; };
|
||||||
@@ -102,22 +103,17 @@ function createModal() {
|
|||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openModal() {
|
function tryNow_handleFormSubmit() {
|
||||||
document.getElementById("buyNowModal").style.display = "flex";
|
const form = document.getElementById("trynowForm");
|
||||||
}
|
const confirmation = document.getElementById("trynowConfirmation");
|
||||||
|
|
||||||
function handleFormSubmit() {
|
|
||||||
const form = document.getElementById("buyForm");
|
|
||||||
const confirmation = document.getElementById("confirmation");
|
|
||||||
|
|
||||||
form.addEventListener("submit", async (e) => {
|
form.addEventListener("submit", async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const data = {};
|
const data = {};
|
||||||
new FormData(form).forEach((value, key) => (data[key] = value));
|
new FormData(form).forEach((value, key) => (data[key] = value));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await fetch(WEBHOOK_URL, {
|
const res = await fetch(TRYNOW_WEBHOOK_URL, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
body: JSON.stringify(data)
|
body: JSON.stringify(data)
|
||||||
@@ -137,25 +133,23 @@ function handleFormSubmit() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function tryNow_attachButtons() {
|
||||||
function attachButtons() {
|
|
||||||
// Select all <a> or <button> elements that include "Try Now" in text
|
|
||||||
const buttons = Array.from(document.querySelectorAll("a, button"));
|
const buttons = Array.from(document.querySelectorAll("a, button"));
|
||||||
buttons.forEach(btn => {
|
buttons.forEach(btn => {
|
||||||
if (btn.textContent && btn.textContent.trim() === "Try Now") {
|
if (btn.textContent && btn.textContent.trim() === "Try Now") {
|
||||||
btn.addEventListener("click", (e) => {
|
btn.addEventListener("click", (e) => {
|
||||||
e.preventDefault(); // Prevent link jump
|
e.preventDefault();
|
||||||
const modal = document.getElementById("buyNowModal");
|
const modal = document.getElementById("trynowModal");
|
||||||
if (modal) modal.style.display = "flex";
|
if (modal) modal.style.display = "flex";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
createModal();
|
tryNow_createModal();
|
||||||
handleFormSubmit();
|
tryNow_handleFormSubmit();
|
||||||
attachButtons();
|
tryNow_attachButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user