// Code4Scene page behaviour: chart tooltips, the Pareto view toggle, sortable leaderboards, copying the BibTeX.
(function () {
// tooltips: any element with data-tip='{"t": title, "r": [[label, value], ...]}' or plain text
var tip = document.createElement("div"); tip.className = "tip"; document.body.appendChild(tip);
function show(el, e) {
var raw = el.getAttribute("data-tip"), html;
try { var d = JSON.parse(raw); html = "" + d.t + "" + (d.r || []).map(function (r) { return r[0] + ": " + r[1]; }).join("
"); }
catch (err) { html = raw; }
tip.innerHTML = html; tip.classList.add("on"); move(e);
}
function move(e) { tip.style.left = Math.min(innerWidth - 160, Math.max(160, e.clientX)) + "px"; tip.style.top = e.clientY + "px"; }
document.addEventListener("mouseover", function (e) { var el = e.target.closest("[data-tip]"); if (el) show(el, e); });
document.addEventListener("mousemove", function (e) { if (tip.classList.contains("on")) move(e); });
document.addEventListener("mouseout", function (e) { var el = e.target.closest("[data-tip]"); if (el && !el.contains(e.relatedTarget)) tip.classList.remove("on"); });
// chart view toggles: