(function () { if (window.__VIDEOWEGO_LOADED__) return; window.__VIDEOWEGO_LOADED__ = true; console.log("VideoWeGo embed loaded"); const cfg = window.__VIDEOWEGO_CONFIG__ || {}; function normalizeColor(color) { color = (color || "1f73ff").trim(); return color.startsWith("#") ? color : "#" + color; } // SETTINGS (replace with dynamic later if needed) const settings = { target: cfg.target || "undefined", color: normalizeColor(cfg.color), size: parseInt(cfg.size || "64", 10), instanceId: cfg.instanceid || "", position: cfg.location || cfg.position || "top-left", backendUrl: "https://www.videowego.com/videowego/index.html", openMode: "popup", popupWidth: 520, popupHeight: 760 }; if (!settings.target) { console.warn("VideoWeGo: no target set"); return; } // Create root const root = document.createElement("div"); root.id = "videowego-floating-button"; const gap = 24; // Position const pos = { position: "fixed", zIndex: 2147483647, width: settings.size + "px", height: settings.size + "px" }; if (settings.position === "bottom-right") { pos.right = gap + "px"; pos.bottom = gap + "px"; } if (settings.position === "bottom-left") { pos.left = gap + "px"; pos.bottom = gap + "px"; } if (settings.position === "top-right") { pos.right = gap + "px"; pos.top = "1" + gap + "px"; } if (settings.position === "top-left") { pos.left = gap + "px"; pos.top = "1" + gap + "px"; } Object.assign(root.style, pos); // Button const btn = document.createElement("button"); btn.style.width = "100%"; btn.style.height = "100%"; btn.style.borderRadius = "50%"; btn.style.background = settings.color; btn.style.border = "none"; btn.style.cursor = "pointer"; btn.style.boxShadow = "0 10px 28px rgba(0,0,0,.28)"; btn.style.display = "flex"; btn.style.alignItems = "center"; btn.style.justifyContent = "center"; // Icon btn.innerHTML = ` `; // Microhelp popup / tooltip const tooltip = document.createElement("div"); const isUnconfigured = !settings.target || settings.target.trim().toLowerCase() === "username"; tooltip.textContent = isUnconfigured ? "This button is not configured yet. Please see instructions to configure this button." : "Call Us"; tooltip.style.position = "absolute"; tooltip.style.bottom = "calc(100% + 10px)"; tooltip.style.background = "#333"; tooltip.style.color = "#fff"; tooltip.style.padding = "8px 12px"; tooltip.style.borderRadius = "6px"; tooltip.style.fontSize = "13px"; tooltip.style.whiteSpace = "nowrap"; tooltip.style.pointerEvents = "none"; tooltip.style.opacity = "0"; tooltip.style.transition = "opacity 0.2s ease"; tooltip.style.zIndex = "2147483647"; tooltip.style.boxShadow = "0 2px 8px rgba(0,0,0,0.25)"; root.appendChild(tooltip); btn.addEventListener("mouseenter", function () { // Position tooltip based on button location if (root.style.left) { tooltip.style.left = "0"; tooltip.style.right = ""; tooltip.style.transform = "none"; } else if (root.style.right) { tooltip.style.right = "0"; tooltip.style.left = ""; tooltip.style.transform = "none"; } else { tooltip.style.left = "50%"; tooltip.style.right = ""; tooltip.style.transform = "translateX(-50%)"; } tooltip.style.opacity = "1"; }); btn.addEventListener("mouseleave", function () { tooltip.style.opacity = "0"; }); // Build URL function buildUrl() { const url = new URL(settings.backendUrl); url.searchParams.set("go", "1"); url.searchParams.set("to", settings.target); url.searchParams.set("return", "pop"); return url.toString(); } // Click handler btn.onclick = function () { const url = buildUrl(); if (settings.openMode === "popup") { const left = (window.innerWidth - settings.popupWidth) / 2; const top = (window.innerHeight - settings.popupHeight) / 2; const popup = window.open( url, "videowego_call", `width=${settings.popupWidth},height=${settings.popupHeight},left=${left},top=${top}` ); if (!popup) { window.location.href = url; } return; } window.open(url, "_blank"); }; root.appendChild(btn); document.body.appendChild(root); })();