diff --git a/static/koboldai.css b/static/koboldai.css index 1ede6bd9..08e6c20e 100644 --- a/static/koboldai.css +++ b/static/koboldai.css @@ -1904,27 +1904,13 @@ body { z-index: 9999999; } -.context-token[tooltip]:hover::after { - content: attr(tooltip); - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; - position: fixed; - transition: opacity 0s linear 0.5s; - - - top: calc(var(--mouse-y) * 100vh - 30px); - left: calc(var(--mouse-x) * 100vw); - transform: translate(var(--tooltip_x), var(--tooltip_y_context)) !important; - opacity: 1; - - - padding: 0px 2px; - color: var(--tooltip_text); - background-color: var(--tooltip_background); - - pointer-events: none; - z-index: 9999999; +.tooltip-context-token { + border: none !important; + font-family: monospace !important; + max-width: min-content !important; } + /* Mobile tooltips */ @media (pointer: coarse), (hover: none) { [tooltip]:after { diff --git a/static/koboldai.js b/static/koboldai.js index 6f9702e7..947dd0a3 100644 --- a/static/koboldai.js +++ b/static/koboldai.js @@ -4983,18 +4983,25 @@ let load_substitutions; const tooltip = $e("span", document.body, {id: "tooltip-text", "style.display": "none"}); let tooltipActive = false; - function alterTooltipState(enabled) { + function alterTooltipState(enabled, specialClass=null) { tooltipActive = enabled; tooltip.style.display = enabled ? "block" : "none"; + tooltip.className = specialClass || ""; } function registerElement(el) { // el should have attribute "tooltip" let text = el.getAttribute("tooltip"); + el.setAttribute("wawawa", "yeah") el.addEventListener("mouseenter", function(event) { tooltip.innerText = text; - alterTooltipState(true); + let specialClass = null; + + // Kinda lame + if (this.classList.contains("context-token")) specialClass = "tooltip-context-token"; + + alterTooltipState(true, specialClass); }); el.addEventListener("mouseleave", function(event) { @@ -5014,13 +5021,15 @@ let load_substitutions; } // Use a MutationObserver to catch future tooltips - const observer = new MutationObserver(function(record, observer) { - for (const node of record[0].addedNodes) { - if (!node.hasAttribute("tooltip")) continue; - registerElement(node); + const observer = new MutationObserver(function(records, observer) { + for (const record of records) { + for (const node of record.addedNodes) { + if (node.nodeType !== 1 || !node.hasAttribute("tooltip")) continue; + registerElement(node); + } } }); - observer.observe(document.body, {childList: true}); + observer.observe(document.body, {childList: true, subtree: true}); })(); /* -- Shortcuts -- */