c
This commit is contained in:
+1884
-714
File diff suppressed because one or more lines are too long
+73
-72
@@ -1,20 +1,21 @@
|
|||||||
const TRYNOW_WEBHOOK_URL = "https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c25169c6-4234-4b47-8e74-612b9539da0a";
|
const TRYNOW_WEBHOOK_URL =
|
||||||
|
"https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c25169c6-4234-4b47-8e74-612b9539da0a";
|
||||||
|
|
||||||
function tryNow_createModal() {
|
function tryNow_createModal() {
|
||||||
const modal = document.createElement("div");
|
const modal = document.createElement("div");
|
||||||
modal.id = "trynowModal";
|
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";
|
||||||
modal.style.width = "100%";
|
modal.style.width = "100%";
|
||||||
modal.style.height = "100%";
|
modal.style.height = "100%";
|
||||||
modal.style.backgroundColor = "rgba(0,0,0,0.6)";
|
modal.style.backgroundColor = "rgba(0,0,0,0.6)";
|
||||||
modal.style.display = "none";
|
modal.style.display = "none";
|
||||||
modal.style.justifyContent = "center";
|
modal.style.justifyContent = "center";
|
||||||
modal.style.alignItems = "center";
|
modal.style.alignItems = "center";
|
||||||
modal.style.zIndex = "1000";
|
modal.style.zIndex = "1000";
|
||||||
|
|
||||||
modal.innerHTML = `
|
modal.innerHTML = `
|
||||||
<div style="
|
<div style="
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
padding: 40px 30px;
|
padding: 40px 30px;
|
||||||
@@ -50,7 +51,6 @@ function tryNow_createModal() {
|
|||||||
|
|
||||||
<select name="product" required style="padding: 12px 15px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; outline: none;">
|
<select name="product" required style="padding: 12px 15px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; outline: none;">
|
||||||
<option value="odoo_19" selected>ODOO</option>
|
<option value="odoo_19" selected>ODOO</option>
|
||||||
<option value="N8N">n8n</option>
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<button type="submit" style="
|
<button type="submit" style="
|
||||||
@@ -92,76 +92,77 @@ function tryNow_createModal() {
|
|||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
document.body.appendChild(modal);
|
document.body.appendChild(modal);
|
||||||
|
|
||||||
// Close modal handlers
|
// Close modal handlers
|
||||||
document.getElementById("trynowCloseModal").onclick = () => { modal.style.display = "none"; };
|
document.getElementById("trynowCloseModal").onclick = () => {
|
||||||
document.getElementById("trynowCloseConfirmation").onclick = () => {
|
modal.style.display = "none";
|
||||||
document.getElementById("trynowConfirmation").style.display = "none";
|
};
|
||||||
modal.style.display = "none";
|
document.getElementById("trynowCloseConfirmation").onclick = () => {
|
||||||
};
|
document.getElementById("trynowConfirmation").style.display = "none";
|
||||||
modal.onclick = (e) => { if (e.target === modal) modal.style.display = "none"; };
|
modal.style.display = "none";
|
||||||
|
};
|
||||||
|
modal.onclick = (e) => {
|
||||||
|
if (e.target === modal) modal.style.display = "none";
|
||||||
|
};
|
||||||
|
|
||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryNow_handleFormSubmit() {
|
function tryNow_handleFormSubmit() {
|
||||||
const form = document.getElementById("trynowForm");
|
const form = document.getElementById("trynowForm");
|
||||||
const confirmation = document.getElementById("trynowConfirmation");
|
const confirmation = document.getElementById("trynowConfirmation");
|
||||||
|
|
||||||
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(TRYNOW_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),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (res.ok) {
|
if (res.ok) {
|
||||||
form.style.display = "none";
|
form.style.display = "none";
|
||||||
confirmation.style.display = "block";
|
confirmation.style.display = "block";
|
||||||
form.reset();
|
form.reset();
|
||||||
} else {
|
} else {
|
||||||
alert("Failed to submit form.");
|
alert("Failed to submit form.");
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
alert("Error submitting form.");
|
alert("Error submitting form.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryNow_attachButtons() {
|
function tryNow_attachButtons() {
|
||||||
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();
|
e.preventDefault();
|
||||||
const modal = document.getElementById("trynowModal");
|
const modal = document.getElementById("trynowModal");
|
||||||
if (modal) {
|
if (modal) {
|
||||||
modal.style.display = "flex";
|
modal.style.display = "flex";
|
||||||
// Reset modal state
|
// Reset modal state
|
||||||
const form = document.getElementById("trynowForm");
|
const form = document.getElementById("trynowForm");
|
||||||
const confirmation = document.getElementById("trynowConfirmation");
|
const confirmation = document.getElementById("trynowConfirmation");
|
||||||
if (form && confirmation) {
|
if (form && confirmation) {
|
||||||
form.style.display = "flex";
|
form.style.display = "flex";
|
||||||
confirmation.style.display = "none";
|
confirmation.style.display = "none";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
document.addEventListener("DOMContentLoaded", () => {
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
tryNow_createModal();
|
tryNow_createModal();
|
||||||
tryNow_handleFormSubmit();
|
tryNow_handleFormSubmit();
|
||||||
tryNow_attachButtons();
|
tryNow_attachButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function () {
|
||||||
console.log("WIDGET COOL")
|
console.log("WIDGET COOL");
|
||||||
const currentScript = document.currentScript;
|
const currentScript = document.currentScript;
|
||||||
const affiliateFromAttr = currentScript.getAttribute("data-affiliate");
|
const affiliateFromAttr = currentScript.getAttribute("data-affiliate");
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
<div class="header">
|
<div class="header">
|
||||||
<img class="icon" src="https://sp01.odoo4projects.com/hugo/live/4.svg">
|
<img class="icon" src="https://sp01.odoo4projects.com/hugo/live/4.svg">
|
||||||
<div>
|
<div>
|
||||||
<div class="title">Try Managed ODOO or n8n - 4 weeks Free</div>
|
<div class="title">Try Managed ODOO - 4 weeks Free</div>
|
||||||
<div class="subtitle">Full-featured 4-week trial. No credit card required.</div>
|
<div class="subtitle">Full-featured 4-week trial. No credit card required.</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -106,10 +106,7 @@
|
|||||||
<input type="radio" name="product" value="odoo_19" required checked>
|
<input type="radio" name="product" value="odoo_19" required checked>
|
||||||
<span>ODOO</span>
|
<span>ODOO</span>
|
||||||
</label>
|
</label>
|
||||||
<label class="option">
|
|
||||||
<input type="radio" name="product" value="N8N" required>
|
|
||||||
<span>N8N</span>
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
<label for="location">Location</label>
|
<label for="location">Location</label>
|
||||||
<select id="location" name="location" required>
|
<select id="location" name="location" required>
|
||||||
@@ -149,10 +146,13 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const formData = new FormData(form);
|
const formData = new FormData(form);
|
||||||
const res = await fetch("https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c25169c6-4234-4b47-8e74-612b9539da0a", {
|
const res = await fetch(
|
||||||
method: "POST",
|
"https://002-001-5dd6e535-4d1c-46bc-9bd9-42ad4bc5f082.odoo4projects.com/webhook/c25169c6-4234-4b47-8e74-612b9539da0a",
|
||||||
body: formData,
|
{
|
||||||
});
|
method: "POST",
|
||||||
|
body: formData,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const text = await res.text();
|
const text = await res.text();
|
||||||
|
|
||||||
@@ -168,4 +168,3 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user