Vesttec
(function() {
const CONTAINER_ID = "vestecWebchatContainer";
function ensureContainer() {
const box = document.getElementById(CONTAINER_ID);
if (!box) {
console.warn("[webchat] Container mangler:", CONTAINER_ID);
}
return box;
}
const OPEN_FN = () => {
if (window.vwpOpen) return window.vwpOpen();
const box = ensureContainer(); if (!box) return;
box.hidden = false;
box.style.display = "flex";
box.style.setProperty("visibility", "visible", "important");
requestAnimationFrame(() => (box.style.opacity = "1"));
};
const CLOSE_FN = () => {
if (window.vwpClose) return window.vwpClose();
const box = ensureContainer(); if (!box) return;
box.style.opacity = "0";
setTimeout(() => {
box.style.display = "none";
box.style.setProperty("visibility", "hidden", "important");
box.hidden = true;
}, 200);
};
function ensureLauncherHost() {
let host = document.getElementById("vwp-shadow-launcher-host");
if (!host) {
host = document.createElement("div");
host.id = "vwp-shadow-launcher-host";
host.style.position = "fixed";
host.style.inset = "auto 20px 20px auto";
host.style.zIndex = "2147483647";
document.body.appendChild(host);
}
if (!host.shadowRoot) host.attachShadow({ mode: "open" });
return host;
}
function renderLauncher(shadow) {
shadow.innerHTML = `
💬
`;
const btn = shadow.querySelector(".btn");
const isOpen = () => {
const box = document.getElementById(CONTAINER_ID);
if (!box) return false;
const cs = getComputedStyle(box);
return cs.display !== "none" && cs.opacity !== "0";
};
btn.onclick = (e) => {
e.preventDefault();
isOpen() ? CLOSE_FN() : OPEN_FN();
};
}
function mount() {
const host = ensureLauncherHost();
renderLauncher(host.shadowRoot);
}
mount();
clearInterval(window.__vwpHealShadow);
window.__vwpHealShadow = setInterval(() => {
const host = document.getElementById("vwp-shadow-launcher-host");
if (!host || !host.isConnected) return mount();
host.style.position = "fixed";
host.style.inset = "auto 20px 20px auto";
host.style.zIndex = "2147483647";
if (!host.shadowRoot || !host.shadowRoot.querySelector(".btn")) {
host.shadowRoot || host.attachShadow({ mode: "open" });
renderLauncher(host.shadowRoot);
}
}, 800);
const mo = new MutationObserver(() => {
if (!document.getElementById("vwp-shadow-launcher-host")) {
mount();
}
});
mo.observe(document.documentElement, { childList: true, subtree: true });
console.log("✅ Shadow-launcher aktiv – prøv å klikke på bobla nederst til høyre.");
})();
Loading....