This repository was archived by the owner on May 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdocscript.js
More file actions
122 lines (95 loc) · 3.03 KB
/
Copy pathdocscript.js
File metadata and controls
122 lines (95 loc) · 3.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
function docLoad() {
let navBar = document.getElementById("navbar");
let navBarTitle = document.createElement("div");
navBarTitle.id = "navbartitle";
navBarTitle.innerHTML = "<a href='#title'>"+document.getElementById("title").innerHTML+"</a>";
navBar.appendChild(navBarTitle);
let navBarList = document.createElement("ol");
navBar.appendChild(navBarList);
const sections = document.getElementById("description").getElementsByClassName("section");
for (const section of sections) {
let sectionTitle = section.getElementsByClassName("sectitle")[0].innerHTML;
section.id = toCamelCase(sectionTitle);
let navBarSection = document.createElement("li");
navBarList.appendChild(navBarSection);
let sectionTitleDiv = document.createElement("div");
sectionTitleDiv.innerHTML = "<a href='#" + toCamelCase(sectionTitle) + "'>"+sectionTitle+"</a>";
navBarSection.appendChild(sectionTitleDiv);
let sectionList = document.createElement("ul");
navBarSection.appendChild(sectionList);
let unorderedFunctions = {};
const functions = section.querySelectorAll(".function");
for (const func of functions) {
let funcTitle = func.getElementsByClassName("funtitle")[0].innerHTML;
func.id = toCamelCase(funcTitle);
const icons = func.querySelectorAll(".funicons > i");
for (const element of icons) {
loadDocIcon(element);
}
unorderedFunctions[funcTitle] = func;
section.removeChild(func);
}
const orderedFunctions = Object.keys(unorderedFunctions).sort().reduce(
(obj, key) => {
obj.push(unorderedFunctions[key]);
return obj;
},
[]
);
for (const func of orderedFunctions) {
let funcTitle = func.getElementsByClassName("funtitle")[0].innerHTML;
let sectionFunction = document.createElement("li");
sectionList.appendChild(sectionFunction);
let functionTitleDiv = document.createElement("div");
functionTitleDiv.innerHTML = "<a href='#" + toCamelCase(funcTitle) + "'>"+funcTitle+"</a>";
sectionFunction.appendChild(functionTitleDiv);
section.appendChild(func);
}
}
}
function loadDocIcon(element)
{
let img = document.createElement("img");
console.log(element.classList);
let tooltipText = "";
if(element.classList.contains("normalTurtleOnly"))
{
img.src = "../resources/turtle.png";
tooltipText = "Turtles Only";
}
else if(element.classList.contains("swordTurtleOnly"))
{
img.src = "../resources/sword_turtle.png";
tooltipText = "Sword Turtles Only";
}
element.classList.add("tooltip");
let tooltip = document.createElement('span');
tooltip.classList.add('tooltiptext');
tooltip.innerHTML = tooltipText;
element.appendChild(img);
element.appendChild(tooltip);
}
function toCamelCase(text)
{
let result = "";
let previousChar = "a";
for (let i = 0; i < text.length; i++) {
let char = text.charAt(i);
if(previousChar == " ")
{
char = char.toUpperCase();
}
else
{
char = char.toLowerCase();
}
previousChar = char;
if(char != " ")
{
result += char;
}
}
return result;
}
addEventListener("load", docLoad);
hljs.highlightAll();