(function () { function copyNow(value) { var area = document.createElement("textarea"); area.value = value; area.setAttribute("readonly", ""); area.style.position = "fixed"; area.style.top = "0"; area.style.left = "0"; area.style.opacity = "0"; document.body.appendChild(area); area.focus(); area.select(); var ok = false; try { ok = document.execCommand("copy"); } catch (e) { ok = false; } document.body.removeChild(area); return ok; } document.querySelectorAll("[data-copy]").forEach(function (btn) { btn.addEventListener("click", function () { var value = btn.getAttribute("data-copy") || ""; var shown = false; function mark() { if (shown) { return; } shown = true; var old = btn.textContent; btn.textContent = document.body.getAttribute("data-copied") || "Copied"; setTimeout(function () { btn.textContent = old; }, 1200); } if (copyNow(value)) { mark(); } if (navigator.clipboard && window.isSecureContext) { navigator.clipboard.writeText(value).then(mark).catch(function () {}); } }); }); document.querySelectorAll("select[data-rev]").forEach(function (sel) { sel.addEventListener("change", function () { var url = new URL(window.location.href); url.searchParams.set("rev", sel.value); window.location = url.toString(); }); }); var filter = document.querySelector("[data-tree-filter]"); if (filter) { var items = document.querySelectorAll(".treelist li"); filter.addEventListener("input", function () { var q = filter.value.trim().toLowerCase(); var paths = []; items.forEach(function (li) { paths.push((li.getAttribute("data-path") || "").toLowerCase()); }); items.forEach(function (li, i) { if (q === "") { li.hidden = false; return; } var path = paths[i]; if (path.indexOf(q) !== -1) { li.hidden = false; return; } var prefix = path + "/"; var child = false; for (var j = 0; j < paths.length; j++) { if (paths[j].indexOf(prefix) === 0 && paths[j].indexOf(q) !== -1) { child = true; break; } } li.hidden = !child; }); }); if (new URLSearchParams(window.location.search).get("focus") === "1") { filter.focus(); } } })();