CSNET commited on
Commit
2369ce8
·
verified ·
1 Parent(s): 15ad0e6

ชื่อโปรเจกต์: Binary MLM Tree Viewer Mockupเป้าหมาย: สร้างไฟล์ HTML5 เดี่ยว (.html) ที่ประกอบด้วย HTML, CSS และ JavaScript ทั้งหมด เพื่อจำลองการแสดงผังสายงาน MLM แบบ Binary ที่มีคุณสมบัติการแสดงผลและโต้ตอบขั้นสูง📝 รายละเอียด Prompt1. โครงสร้างไฟล์ (File Structure)ต้องเป็น ไฟล์ HTML5 เดี่ยว (index.html หรือชื่ออื่นตามสะดวก)HTML, CSS, และ JavaScript ทั้งหมดต้องอยู่ในไฟล์เดียวCSS ต้องอยู่ในแท็ก <style> ภายใน <head>.JavaScript ต้องอยู่ในแท็ก <script> ภายใน <body> หรือ <head>.2. เทคโนโลยีที่ใช้ (Technology Stack)HTML5: สำหรับโครงสร้างCSS3: สำหรับการจัดรูปแบบและการแสดงผลผัง (ใช้ Flexbox หรือ Grid/Custom Properties เพื่อความยืดหยุ่น)Vanilla JavaScript (ES6+): สำหรับการจัดการข้อมูล, การสร้าง/อัปเดต DOM, และการโต้ตอบของผู้ใช้ ห้ามใช้ Library/Framework ภายนอก เช่น React, Vue, jQuery, หรือ D3.js.3. ข้อมูลจำลอง (Mock Data)สร้างโครงสร้างข้อมูล JavaScript (เช่น อาร์เรย์ของอ็อบเจกต์ หรืออ็อบเจกต์ที่ใช้ ID/ParentID) เพื่อจำลองสมาชิกอย่างน้อย 15-20 คน โดยมีการเชื่อมโยงแบบ Binary และรวมรายละเอียดดังนี้:FieldDescriptionTypeExampleidรหัสสมาชิกNumber/String1parentIdรหัสสมาชิกที่แนะนำ (null สำหรับ Root)Number/String1 (parent of 3)sideตำแหน่งในผัง: "L" (ซ้าย) หรือ "R" (ขวา)String"L"nameชื่อสมาชิกString"Tony Stark"positionตำแหน่ง/Rank ในบริษัทString"Diamond"avatarUrlURL รูปโปรไฟล์จำลอง (ใช้ Placeholder Image URL)Stringhttps://via.placeholder.com/50scoreLeftคะแนนสะสมทีมซ้ายNumber15,000scoreRightคะแนนสะสมทีมขวาNumber22,500isExpandedสถานะการขยายผังย่อย (ค่าเริ่มต้นเป็น true/false)Booleantruedetailsรายละเอียดอื่นๆ (ใช้แสดงใน Popover/Tooltip)String"Joined: 2024/01/01"4. คุณสมบัติการแสดงผล (Visual Features)Node (กล่องสมาชิก): แต่ละกล่องต้องแสดง:รูปโปรไฟล์ (Avatar)ชื่อ และ ตำแหน่ง (Rank)คะแนนซ้าย/ขวา ที่ชัดเจนLayout: จัดเรียงแบบผัง Binary Tree ที่สวยงามและชัดเจน (ใช้ CSS สำหรับการเชื่อมต่อเส้น)การเชื่อมต่อ: ต้องมีเส้นเชื่อมโยงจาก parentId ไปยังลูกทั้งซ้ายและขวาอย่างชัดเจน.5. คุณสมบัติการโต้ตอบ (Interactive Features)การย่อ/ขยาย/หุบผัง (Expand/Collapse):แต่ละ Node ต้องมีปุ่ม/ไอคอนที่ให้ผู้ใช้ คลิกเพื่อซ่อน (Collapse) หรือ แสดง (Expand) สมาชิกที่อยู่ภายใต้ Node นั้นๆ.การหุบจะซ่อนทั้ง Subtree.การดูรายละเอียดเพิ่มเติม (Tooltip/Popover):เมื่อ Hover หรือคลิก ที่ Node ให้แสดงรายละเอียดเพิ่มเติมจากฟิลด์ details (เช่น Popover ขนาดเล็ก).การเลื่อนดูจำนวนมากๆ (Horizontal Scrolling):ผังต้องสามารถขยายออกทางด้านข้างได้ (กรณีมีสมาชิกจำนวนมาก) และมีแถบ Scrollbar แนวนอน เพื่อให้ดูผังทั้งหมดได้.Zoom (Optional but recommended):หากเป็นไปได้ ให้มีการจำลองการ Zoom-in/Zoom-out โดยการใช้ CSS transform: scale() หรือการจัดการขนาด Font/Node ผ่าน JavaScript.6. ข้อจำกัดที่สำคัญ (Critical Constraints)ห้ามใช้ JS Library ภายนอกห้ามใช้ CSS Frameworks (เช่น Bootstrap, Tailwind)ห้ามมีไฟล์ JS หรือ CSS แยก (ทุกอย่างต้องอยู่ในไฟล์ .html เดียวเท่านั้น)🚀 สิ่งที่ต้องการจากการตอบกลับโค้ด HTML5 ที่ทำงานได้เต็มรูปแบบ (Full working HTML5 file) พร้อมข้อมูลจำลองและฟังก์ชัน JavaScript ข้างต้น เพื่อเป็น Mockup ที่พร้อมใช้งานทันที

Browse files
Files changed (2) hide show
  1. README.md +7 -4
  2. index.html +421 -19
README.md CHANGED
@@ -1,10 +1,13 @@
1
  ---
2
  title: Binary Bloom Tree Explorer
3
- emoji: 🔥
4
- colorFrom: green
5
- colorTo: yellow
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
1
  ---
2
  title: Binary Bloom Tree Explorer
3
+ colorFrom: pink
4
+ colorTo: purple
5
+ emoji: 🐳
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite-v3
10
  ---
11
 
12
+ # Welcome to your new DeepSite project!
13
+ This project was created with [DeepSite](https://huggingface.co/deepsite).
index.html CHANGED
@@ -1,19 +1,421 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Binary Bloom Tree Explorer</title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <style>
8
+ :root {
9
+ --primary: #10b981;
10
+ --primary-dark: #059669;
11
+ --secondary: #3b82f6;
12
+ --secondary-dark: #1d4ed8;
13
+ --bg: #f3f4f6;
14
+ --surface: #ffffff;
15
+ --text: #1f2937;
16
+ --text-muted: #6b7280;
17
+ --line: #d1d5db;
18
+ --danger: #ef4444;
19
+ --success: #22c55e;
20
+ --warning: #f59e0b;
21
+ }
22
+
23
+ * {
24
+ margin: 0;
25
+ padding: 0;
26
+ box-sizing: border-box;
27
+ }
28
+
29
+ body {
30
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
31
+ background: var(--bg);
32
+ color: var(--text);
33
+ overflow-x: hidden;
34
+ }
35
+
36
+ header {
37
+ background: var(--surface);
38
+ box-shadow: 0 2px 8px rgba(0,0,0,.05);
39
+ padding: 1rem 2rem;
40
+ display: flex;
41
+ align-items: center;
42
+ gap: 1rem;
43
+ position: sticky;
44
+ top: 0;
45
+ z-index: 10;
46
+ }
47
+
48
+ header h1 {
49
+ font-size: 1.5rem;
50
+ font-weight: 600;
51
+ color: var(--primary-dark);
52
+ }
53
+
54
+ .controls {
55
+ display: flex;
56
+ gap: 1rem;
57
+ align-items: center;
58
+ margin-left: auto;
59
+ }
60
+
61
+ .controls button {
62
+ border: none;
63
+ background: var(--primary);
64
+ color: #fff;
65
+ padding: .5rem 1rem;
66
+ border-radius: .5rem;
67
+ font-size: .875rem;
68
+ cursor: pointer;
69
+ transition: .2s;
70
+ }
71
+
72
+ .controls button:hover {
73
+ background: var(--primary-dark);
74
+ }
75
+
76
+ .controls .zoom {
77
+ display: flex;
78
+ align-items: center;
79
+ gap: .5rem;
80
+ font-size: .875rem;
81
+ }
82
+
83
+ .controls .zoom span {
84
+ width: 2rem;
85
+ text-align: center;
86
+ font-weight: 600;
87
+ }
88
+
89
+ .tree-wrapper {
90
+ margin: 2rem;
91
+ overflow-x: auto;
92
+ padding-bottom: 2rem;
93
+ }
94
+
95
+ .tree {
96
+ display: inline-block;
97
+ min-width: 100%;
98
+ padding: 1rem;
99
+ transform-origin: top left;
100
+ transition: transform .3s;
101
+ }
102
+
103
+ .node {
104
+ display: flex;
105
+ flex-direction: column;
106
+ align-items: center;
107
+ position: relative;
108
+ padding: 1rem 0;
109
+ }
110
+
111
+ .node-content {
112
+ position: relative;
113
+ background: var(--surface);
114
+ padding: .75rem;
115
+ border-radius: 1rem;
116
+ box-shadow: 0 4px 12px rgba(0,0,0,.08);
117
+ width: 240px;
118
+ display: flex;
119
+ flex-direction: column;
120
+ align-items: center;
121
+ gap: .5rem;
122
+ transition: .2s;
123
+ z-index: 2;
124
+ }
125
+
126
+ .node-content:hover {
127
+ transform: translateY(-2px);
128
+ box-shadow: 0 6px 20px rgba(0,0,0,.12);
129
+ }
130
+
131
+ .avatar {
132
+ width: 60px;
133
+ height: 60px;
134
+ border-radius: 50%;
135
+ object-fit: cover;
136
+ border: 3px solid var(--primary);
137
+ }
138
+
139
+ .info {
140
+ text-align: center;
141
+ }
142
+
143
+ .info .name {
144
+ font-weight: 600;
145
+ font-size: 1rem;
146
+ }
147
+
148
+ .info .rank {
149
+ font-size: .75rem;
150
+ color: var(--text-muted);
151
+ margin-bottom: .25rem;
152
+ }
153
+
154
+ .scores {
155
+ display: flex;
156
+ justify-content: space-between;
157
+ width: 100%;
158
+ gap: .5rem;
159
+ }
160
+
161
+ .score {
162
+ flex: 1;
163
+ background: var(--bg);
164
+ border-radius: .5rem;
165
+ padding: .5rem;
166
+ text-align: center;
167
+ font-size: .75rem;
168
+ }
169
+
170
+ .score span {
171
+ font-weight: 700;
172
+ color: var(--primary-dark);
173
+ }
174
+
175
+ .controls-node {
176
+ position: absolute;
177
+ top: -.5rem;
178
+ right: -.5rem;
179
+ display: flex;
180
+ gap: .25rem;
181
+ }
182
+
183
+ .controls-node button {
184
+ background: var(--primary);
185
+ color: #fff;
186
+ border: none;
187
+ width: 24px;
188
+ height: 24px;
189
+ border-radius: 50%;
190
+ cursor: pointer;
191
+ font-size: .75rem;
192
+ display: flex;
193
+ align-items: center;
194
+ justify-content: center;
195
+ transition: .2s;
196
+ }
197
+
198
+ .controls-node button:hover {
199
+ background: var(--primary-dark);
200
+ }
201
+
202
+ .children {
203
+ display: flex;
204
+ justify-content: center;
205
+ position: relative;
206
+ margin-top: 2rem;
207
+ }
208
+
209
+ .children::before {
210
+ content: "";
211
+ position: absolute;
212
+ top: -1rem;
213
+ left: 50%;
214
+ width: 2px;
215
+ height: 1rem;
216
+ background: var(--line);
217
+ }
218
+
219
+ .children .node {
220
+ position: relative;
221
+ margin: 0 1rem;
222
+ }
223
+
224
+ .children .node::before {
225
+ content: "";
226
+ position: absolute;
227
+ top: -1rem;
228
+ left: 50%;
229
+ width: 2px;
230
+ height: 1rem;
231
+ background: var(--line);
232
+ }
233
+
234
+ .children .node:first-child::after,
235
+ .children .node:last-child::after {
236
+ content: "";
237
+ position: absolute;
238
+ top: -1rem;
239
+ width: 50%;
240
+ height: 2px;
241
+ background: var(--line);
242
+ }
243
+
244
+ .children .node:first-child::after {
245
+ right: 50%;
246
+ }
247
+
248
+ .children .node:last-child::after {
249
+ left: 50%;
250
+ }
251
+
252
+ .hiddenSubtree > .children {
253
+ display: none;
254
+ }
255
+
256
+ .tooltip {
257
+ position: absolute;
258
+ top: 110%;
259
+ background: var(--surface);
260
+ font-size: .75rem;
261
+ padding: .5rem .75rem;
262
+ border-radius: .5rem;
263
+ box-shadow: 0 4px 12px rgba(0,0,0,.15);
264
+ pointer-events: none;
265
+ opacity: 0;
266
+ transform: translateY(-4px);
267
+ transition: .2s;
268
+ z-index: 3;
269
+ white-space: nowrap;
270
+ }
271
+
272
+ .node-content:hover .tooltip {
273
+ opacity: 1;
274
+ transform: translateY(0);
275
+ }
276
+
277
+ @media (max-width: 600px) {
278
+ .node-content {
279
+ width: 160px;
280
+ }
281
+
282
+ .avatar {
283
+ width: 48px;
284
+ height: 48px;
285
+ }
286
+
287
+ .scores {
288
+ flex-direction: column;
289
+ gap: .25rem;
290
+ }
291
+ }
292
+ </style>
293
+ </head>
294
+ <body>
295
+ <header>
296
+ <h1>Binary Bloom Tree Explorer</h1>
297
+ <div class="controls">
298
+ <button id="expandAll">Expand All</button>
299
+ <button id="collapseAll">Collapse All</button>
300
+ <div class="zoom">
301
+ <button id="zoomOut">-</button>
302
+ <span id="zoomLevel">100%</span>
303
+ <button id="zoomIn">+</button>
304
+ </div>
305
+ </div>
306
+ </header>
307
+
308
+ <div class="tree-wrapper">
309
+ <div id="tree" class="tree"></div>
310
+ </div>
311
+
312
+ <script>
313
+ const mockData = [
314
+ { id: 1, parentId: null, side: null, name: "Natasha Romanoff", position: "Crown Diamond", avatarUrl: "https://i.pravatar.cc/150?img=47", scoreLeft: 125000, scoreRight: 132000, isExpanded: true, details: "Joined: 2020-03-15, Country: USA" },
315
+ { id: 2, parentId: 1, side: "L", name: "Steve Rogers", position: "Diamond", avatarUrl: "https://i.pravatar.cc/150?img=32", scoreLeft: 48000, scoreRight: 55000, isExpanded: true, details: "Joined: 2021-01-05, Country: USA" },
316
+ { id: 3, parentId: 1, side: "R", name: "Tony Stark", position: "Ruby", avatarUrl: "https://i.pravatar.cc/150?img=11", scoreLeft: 39000, scoreRight: 42000, isExpanded: true, details: "Joined: 2021-02-18, Country: USA" },
317
+ { id: 4, parentId: 2, side: "L", name: "Bruce Banner", position: "Emerald", avatarUrl: "https://i.pravatar.cc/150?img=28", scoreLeft: 21000, scoreRight: 19500, isExpanded: true, details: "Joined: 2021-09-10, Country: USA" },
318
+ { id: 5, parentId: 2, side: "R", name: "Clint Barton", position: "Sapphire", avatarUrl: "https://i.pravatar.cc/150?img=15", scoreLeft: 18000, scoreRight: 22000, isExpanded: false, details: "Joined: 2022-03-22, Country: USA" },
319
+ { id: 6, parentId: 3, side: "L", name: "Peter Parker", position: "Platinum", avatarUrl: "https://i.pravatar.cc/150?img=54", scoreLeft: 15000, scoreRight: 16500, isExpanded: true, details: "Joined: 2022-05-14, Country: USA" },
320
+ { id: 7, parentId: 3, side: "R", name: "Carol Danvers", position: "Gold", avatarUrl: "https://i.pravatar.cc/150?img=44", scoreLeft: 12000, scoreRight: 13500, isExpanded: false, details: "Joined: 2022-07-09, Country: USA" },
321
+ { id: 8, parentId: 4, side: "L", name: "T'Challa", position: "Silver", avatarUrl: "https://i.pravatar.cc/150?img=33", scoreLeft: 8000, scoreRight: 7500, isExpanded: true, details: "Joined: 2023-01-30, Country: Wakanda" },
322
+ { id: 9, parentId: 4, side: "R", name: "Wanda Maximoff", position: "Silver", avatarUrl: "https://i.pravatar.cc/150?img=41", scoreLeft: 7000, scoreRight: 8500, isExpanded: false, details: "Joined: 2023-03-11, Country: Sokovia" },
323
+ { id: 10, parentId: 5, side: "L", name: "Sam Wilson", position: "Bronze", avatarUrl: "https://i.pravatar.cc/150?img=52", scoreLeft: 4200, scoreRight: 3800, isExpanded: false, details: "Joined: 2023-06-25, Country: USA" },
324
+ { id: 11, parentId: 5, side: "R", name: "Scott Lang", position: "Bronze", avatarUrl: "https://i.pravatar.cc/150?img=29", scoreLeft: 3600, scoreRight: 4100, isExpanded: false, details: "Joined: 2023-08-03, Country: USA" },
325
+ { id: 12, parentId: 6, side: "L", name: "Hope van Dyne", position: "Bronze", avatarUrl: "https://i.pravatar.cc/150?img=26", scoreLeft: 2200, scoreRight: 1900, isExpanded: false, details: "Joined: 2023-09-14, Country: USA" },
326
+ { id: 13, parentId: 6, side: "R", name: "Shuri", position: "Bronze", avatarUrl: "https://i.pravatar.cc/150?img=48", scoreLeft: 1800, scoreRight: 2100, isExpanded: false, details: "Joined: 2023-10-05, Country: Wakanda" },
327
+ { id: 14, parentId: 7, side: "L", name: "Okoye", position: "Bronze", avatarUrl: "https://i.pravatar.cc/150?img=24", scoreLeft: 1100, scoreRight: 1300, isExpanded: false, details: "Joined: 2023-11-01, Country: Wakanda" },
328
+ { id: 15, parentId: 7, side: "R", name: "M'Baku", position: "Bronze", avatarUrl: "https://i.pravatar.cc/150?img=12", scoreLeft: 900, scoreRight: 1200, isExpanded: false, details: "Joined: 2023-12-12, Country: Wakanda" },
329
+ { id: 16, parentId: 8, side: "L", name: "Nakia", position: "Member", avatarUrl: "https://i.pravatar.cc/150?img=9", scoreLeft: 400, scoreRight: 350, isExpanded: false, details: "Joined: 2024-02-10, Country: Wakanda" },
330
+ { id: 17, parentId: 8, side: "R", name: "Zuri", position: "Member", avatarUrl: "https://i.pravatar.cc/150?img=5", scoreLeft: 300, scoreRight: 400, isExpanded: false, details: "Joined: 2024-03-01, Country: Wakanda" },
331
+ { id: 18, parentId: 9, side: "L", name: "Vision", position: "Member", avatarUrl: "https://i.pravatar.cc/150?img=60", scoreLeft: 250, scoreRight: 200, isExpanded: false, details: "Joined: 2024-03-15, Country: Earth" },
332
+ { id: 19, parentId: 9, side: "R", name: "Pietro Maximoff", position: "Member", avatarUrl: "https://i.pravatar.cc/150?img=22", scoreLeft: 200, scoreRight: 250, isExpanded: false, details: "Joined: 2024-04-01, Country: Sokovia" },
333
+ { id: 20, parentId: 10, side: "L", name: "Maria Hill", position: "Member", avatarUrl: "https://i.pravatar.cc/150?img=17", scoreLeft: 100, scoreRight: 150, isExpanded: false, details: "Joined: 2024-05-01, Country: USA" }
334
+ ];
335
+
336
+ const treeContainer = document.getElementById('tree');
337
+ let scale = 1;
338
+
339
+ function buildTree(parentId = null) {
340
+ const nodes = mockData.filter(n => n.parentId === parentId);
341
+ if (!nodes.length) return null;
342
+
343
+ const fragment = document.createDocumentFragment();
344
+
345
+ nodes.forEach(node => {
346
+ const div = document.createElement('div');
347
+ div.className = `node ${!node.isExpanded ? 'hiddenSubtree' : ''}`;
348
+ div.dataset.id = node.id;
349
+
350
+ div.innerHTML = `
351
+ <div class="node-content">
352
+ <img class="avatar" src="${node.avatarUrl}" alt="${node.name}">
353
+ <div class="info">
354
+ <div class="name">${node.name}</div>
355
+ <div class="rank">${node.position}</div>
356
+ </div>
357
+ <div class="scores">
358
+ <div class="score">Left<br><span>${node.scoreLeft.toLocaleString()}</span></div>
359
+ <div class="score">Right<br><span>${node.scoreRight.toLocaleString()}</span></div>
360
+ </div>
361
+ <div class="controls-node">
362
+ <button class="toggle" title="${node.isExpanded ? 'Collapse' : 'Expand'}">
363
+ ${node.isExpanded ? '−' : '+'}
364
+ </button>
365
+ </div>
366
+ <div class="tooltip">${node.details}</div>
367
+ </div>
368
+ <div class="children"></div>
369
+ `;
370
+
371
+ const childrenContainer = div.querySelector('.children');
372
+ const children = buildTree(node.id);
373
+ if (children) {
374
+ childrenContainer.appendChild(children);
375
+ } else {
376
+ div.querySelector('.toggle').style.display = 'none';
377
+ }
378
+
379
+ fragment.appendChild(div);
380
+ });
381
+
382
+ return fragment;
383
+ }
384
+
385
+ function attachToggleEvents() {
386
+ treeContainer.addEventListener('click', e => {
387
+ if (e.target.classList.contains('toggle')) {
388
+ const nodeEl = e.target.closest('.node');
389
+ const isHidden = nodeEl.classList.toggle('hiddenSubtree');
390
+ e.target.textContent = isHidden ? '+' : '−';
391
+ e.target.title = isHidden ? 'Expand' : 'Collapse';
392
+ }
393
+ });
394
+ }
395
+
396
+ function expandAll() {
397
+ document.querySelectorAll('.node').forEach(n => n.classList.remove('hiddenSubtree'));
398
+ document.querySelectorAll('.toggle').forEach(b => {
399
+ b.textContent = '−';
400
+ b.title = 'Collapse';
401
+ });
402
+ }
403
+
404
+ function collapseAll() {
405
+ document.querySelectorAll('.node').forEach(n => {
406
+ if (n.querySelector('.children').childElementCount) {
407
+ n.classList.add('hiddenSubtree');
408
+ const btn = n.querySelector('.toggle');
409
+ btn.textContent = '+';
410
+ btn.title = 'Expand';
411
+ }
412
+ });
413
+ }
414
+
415
+ function setScale(newScale) {
416
+ scale = newScale;
417
+ treeContainer.style.transform = `scale(${scale})`;
418
+ document.getElement
419
+ <script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
420
+ </body>
421
+ </html>