l
This commit is contained in:
+20
-11
@@ -1,24 +1,31 @@
|
|||||||
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";
|
||||||
|
|
||||||
// --- Helper: Get cookie value ---
|
// --- Helper: Get cookie value ---
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
const value = `; ${document.cookie}`;
|
const value = `; ${document.cookie}`;
|
||||||
const parts = value.split(`; ${name}=`);
|
const parts = value.split(`; ${name}=`);
|
||||||
if (parts.length === 2) return parts.pop().split(';').shift();
|
if (parts.length === 2) return parts.pop().split(";").shift();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Add UTM fields to form ---
|
// --- Add UTM fields to form ---
|
||||||
function addUtmFields(form) {
|
function addUtmFields(form) {
|
||||||
const utmParams = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
|
const utmParams = [
|
||||||
|
"utm_source",
|
||||||
|
"utm_medium",
|
||||||
|
"utm_campaign",
|
||||||
|
"utm_term",
|
||||||
|
"utm_content",
|
||||||
|
];
|
||||||
|
|
||||||
const defaults = {
|
const defaults = {
|
||||||
utm_source: "homepage",
|
utm_source: "homepage",
|
||||||
utm_medium: "direct",
|
utm_medium: "direct",
|
||||||
utm_campaign: "none"
|
utm_campaign: "none",
|
||||||
};
|
};
|
||||||
|
|
||||||
utmParams.forEach(param => {
|
utmParams.forEach((param) => {
|
||||||
let input = form.querySelector(`input[name="${param}"]`);
|
let input = form.querySelector(`input[name="${param}"]`);
|
||||||
if (!input) {
|
if (!input) {
|
||||||
input = document.createElement("input");
|
input = document.createElement("input");
|
||||||
@@ -84,7 +91,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="
|
||||||
@@ -133,12 +139,16 @@ function tryNow_createModal() {
|
|||||||
addUtmFields(form);
|
addUtmFields(form);
|
||||||
|
|
||||||
// Close modal handlers
|
// Close modal handlers
|
||||||
document.getElementById("trynowCloseModal").onclick = () => { modal.style.display = "none"; };
|
document.getElementById("trynowCloseModal").onclick = () => {
|
||||||
|
modal.style.display = "none";
|
||||||
|
};
|
||||||
document.getElementById("trynowCloseConfirmation").onclick = () => {
|
document.getElementById("trynowCloseConfirmation").onclick = () => {
|
||||||
document.getElementById("trynowConfirmation").style.display = "none";
|
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";
|
||||||
|
};
|
||||||
|
|
||||||
return modal;
|
return modal;
|
||||||
}
|
}
|
||||||
@@ -161,7 +171,7 @@ function tryNow_handleFormSubmit() {
|
|||||||
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) {
|
||||||
@@ -181,7 +191,7 @@ function tryNow_handleFormSubmit() {
|
|||||||
// --- Attach "Try Now" buttons ---
|
// --- Attach "Try Now" buttons ---
|
||||||
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();
|
||||||
@@ -209,4 +219,3 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
tryNow_handleFormSubmit();
|
tryNow_handleFormSubmit();
|
||||||
tryNow_attachButtons();
|
tryNow_attachButtons();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user