BlueGit

timfa bluegit

Files

bluegit / internal / server / static / repo.js

repo.js

feat: nieuw-formulier, groepsoverzicht, logo's en talen
timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa · 3 weeks ago
Failed d1203d3b History
repo.js 2.5 KiB Download Raw
1(function () {
2 function copyNow(value) {
3 var area = document.createElement("textarea");
4 area.value = value;
5 area.setAttribute("readonly", "");
6 area.style.position = "fixed";
7 area.style.top = "0";
8 area.style.left = "0";
9 area.style.opacity = "0";
10 document.body.appendChild(area);
11 area.focus();
12 area.select();
13 var ok = false;
14 try {
15 ok = document.execCommand("copy");
16 } catch (e) {
17 ok = false;
18 }
19 document.body.removeChild(area);
20 return ok;
21 }
22 document.querySelectorAll("[data-copy]").forEach(function (btn) {
23 btn.addEventListener("click", function () {
24 var value = btn.getAttribute("data-copy") || "";
25 var shown = false;
26 function mark() {
27 if (shown) {
28 return;
29 }
30 shown = true;
31 var old = btn.textContent;
32 btn.textContent = document.body.getAttribute("data-copied") || "Copied";
33 setTimeout(function () { btn.textContent = old; }, 1200);
34 }
35 if (copyNow(value)) {
36 mark();
37 }
38 if (navigator.clipboard && window.isSecureContext) {
39 navigator.clipboard.writeText(value).then(mark).catch(function () {});
40 }
41 });
42 });
43 document.querySelectorAll("select[data-rev]").forEach(function (sel) {
44 sel.addEventListener("change", function () {
45 var url = new URL(window.location.href);
46 url.searchParams.set("rev", sel.value);
47 window.location = url.toString();
48 });
49 });
50 var filter = document.querySelector("[data-tree-filter]");
51 if (filter) {
52 var items = document.querySelectorAll(".treelist li");
53 filter.addEventListener("input", function () {
54 var q = filter.value.trim().toLowerCase();
55 var paths = [];
56 items.forEach(function (li) {
57 paths.push((li.getAttribute("data-path") || "").toLowerCase());
58 });
59 items.forEach(function (li, i) {
60 if (q === "") {
61 li.hidden = false;
62 return;
63 }
64 var path = paths[i];
65 if (path.indexOf(q) !== -1) {
66 li.hidden = false;
67 return;
68 }
69 var prefix = path + "/";
70 var child = false;
71 for (var j = 0; j < paths.length; j++) {
72 if (paths[j].indexOf(prefix) === 0 && paths[j].indexOf(q) !== -1) {
73 child = true;
74 break;
75 }
76 }
77 li.hidden = !child;
78 });
79 });
80 if (new URLSearchParams(window.location.search).get("focus") === "1") {
81 filter.focus();
82 }
83 }
84})();