-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
399 lines (335 loc) · 11.6 KB
/
index.html
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<!DOCTYPE html>
<html>
<head>
<title>threestudio Extensions Info</title>
<style>
:root {
--background-color: #f7f7f7;
--text-color: #000;
--link-color: #404068;
--link-hover-color: #5c5c89;
--table-background-color: #fff;
--table-header-color: #c2d2f2;
--table-alt-row: #d7d7d7;
--table-hover-color: #c5c5f5;
--table-border-color: #ddd;
--table-border-alt-color: silver;
}
body {
font-family: Arial, sans-serif;
background-color: var(--background-color);
color: var(--text-color);
margin: 0;
padding: 0;
}
a,
a:link,
a:active,
a:visited {
color: var(--link-color);
}
a:hover {
color: var(--link-hover-color);
}
#nav {
margin: 0 auto;
padding-left: 3vw;
padding-right: 3vw;
}
.tools {
float:right;
padding-right: 3vw;
}
#search-bar {
float: right;
}
#container {
padding-left: 2.5vw;
padding-right: 2.5vw;
}
table {
border-collapse: collapse;
width: 100%;
margin: 20px auto;
border: 1px solid var(--table-border-color);
border-radius: 5px;
background-color: var(--table-background-color);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
overflow: hidden;
}
th, td {
text-align: left;
color: var(--text-color);
padding: 12px;
border-bottom: 1px solid var(--table-border-color);
border: 1px solid var(--table-border-alt-color);
cursor: pointer;
}
th {
background-color: var(--table-header-color);
}
td:first-child {
font-weight: bold;
}
td:last-child {
font-style: italic;
}
tr:hover {
background-color: var(--table-hover-color);
}
.alternate-row {
background-color: var(--table-alt-row);
}
/* Mobile Fixes */
@media screen and (max-width: 1024px) {
#container {
padding-left: 0;
padding-right: 0;
}
}
</style>
</head>
<body>
<br />
<br />
<center><B><font size='20px'>threestudio Extensions Info</font></B></center>
<br />
<div id="nav">
<B>GitHub Repositories:</B> [<a href="https://github.com/threestudio-project/threestudio" target="blank"/>threestudio</a>]
[<a href="https://github.com/threestudio-project/threestudio-extensions" target="blank"/>threestudio-Extensions</a>]
[<a href="https://threestudio-project.github.io/threestudio-extensions/" target="blank"/>threestudio-project.github.io/threestudio-extensions/</a>]
<div id="search-bar">
<label for="searchType">Type:</label>
<select id="searchType">
<option value="All">All</option>
<option value="ID">ID</option>
<option value="Author">Author</option>
<option value="Title">Title</option>
<option value="Description">Description</option>
<option value="Modules">Modules</option>
</select>
<input type="text" id="searchInput" placeholder="Search...">
</div>
</div>
<br />
<div class="tools"><a id="toggleTheme" href="#">Toggle Theme</a></div>
<br />
<br />
<div id="container">
<table id="json-table">
<thead>
<tr>
<th style="width: 20px; text-align: center; border: 1px solid silver">ID</th>
<th style="width: 100px; text-align: center; border: 1px solid silver"></th>
<th style="width: 100px; text-align: center; border: 1px solid silver">Author</th>
<th style="text-align: center; border: 1px solid silver">Title</th>
<th style="width: 100px; text-align: center; border: 1px solid silver">Reference</th>
<th style="text-align: center; border: 1px solid silver">Description</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
<script>
const themeToggle = document.getElementById("toggleTheme");
const lightThemeColors = {
'--background-color': '#f7f7f7',
'--text-color': '#000',
'--link-color': '#34347c',
'--link-hover-color': '#5c5c89',
'--table-background-color': '#fff',
'--table-header-color': '#c2d2f2',
'--table-alt-row': '#d7d7d7',
'--table-hover-color': '#c5c5f5',
'--table-border-color': '#ddd',
'--table-border-alt-color': 'silver'
};
const darkThemeColors = {
'--background-color': '#333',
'--text-color': '#fff',
'--link-color': '#c7c7ed',
'--link-hover-color': '#e3e3fc',
'--table-background-color': '#121212',
'--table-header-color': '#454545',
'--table-alt-row': '#252525',
'--table-hover-color': '#616177',
'--table-border-color': '#5c5c5c',
'--table-border-alt-color': '#555'
};
let originalOrder = [];
document.addEventListener('DOMContentLoaded', async function() {
let sortBy = 'ID';
let sortAscending = true;
async function load() {
let ext_list = await fetch('https://raw.githubusercontent.com/threestudio-project/threestudio-extensions/master/custom-extensions-list.json');
let exts = await ext_list.json();
let node_map = await (await fetch('https://raw.githubusercontent.com/threestudio-project/threestudio-extensions/master/custom-extensions-modules-map.json')).json();
const tableBody = document.querySelector('#json-table tbody');
let alternateColor = false;
exts.custom_nodes.forEach((node, index) => {
node.id = index + 1;
});
function updateTable(items) {
tableBody.innerHTML = '';
items.forEach((item, index) => {
const row = document.createElement('tr');
const nodesRow = document.createElement('tr');
if (alternateColor) {
row.classList.add('alternate-row');
nodesRow.classList.add('alternate-row');
}
alternateColor = !alternateColor;
const node_id = document.createElement('td');
const nodeInfoLabel = document.createElement('td');
const author = document.createElement('td');
const title = document.createElement('td');
const reference = document.createElement('td');
const desc = document.createElement('td');
node_id.setAttribute('rowspan', '2');
node_id.textContent = item.id;
node_id.style.textAlign = 'center';
nodeInfoLabel.innerHTML = "<B>INFO</B>";
author.textContent = item.author;
title.innerHTML = `<a href='${item.reference}' target='blank'>${item.title}</a>`;
reference.innerHTML = `<a href='${item.reference}' target='blank'>${item.reference}</a>`;
desc.innerHTML = item.description;
row.appendChild(node_id);
row.appendChild(nodeInfoLabel);
row.appendChild(author);
row.appendChild(title);
row.appendChild(reference);
row.appendChild(desc);
const nodeRowLabel = document.createElement('td');
const nodes = document.createElement('td');
nodeRowLabel.innerHTML = "<B>Modules</B>";
nodes.setAttribute('colspan', '4');
nodesRow.appendChild(nodeRowLabel);
nodesRow.appendChild(nodes);
tableBody.appendChild(row);
tableBody.appendChild(nodesRow);
var total_nodes = "";
for (let k in item.files) {
let file = item.files[k];
let nodes_in_file = node_map[file];
if (!nodes_in_file)
continue;
for (let n in nodes_in_file[0]) {
if (total_nodes != "")
total_nodes += ", ";
total_nodes += nodes_in_file[0][n];
}
}
if (total_nodes == '')
nodes.textContent = 'N/A';
else
nodes.textContent = total_nodes;
});
}
function handleHeaderClick(category) {
if (sortBy === category) {
sortAscending = !sortAscending;
} else {
sortBy = category;
sortAscending = true;
}
let sortedItems = [...originalOrder]; // Create a copy to preserve the original order
sortedItems.sort((a, b) => {
if (sortBy === 'Title') {
return a.title.localeCompare(b.title);
} else if (sortBy === 'Description') {
return a.description.localeCompare(b.description);
} else if (sortBy === 'Author') {
return a.author.localeCompare(b.author);
} else if (sortBy === 'Reference') {
return a.reference.localeCompare(b.reference);
} else if (sortBy === 'ID') {
return a.id - b.id;
}
});
if (!sortAscending) {
sortedItems.reverse();
}
updateTable(sortedItems);
}
const headers = document.querySelectorAll('#json-table th');
headers.forEach(header => {
header.addEventListener('click', () => {
const category = header.textContent.trim();
handleHeaderClick(category);
});
});
originalOrder = exts.custom_nodes.slice();
updateTable(originalOrder);
const searchInput = document.getElementById("searchInput");
const searchType = document.getElementById("searchType");
searchInput.addEventListener("input", function() {
const searchTerm = searchInput.value.toLowerCase();
const selectedCategory = searchType.value;
const filteredItems = originalOrder.filter(item => {
// Generate node content here cause it was not accessible
let total_nodes = "";
for (let k in item.files) {
let file = item.files[k];
let nodes_in_file = node_map[file];
if (!nodes_in_file)
continue;
for (let n in nodes_in_file[0]) {
if (total_nodes != "")
total_nodes += ", ";
total_nodes += nodes_in_file[0][n];
}
}
const nodesContent = total_nodes.toLowerCase();
return (
item.id.toString().includes(searchTerm) ||
item.author.toLowerCase().includes(searchTerm) ||
item.title.toLowerCase().includes(searchTerm) ||
item.description.toLowerCase().includes(searchTerm) ||
item.reference.toLowerCase().includes(searchTerm) ||
nodesContent.includes(searchTerm)
);
});
filteredItems.sort((a, b) => {
return a.title.localeCompare(b.title); // This should be sorting titles but if searching say "Power" it is not first
});
updateTable(filteredItems);
});
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.has("type")) {
searchType.value = urlParams.get("type");
}
if (urlParams.has("keyword")) {
searchInput.value = urlParams.get("keyword");
searchInput.dispatchEvent(new Event("input"));
}
}
const currentTheme = localStorage.getItem('theme');
if (currentTheme === 'dark') {
const root = document.documentElement;
for (const [property, value] of Object.entries(darkThemeColors)) {
root.style.setProperty(property, value);
}
}
load();
});
themeToggle.addEventListener("click", function(){
const root = document.documentElement;
const currentTheme = localStorage.getItem('theme');
if (currentTheme === 'dark' || currentTheme === null) {
for (const [property, value] of Object.entries(lightThemeColors)) {
root.style.setProperty(property, value);
}
localStorage.setItem('theme', 'light');
} else {
for (const [property, value] of Object.entries(darkThemeColors)) {
root.style.setProperty(property, value);
}
localStorage.setItem('theme', 'dark');
}
});
</script>
</body>
</html>