MCPcopy Create free account
hub / github.com/awesome-kusion/rust-code-book / initAll

Function initAll

js/custom.js:8–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

6const data_category_id = "DIC_kwDOH0lTxM4CQ1T0";
7
8var initAll = function () {
9 var path = window.location.pathname;
10 if (path.endsWith("/print.html")) {
11 return;
12 }
13
14 var images = document.querySelectorAll("main img")
15 Array.prototype.forEach.call(images, function (img) {
16 img.addEventListener("click", function () {
17 BigPicture({
18 el: img,
19 });
20 });
21 });
22
23 // Un-active everything when you click it
24 Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) {
25 el.addEventHandler("click", function () {
26 Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) {
27 el.classList.remove("active");
28 });
29 el.classList.add("active");
30 });
31 });
32
33 var updateFunction = function () {
34 var id = null;
35 var elements = document.getElementsByClassName("header");
36 Array.prototype.forEach.call(elements, function (el) {
37 if (window.pageYOffset >= el.offsetTop) {
38 id = el;
39 }
40 });
41
42 Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) {
43 el.classList.remove("active");
44 });
45
46 Array.prototype.forEach.call(document.getElementsByClassName("pagetoc")[0].children, function (el) {
47 if (id == null) {
48 return;
49 }
50 if (id.href.localeCompare(el.href) == 0) {
51 el.classList.add("active");
52 }
53 });
54 };
55
56 var pagetoc = document.getElementsByClassName("pagetoc")[0];
57 var elements = document.getElementsByClassName("header");
58 Array.prototype.forEach.call(elements, function (el) {
59 var link = document.createElement("a");
60
61 // Indent shows hierarchy
62 var indent = "";
63 switch (el.parentElement.tagName) {
64 case "H1":
65 return;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected