1/* KChat Widget â open/close toggle with lazy-loaded iframe */ 2(function () { 3 var btn = document.getElementById("kchat-btn"); 4 var panel = document.getElementById("kchat-panel"); 5 if (!btn || !panel) return; 6 7 var closeBtn = document.getElementById("kchat-close"); 8 var expandBtn = document.getElementById("kchat-expand"); 9 var badge = document.getElementById("kchat-badge"); 10 var iframe = document.getElementById("kchat-iframe"); 11 var kchatOpen = false; 12 13 function toggleKChat() { 14 kchatOpen = !kchatOpen; 15 16 if (kchatOpen) { 17 // Lazy load -- only fetch on first open 18 if (iframe.getAttribute("src") === "about:blank") { 19 iframe.src = iframe.dataset.src; 20 } 21 panel.classList.add("open"); 22 badge.hidden = true; 23 } else { 24 panel.classList.remove("open"); 25 btn.focus(); 26 } 27 28 document.body.classList.toggle("kchat-open", kchatOpen); 29 panel.setAttribute("aria-hidden", kchatOpen ? "false" : "true"); 30 btn.setAttribute("aria-expanded", kchatOpen ? "true" : "false"); 31 } 32 33 function toggleExpand() { 34 var expanded = panel.classList.toggle("expanded"); 35 expandBtn.setAttribute("aria-pressed", expanded ? "true" : "false"); 36 expandBtn.setAttribute("aria-label", expanded ? "Shrink chat assistant" : "Expand chat assistant"); 37 } 38 39 btn.addEventListener("click", toggleKChat); 40 if (expandBtn) expandBtn.addEventListener("click", toggleExpand); 41 closeBtn.addEventListener("click", toggleKChat); 42 43 // Close panel on Escape key 44 document.addEventListener("keydown", function (e) { 45 if (e.key === "Escape" && kchatOpen) { 46 toggleKChat(); 47 } 48 }); 49 50 window.toggleKChat = toggleKChat; 51})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.