ชื่อโปรเจกต์: 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- README.md +8 -5
- index.html +675 -19
README.md
CHANGED
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title: Binary
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: Binary MLM Tree Viewer Mockup 🌳💎
|
| 3 |
+
colorFrom: pink
|
| 4 |
+
colorTo: green
|
| 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,675 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Binary MLM Tree Viewer Mockup</title>
|
| 7 |
+
<style>
|
| 8 |
+
:root {
|
| 9 |
+
--primary: #3B82F6;
|
| 10 |
+
--secondary: #8B5CF6;
|
| 11 |
+
--accent: #10B981;
|
| 12 |
+
--danger: #EF4444;
|
| 13 |
+
--warning: #F59E0B;
|
| 14 |
+
--bg-main: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 15 |
+
--bg-card: rgba(255, 255, 255, 0.25);
|
| 16 |
+
--bg-card-hover: rgba(255, 255, 255, 0.4);
|
| 17 |
+
--text-primary: #1F2937;
|
| 18 |
+
--text-secondary: #6B7280;
|
| 19 |
+
--border-color: rgba(255, 255, 255, 0.3);
|
| 20 |
+
--shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
|
| 21 |
+
--blur: blur(12px);
|
| 22 |
+
--transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
* {
|
| 26 |
+
margin: 0;
|
| 27 |
+
padding: 0;
|
| 28 |
+
box-sizing: border-box;
|
| 29 |
+
}
|
| 30 |
+
|
| 31 |
+
body {
|
| 32 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
| 33 |
+
background: var(--bg-main);
|
| 34 |
+
background-attachment: fixed;
|
| 35 |
+
color: var(--text-primary);
|
| 36 |
+
overflow: hidden;
|
| 37 |
+
height: 100vh;
|
| 38 |
+
padding: 20px;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
.container {
|
| 42 |
+
display: flex;
|
| 43 |
+
flex-direction: column;
|
| 44 |
+
height: calc(100vh - 40px);
|
| 45 |
+
background: rgba(255, 255, 255, 0.1);
|
| 46 |
+
border-radius: 20px;
|
| 47 |
+
backdrop-filter: var(--blur);
|
| 48 |
+
-webkit-backdrop-filter: var(--blur);
|
| 49 |
+
border: 1px solid var(--border-color);
|
| 50 |
+
box-shadow: var(--shadow);
|
| 51 |
+
overflow: hidden;
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
header {
|
| 55 |
+
background: rgba(255, 255, 255, 0.15);
|
| 56 |
+
padding: 20px 30px;
|
| 57 |
+
border-bottom: 1px solid var(--border-color);
|
| 58 |
+
display: flex;
|
| 59 |
+
justify-content: space-between;
|
| 60 |
+
align-items: center;
|
| 61 |
+
flex-wrap: wrap;
|
| 62 |
+
gap: 15px;
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
h1 {
|
| 66 |
+
font-size: 28px;
|
| 67 |
+
font-weight: 700;
|
| 68 |
+
background: linear-gradient(45deg, var(--primary), var(--secondary));
|
| 69 |
+
-webkit-background-clip: text;
|
| 70 |
+
-webkit-text-fill-color: transparent;
|
| 71 |
+
background-clip: text;
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
.controls {
|
| 75 |
+
display: flex;
|
| 76 |
+
gap: 10px;
|
| 77 |
+
flex-wrap: wrap;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
button {
|
| 81 |
+
padding: 10px 20px;
|
| 82 |
+
border: none;
|
| 83 |
+
border-radius: 10px;
|
| 84 |
+
font-weight: 600;
|
| 85 |
+
cursor: pointer;
|
| 86 |
+
transition: var(--transition);
|
| 87 |
+
background: var(--bg-card);
|
| 88 |
+
border: 1px solid var(--border-color);
|
| 89 |
+
color: var(--text-primary);
|
| 90 |
+
font-size: 14px;
|
| 91 |
+
display: flex;
|
| 92 |
+
align-items: center;
|
| 93 |
+
gap: 5px;
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
button:hover {
|
| 97 |
+
background: var(--bg-card-hover);
|
| 98 |
+
transform: translateY(-2px);
|
| 99 |
+
box-shadow: var(--shadow);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
button:active {
|
| 103 |
+
transform: translateY(0);
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.tree-container {
|
| 107 |
+
flex: 1;
|
| 108 |
+
overflow-x: auto;
|
| 109 |
+
overflow-y: auto;
|
| 110 |
+
padding: 30px;
|
| 111 |
+
position: relative;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.tree-container::-webkit-scrollbar {
|
| 115 |
+
height: 8px;
|
| 116 |
+
width: 8px;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.tree-container::-webkit-scrollbar-track {
|
| 120 |
+
background: rgba(255, 255, 255, 0.1);
|
| 121 |
+
border-radius: 10px;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.tree-container::-webkit-scrollbar-thumb {
|
| 125 |
+
background: linear-gradient(45deg, var(--primary), var(--secondary));
|
| 126 |
+
border-radius: 10px;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.tree {
|
| 130 |
+
display: inline-block;
|
| 131 |
+
min-width: 100%;
|
| 132 |
+
transform-origin: center top;
|
| 133 |
+
transition: transform 0.3s ease;
|
| 134 |
+
}
|
| 135 |
+
|
| 136 |
+
.node-wrapper {
|
| 137 |
+
display: flex;
|
| 138 |
+
flex-direction: column;
|
| 139 |
+
align-items: center;
|
| 140 |
+
position: relative;
|
| 141 |
+
padding: 10px 20px;
|
| 142 |
+
}
|
| 143 |
+
|
| 144 |
+
.node {
|
| 145 |
+
background: var(--bg-card);
|
| 146 |
+
backdrop-filter: var(--blur);
|
| 147 |
+
-webkit-backdrop-filter: var(--blur);
|
| 148 |
+
border: 1px solid var(--border-color);
|
| 149 |
+
border-radius: 15px;
|
| 150 |
+
padding: 15px;
|
| 151 |
+
box-shadow: var(--shadow);
|
| 152 |
+
transition: var(--transition);
|
| 153 |
+
cursor: pointer;
|
| 154 |
+
position: relative;
|
| 155 |
+
min-width: 180px;
|
| 156 |
+
max-width: 220px;
|
| 157 |
+
z-index: 2;
|
| 158 |
+
}
|
| 159 |
+
|
| 160 |
+
.node:hover {
|
| 161 |
+
transform: translateY(-5px);
|
| 162 |
+
background: var(--bg-card-hover);
|
| 163 |
+
box-shadow: 0 12px 40px rgba(31, 38, 135, 0.5);
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
.node-header {
|
| 167 |
+
display: flex;
|
| 168 |
+
align-items: center;
|
| 169 |
+
gap: 12px;
|
| 170 |
+
margin-bottom: 10px;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.avatar {
|
| 174 |
+
width: 50px;
|
| 175 |
+
height: 50px;
|
| 176 |
+
border-radius: 50%;
|
| 177 |
+
object-fit: cover;
|
| 178 |
+
border: 2px solid var(--border-color);
|
| 179 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 180 |
+
}
|
| 181 |
+
|
| 182 |
+
.node-info h3 {
|
| 183 |
+
font-size: 16px;
|
| 184 |
+
font-weight: 700;
|
| 185 |
+
color: var(--text-primary);
|
| 186 |
+
line-height: 1.2;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.node-info .position {
|
| 190 |
+
font-size: 12px;
|
| 191 |
+
font-weight: 600;
|
| 192 |
+
color: var(--secondary);
|
| 193 |
+
background: rgba(139, 92, 246, 0.2);
|
| 194 |
+
padding: 2px 8px;
|
| 195 |
+
border-radius: 6px;
|
| 196 |
+
display: inline-block;
|
| 197 |
+
margin-top: 3px;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.scores {
|
| 201 |
+
display: flex;
|
| 202 |
+
justify-content: space-between;
|
| 203 |
+
gap: 10px;
|
| 204 |
+
margin-top: 10px;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
.score-box {
|
| 208 |
+
flex: 1;
|
| 209 |
+
text-align: center;
|
| 210 |
+
padding: 8px;
|
| 211 |
+
border-radius: 8px;
|
| 212 |
+
background: rgba(255, 255, 255, 0.1);
|
| 213 |
+
border: 1px solid var(--border-color);
|
| 214 |
+
}
|
| 215 |
+
|
| 216 |
+
.score-box.left {
|
| 217 |
+
background: rgba(59, 130, 246, 0.15);
|
| 218 |
+
border-color: rgba(59, 130, 246, 0.3);
|
| 219 |
+
}
|
| 220 |
+
|
| 221 |
+
.score-box.right {
|
| 222 |
+
background: rgba(139, 92, 246, 0.15);
|
| 223 |
+
border-color: rgba(139, 92, 246, 0.3);
|
| 224 |
+
}
|
| 225 |
+
|
| 226 |
+
.score-label {
|
| 227 |
+
font-size: 10px;
|
| 228 |
+
color: var(--text-secondary);
|
| 229 |
+
text-transform: uppercase;
|
| 230 |
+
font-weight: 600;
|
| 231 |
+
}
|
| 232 |
+
|
| 233 |
+
.score-value {
|
| 234 |
+
font-size: 14px;
|
| 235 |
+
font-weight: 700;
|
| 236 |
+
color: var(--text-primary);
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
.toggle-btn {
|
| 240 |
+
position: absolute;
|
| 241 |
+
top: -8px;
|
| 242 |
+
right: -8px;
|
| 243 |
+
width: 24px;
|
| 244 |
+
height: 24px;
|
| 245 |
+
border-radius: 50%;
|
| 246 |
+
background: var(--primary);
|
| 247 |
+
color: white;
|
| 248 |
+
border: 2px solid var(--border-color);
|
| 249 |
+
display: flex;
|
| 250 |
+
align-items: center;
|
| 251 |
+
justify-content: center;
|
| 252 |
+
font-size: 12px;
|
| 253 |
+
font-weight: bold;
|
| 254 |
+
cursor: pointer;
|
| 255 |
+
transition: var(--transition);
|
| 256 |
+
z-index: 3;
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
.toggle-btn:hover {
|
| 260 |
+
background: var(--secondary);
|
| 261 |
+
transform: scale(1.1);
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
.children {
|
| 265 |
+
display: flex;
|
| 266 |
+
justify-content: center;
|
| 267 |
+
gap: 40px;
|
| 268 |
+
margin-top: 40px;
|
| 269 |
+
position: relative;
|
| 270 |
+
transition: var(--transition);
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.children.collapsed {
|
| 274 |
+
display: none;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
.children::before {
|
| 278 |
+
content: '';
|
| 279 |
+
position: absolute;
|
| 280 |
+
top: -20px;
|
| 281 |
+
left: 50%;
|
| 282 |
+
transform: translateX(-50%);
|
| 283 |
+
width: 2px;
|
| 284 |
+
height: 20px;
|
| 285 |
+
background: linear-gradient(to bottom, var(--primary), var(--secondary));
|
| 286 |
+
opacity: 0.6;
|
| 287 |
+
}
|
| 288 |
+
|
| 289 |
+
.child-wrapper {
|
| 290 |
+
display: flex;
|
| 291 |
+
flex-direction: column;
|
| 292 |
+
align-items: center;
|
| 293 |
+
position: relative;
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
.child-wrapper::before {
|
| 297 |
+
content: '';
|
| 298 |
+
position: absolute;
|
| 299 |
+
top: -20px;
|
| 300 |
+
width: 50%;
|
| 301 |
+
height: 2px;
|
| 302 |
+
background: linear-gradient(to right, var(--primary), var(--secondary));
|
| 303 |
+
opacity: 0.6;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
.child-wrapper.left::before {
|
| 307 |
+
right: 0;
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
.child-wrapper.right::before {
|
| 311 |
+
left: 0;
|
| 312 |
+
}
|
| 313 |
+
|
| 314 |
+
.tooltip {
|
| 315 |
+
position: fixed;
|
| 316 |
+
background: rgba(0, 0, 0, 0.9);
|
| 317 |
+
color: white;
|
| 318 |
+
padding: 10px 15px;
|
| 319 |
+
border-radius: 8px;
|
| 320 |
+
font-size: 12px;
|
| 321 |
+
z-index: 1000;
|
| 322 |
+
pointer-events: none;
|
| 323 |
+
opacity: 0;
|
| 324 |
+
transition: opacity 0.3s;
|
| 325 |
+
max-width: 250px;
|
| 326 |
+
backdrop-filter: blur(10px);
|
| 327 |
+
-webkit-backdrop-filter: blur(10px);
|
| 328 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 329 |
+
}
|
| 330 |
+
|
| 331 |
+
.tooltip.visible {
|
| 332 |
+
opacity: 1;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
@media (max-width: 768px) {
|
| 336 |
+
header {
|
| 337 |
+
padding: 15px 20px;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
h1 {
|
| 341 |
+
font-size: 22px;
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
button {
|
| 345 |
+
padding: 8px 15px;
|
| 346 |
+
font-size: 13px;
|
| 347 |
+
}
|
| 348 |
+
|
| 349 |
+
.node {
|
| 350 |
+
min-width: 150px;
|
| 351 |
+
padding: 12px;
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
.avatar {
|
| 355 |
+
width: 40px;
|
| 356 |
+
height: 40px;
|
| 357 |
+
}
|
| 358 |
+
|
| 359 |
+
.node-info h3 {
|
| 360 |
+
font-size: 14px;
|
| 361 |
+
}
|
| 362 |
+
|
| 363 |
+
.children {
|
| 364 |
+
gap: 20px;
|
| 365 |
+
}
|
| 366 |
+
}
|
| 367 |
+
|
| 368 |
+
@media (max-width: 480px) {
|
| 369 |
+
body {
|
| 370 |
+
padding: 10px;
|
| 371 |
+
}
|
| 372 |
+
|
| 373 |
+
.container {
|
| 374 |
+
height: calc(100vh - 20px);
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
.tree-container {
|
| 378 |
+
padding: 15px;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.node {
|
| 382 |
+
min-width: 130px;
|
| 383 |
+
padding: 10px;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
+
.avatar {
|
| 387 |
+
width: 35px;
|
| 388 |
+
height: 35px;
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
.node-info h3 {
|
| 392 |
+
font-size: 13px;
|
| 393 |
+
}
|
| 394 |
+
}
|
| 395 |
+
</style>
|
| 396 |
+
</head>
|
| 397 |
+
<body>
|
| 398 |
+
<div class="container">
|
| 399 |
+
<header>
|
| 400 |
+
<h1>Binary MLM Tree Viewer</h1>
|
| 401 |
+
<div class="controls">
|
| 402 |
+
<button id="zoomOut">− Zoom Out</button>
|
| 403 |
+
<button id="zoomIn">+ Zoom In</button>
|
| 404 |
+
<button id="expandAll">📂 Expand All</button>
|
| 405 |
+
<button id="collapseAll">📁 Collapse All</button>
|
| 406 |
+
</div>
|
| 407 |
+
</header>
|
| 408 |
+
<div class="tree-container" id="treeContainer">
|
| 409 |
+
<div class="tree" id="tree"></div>
|
| 410 |
+
</div>
|
| 411 |
+
</div>
|
| 412 |
+
<div class="tooltip" id="tooltip"></div>
|
| 413 |
+
|
| 414 |
+
<script>
|
| 415 |
+
// Mock Data
|
| 416 |
+
const mockData = [
|
| 417 |
+
{ id: 1, parentId: null, side: null, name: "Tony Stark", position: "Diamond", avatarUrl: "https://static.photos/technology/200x200/1", scoreLeft: 15500, scoreRight: 22500, isExpanded: true, details: "Joined: 2024/01/01 | Total: 38,000 PV | Team Size: 2,450" },
|
| 418 |
+
{ id: 2, parentId: 1, side: "L", name: "Steve Rogers", position: "Platinum", avatarUrl: "https://static.photos/people/200x200/2", scoreLeft: 8500, scoreRight: 12000, isExpanded: true, details: "Joined: 2024/02/15 | Total: 20,500 PV | Team Size: 1,200" },
|
| 419 |
+
{ id: 3, parentId: 1, side: "R", name: "Bruce Banner", position: "Platinum", avatarUrl: "https://static.photos/science/200x200/3", scoreLeft: 7000, scoreRight: 10500, isExpanded: true, details: "Joined: 2024/03/10 | Total: 17,500 PV | Team Size: 1,050" },
|
| 420 |
+
{ id: 4, parentId: 2, side: "L", name: "Natasha Romanoff", position: "Gold", avatarUrl: "https://static.photos/people/200x200/4", scoreLeft: 4500, scoreRight: 3800, isExpanded: true, details: "Joined: 2024/04/20 | Total: 8,300 PV | Team Size: 520" },
|
| 421 |
+
{ id: 5, parentId: 2, side: "R", name: "Clint Barton", position: "Gold", avatarUrl: "https://static.photos/outdoor/200x200/5", scoreLeft: 4000, scoreRight: 4200, isExpanded: true, details: "Joined: 2024/05/05 | Total: 8,200 PV | Team Size: 480" },
|
| 422 |
+
{ id: 6, parentId: 3, side: "L", name: "Thor Odinson", position: "Gold", avatarUrl: "https://static.photos/abstract/200x200/6", scoreLeft: 3200, scoreRight: 4500, isExpanded: true, details: "Joined: 2024/06/12 | Total: 7,700 PV | Team Size: 450" },
|
| 423 |
+
{ id: 7, parentId: 3, side: "R", name: "Loki Laufeyson", position: "Gold", avatarUrl: "https://static.photos/minimal/200x200/7", scoreLeft: 3800, scoreRight: 3000, isExpanded: true, details: "Joined: 2024/07/18 | Total: 6,800 PV | Team Size: 400" },
|
| 424 |
+
{ id: 8, parentId: 4, side: "L", name: "Peter Parker", position: "Silver", avatarUrl: "https://static.photos/people/200x200/8", scoreLeft: 2000, scoreRight: 1500, isExpanded: false, details: "Joined: 2024/08/25 | Total: 3,500 PV | Team Size: 180" },
|
| 425 |
+
{ id: 9, parentId: 4, side: "R", name: "Wanda Maximoff", position: "Silver", avatarUrl: "https://static.photos/abstract/200x200/9", scoreLeft: 1500, scoreRight: 1800, isExpanded: false, details: "Joined: 2024/09/10 | Total: 3,300 PV | Team Size: 165" },
|
| 426 |
+
{ id: 10, parentId: 5, side: "L", name: "Vision", position: "Silver", avatarUrl: "https://static.photos/technology/200x200/10", scoreLeft: 1800, scoreRight: 1700, isExpanded: false, details: "Joined: 2024/10/03 | Total: 3,500 PV | Team Size: 175" },
|
| 427 |
+
{ id: 11, parentId: 5, side: "R", name: "Sam Wilson", position: "Silver", avatarUrl: "https://static.photos/outdoor/200x200/11", scoreLeft: 1600, scoreRight: 1900, isExpanded: false, details: "Joined: 2024/11/15 | Total: 3,500 PV | Team Size: 170" },
|
| 428 |
+
{ id: 12, parentId: 6, side: "L", name: "Bucky Barnes", position: "Silver", avatarUrl: "https://static.photos/people/200x200/12", scoreLeft: 1400, scoreRight: 1300, isExpanded: false, details: "Joined: 2024/12/01 | Total: 2,700 PV | Team Size: 140" },
|
| 429 |
+
{ id: 13, parentId: 6, side: "R", name: "Carol Danvers", position: "Silver", avatarUrl: "https://static.photos/abstract/200x200/13", scoreLeft: 1100, scoreRight: 1600, isExpanded: false, details: "Joined: 2024/12/20 | Total: 2,700 PV | Team Size: 135" },
|
| 430 |
+
{ id: 14, parentId: 7, side: "L", name: "Scott Lang", position: "Silver", avatarUrl: "https://static.photos/minimal/200x200/14", scoreLeft: 1200, scoreRight: 1100, isExpanded: false, details: "Joined: 2025/01/05 | Total: 2,300 PV | Team Size: 125" },
|
| 431 |
+
{ id: 15, parentId: 7, side: "R", name: "Hope Van Dyne", position: "Silver", avatarUrl: "https://static.photos/people/200x200/15", scoreLeft: 1300, scoreRight: 1000, isExpanded: false, details: "Joined: 2025/01/18 | Total: 2,300 PV | Team Size: 120" },
|
| 432 |
+
{ id: 16, parentId: 8, side: "L", name: "Stephen Strange", position: "Bronze", avatarUrl: "https://static.photos/abstract/200x200/16", scoreLeft: 800, scoreRight: 600, isExpanded: false, details: "Joined: 2025/02/10 | Total: 1,400 PV | Team Size: 75" },
|
| 433 |
+
{ id: 17, parentId: 8, side: "R", name: "T'Challa", position: "Bronze", avatarUrl: "https://static.photos/nature/200x200/17", scoreLeft: 700, scoreRight: 700, isExpanded: false, details: "Joined: 2025/02/25 | Total: 1,400 PV | Team Size: 70" },
|
| 434 |
+
{ id: 18, parentId: 9, side: "L", name: "Shuri", position: "Bronze", avatarUrl: "https://static.photos/technology/200x200/18", scoreLeft: 600, scoreRight: 650, isExpanded: false, details: "Joined: 2025/03/08 | Total: 1,250 PV | Team Size: 65" },
|
| 435 |
+
{ id: 19, parentId: 9, side: "R", name: "Okoye", position: "Bronze", avatarUrl: "https://static.photos/people/200x200/19", scoreLeft: 550, scoreRight: 600, isExpanded: false, details: "Joined: 2025/03/20 | Total: 1,150 PV | Team Size: 60" },
|
| 436 |
+
{ id: 20, parentId: 10, side: "L", name: "M'Baku", position: "Bronze", avatarUrl: "https://static.photos/outdoor/200x200/20", scoreLeft: 500, scoreRight: 550, isExpanded: false, details: "Joined: 2025/04/02 | Total: 1,050 PV | Team Size: 55" }
|
| 437 |
+
];
|
| 438 |
+
|
| 439 |
+
// State Management
|
| 440 |
+
let zoomLevel = 1;
|
| 441 |
+
const MIN_ZOOM = 0.5;
|
| 442 |
+
const MAX_ZOOM = 2;
|
| 443 |
+
const ZOOM_STEP = 0.1;
|
| 444 |
+
|
| 445 |
+
// Utility Functions
|
| 446 |
+
function formatNumber(num) {
|
| 447 |
+
return num.toLocaleString();
|
| 448 |
+
}
|
| 449 |
+
|
| 450 |
+
function getPositionColor(position) {
|
| 451 |
+
const colors = {
|
| 452 |
+
"Diamond": "linear-gradient(45deg, #FFD700, #FFA500)",
|
| 453 |
+
"Platinum": "linear-gradient(45deg, #E5E4E2, #C0C0C0)",
|
| 454 |
+
"Gold": "linear-gradient(45deg, #FFD700, #FFA000)",
|
| 455 |
+
"Silver": "linear-gradient(45deg, #C0C0C0, #A0A0A0)",
|
| 456 |
+
"Bronze": "linear-gradient(45deg, #CD7F32, #A0522D)"
|
| 457 |
+
};
|
| 458 |
+
return colors[position] || "linear-gradient(45deg, #3B82F6, #8B5CF6)";
|
| 459 |
+
}
|
| 460 |
+
|
| 461 |
+
// Build Tree Structure
|
| 462 |
+
function buildTree(nodeId) {
|
| 463 |
+
const node = mockData.find(n => n.id === nodeId);
|
| 464 |
+
if (!node) return null;
|
| 465 |
+
|
| 466 |
+
const children = mockData.filter(n => n.parentId === nodeId);
|
| 467 |
+
const leftChild = children.find(c => c.side === "L");
|
| 468 |
+
const rightChild = children.find(c => c.side === "R");
|
| 469 |
+
|
| 470 |
+
return {
|
| 471 |
+
...node,
|
| 472 |
+
left: leftChild ? buildTree(leftChild.id) : null,
|
| 473 |
+
right: rightChild ? buildTree(rightChild.id) : null
|
| 474 |
+
};
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
// Create Node Element
|
| 478 |
+
function createNodeElement(node) {
|
| 479 |
+
const wrapper = document.createElement('div');
|
| 480 |
+
wrapper.className = 'node-wrapper';
|
| 481 |
+
|
| 482 |
+
const nodeDiv = document.createElement('div');
|
| 483 |
+
nodeDiv.className = 'node';
|
| 484 |
+
nodeDiv.dataset.nodeId = node.id;
|
| 485 |
+
|
| 486 |
+
// Avatar and Info
|
| 487 |
+
const hasChildren = node.left || node.right;
|
| 488 |
+
nodeDiv.innerHTML = `
|
| 489 |
+
${hasChildren ? `<div class="toggle-btn">${node.isExpanded ? '−' : '+'}</div>` : ''}
|
| 490 |
+
<div class="node-header">
|
| 491 |
+
<img src="${node.avatarUrl}" alt="${node.name}" class="avatar" onerror="this.src='https://static.photos/people/200x200/1'">
|
| 492 |
+
<div class="node-info">
|
| 493 |
+
<h3>${node.name}</h3>
|
| 494 |
+
<span class="position" style="background: ${getPositionColor(node.position)}20; color: ${getPositionColor(node.position).match(/#[a-fA-F0-9]{6}/)[0]}">${node.position}</span>
|
| 495 |
+
</div>
|
| 496 |
+
</div>
|
| 497 |
+
<div class="scores">
|
| 498 |
+
<div class="score-box left">
|
| 499 |
+
<div class="score-label">Left</div>
|
| 500 |
+
<div class="score-value">${formatNumber(node.scoreLeft)}</div>
|
| 501 |
+
</div>
|
| 502 |
+
<div class="score-box right">
|
| 503 |
+
<div class="score-label">Right</div>
|
| 504 |
+
<div class="score-value">${formatNumber(node.scoreRight)}</div>
|
| 505 |
+
</div>
|
| 506 |
+
</div>
|
| 507 |
+
`;
|
| 508 |
+
|
| 509 |
+
wrapper.appendChild(nodeDiv);
|
| 510 |
+
|
| 511 |
+
// Children Container
|
| 512 |
+
if (hasChildren) {
|
| 513 |
+
const childrenDiv = document.createElement('div');
|
| 514 |
+
childrenDiv.className = `children ${node.isExpanded ? '' : 'collapsed'}`;
|
| 515 |
+
|
| 516 |
+
// Left Child
|
| 517 |
+
if (node.left) {
|
| 518 |
+
const leftWrapper = document.createElement('div');
|
| 519 |
+
leftWrapper.className = 'child-wrapper left';
|
| 520 |
+
leftWrapper.appendChild(createNodeElement(node.left));
|
| 521 |
+
childrenDiv.appendChild(leftWrapper);
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
// Right Child
|
| 525 |
+
if (node.right) {
|
| 526 |
+
const rightWrapper = document.createElement('div');
|
| 527 |
+
rightWrapper.className = 'child-wrapper right';
|
| 528 |
+
rightWrapper.appendChild(createNodeElement(node.right));
|
| 529 |
+
childrenDiv.appendChild(rightWrapper);
|
| 530 |
+
}
|
| 531 |
+
|
| 532 |
+
wrapper.appendChild(childrenDiv);
|
| 533 |
+
}
|
| 534 |
+
|
| 535 |
+
// Event Listeners
|
| 536 |
+
nodeDiv.addEventListener('click', (e) => {
|
| 537 |
+
if (e.target.classList.contains('toggle-btn')) {
|
| 538 |
+
e.stopPropagation();
|
| 539 |
+
toggleNode(node.id);
|
| 540 |
+
}
|
| 541 |
+
});
|
| 542 |
+
|
| 543 |
+
nodeDiv.addEventListener('mouseenter', (e) => showTooltip(e, node));
|
| 544 |
+
nodeDiv.addEventListener('mouseleave', hideTooltip);
|
| 545 |
+
|
| 546 |
+
return wrapper;
|
| 547 |
+
}
|
| 548 |
+
|
| 549 |
+
// Toggle Node Expand/Collapse
|
| 550 |
+
function toggleNode(nodeId) {
|
| 551 |
+
const node = mockData.find(n => n.id === nodeId);
|
| 552 |
+
if (node) {
|
| 553 |
+
node.isExpanded = !node.isExpanded;
|
| 554 |
+
renderTree();
|
| 555 |
+
}
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
// Tooltip Functions
|
| 559 |
+
function showTooltip(e, node) {
|
| 560 |
+
const tooltip = document.getElementById('tooltip');
|
| 561 |
+
tooltip.innerHTML = `
|
| 562 |
+
<strong>${node.name}</strong><br>
|
| 563 |
+
Position: ${node.position}<br>
|
| 564 |
+
${node.details}
|
| 565 |
+
`;
|
| 566 |
+
tooltip.classList.add('visible');
|
| 567 |
+
updateTooltipPosition(e);
|
| 568 |
+
}
|
| 569 |
+
|
| 570 |
+
function hideTooltip() {
|
| 571 |
+
const tooltip = document.getElementById('tooltip');
|
| 572 |
+
tooltip.classList.remove('visible');
|
| 573 |
+
}
|
| 574 |
+
|
| 575 |
+
function updateTooltipPosition(e) {
|
| 576 |
+
const tooltip = document.getElementById('tooltip');
|
| 577 |
+
const rect = tooltip.getBoundingClientRect();
|
| 578 |
+
let x = e.clientX;
|
| 579 |
+
let y = e.clientY - rect.height - 10;
|
| 580 |
+
|
| 581 |
+
if (x + rect.width > window.innerWidth) {
|
| 582 |
+
x = window.innerWidth - rect.width - 10;
|
| 583 |
+
}
|
| 584 |
+
|
| 585 |
+
if (y < 10) {
|
| 586 |
+
y = e.clientY + 10;
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
tooltip.style.left = x + 'px';
|
| 590 |
+
tooltip.style.top = y + 'px';
|
| 591 |
+
}
|
| 592 |
+
|
| 593 |
+
// Zoom Functions
|
| 594 |
+
function setZoom(level) {
|
| 595 |
+
zoomLevel = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, level));
|
| 596 |
+
const tree = document.getElementById('tree');
|
| 597 |
+
tree.style.transform = `scale(${zoomLevel})`;
|
| 598 |
+
}
|
| 599 |
+
|
| 600 |
+
// Expand/Collapse All
|
| 601 |
+
function expandAll(expand = true) {
|
| 602 |
+
mockData.forEach(node => {
|
| 603 |
+
const hasChildren = mockData.some(n => n.parentId === node.id);
|
| 604 |
+
if (hasChildren) {
|
| 605 |
+
node.isExpanded = expand;
|
| 606 |
+
}
|
| 607 |
+
});
|
| 608 |
+
renderTree();
|
| 609 |
+
}
|
| 610 |
+
|
| 611 |
+
// Render Tree
|
| 612 |
+
function renderTree() {
|
| 613 |
+
const treeContainer = document.getElementById('tree');
|
| 614 |
+
treeContainer.innerHTML = '';
|
| 615 |
+
const rootNode = mockData.find(n => n.parentId === null);
|
| 616 |
+
if (rootNode) {
|
| 617 |
+
const tree = buildTree(rootNode.id);
|
| 618 |
+
treeContainer.appendChild(createNodeElement(tree));
|
| 619 |
+
}
|
| 620 |
+
}
|
| 621 |
+
|
| 622 |
+
// Initialize
|
| 623 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 624 |
+
renderTree();
|
| 625 |
+
|
| 626 |
+
// Zoom Controls
|
| 627 |
+
document.getElementById('zoomIn').addEventListener('click', () => {
|
| 628 |
+
setZoom(zoomLevel + ZOOM_STEP);
|
| 629 |
+
});
|
| 630 |
+
|
| 631 |
+
document.getElementById('zoomOut').addEventListener('click', () => {
|
| 632 |
+
setZoom(zoomLevel - ZOOM_STEP);
|
| 633 |
+
});
|
| 634 |
+
|
| 635 |
+
// Expand/Collapse Controls
|
| 636 |
+
document.getElementById('expandAll').addEventListener('click', () => expandAll(true));
|
| 637 |
+
document.getElementById('collapseAll').addEventListener('click', () => expandAll(false));
|
| 638 |
+
|
| 639 |
+
// Mouse move for tooltip
|
| 640 |
+
document.addEventListener('mousemove', (e) => {
|
| 641 |
+
const tooltip = document.getElementById('tooltip');
|
| 642 |
+
if (tooltip.classList.contains('visible')) {
|
| 643 |
+
updateTooltipPosition(e);
|
| 644 |
+
}
|
| 645 |
+
});
|
| 646 |
+
|
| 647 |
+
// Keyboard shortcuts
|
| 648 |
+
document.addEventListener('keydown', (e) => {
|
| 649 |
+
if (e.key === '+' || e.key === '=') {
|
| 650 |
+
setZoom(zoomLevel + ZOOM_STEP);
|
| 651 |
+
} else if (e.key === '-') {
|
| 652 |
+
setZoom(zoomLevel - ZOOM_STEP);
|
| 653 |
+
} else if (e.key === '0') {
|
| 654 |
+
setZoom(1);
|
| 655 |
+
}
|
| 656 |
+
});
|
| 657 |
+
});
|
| 658 |
+
|
| 659 |
+
// Update tree on window resize
|
| 660 |
+
window.addEventListener('resize', () => {
|
| 661 |
+
const treeContainer = document.getElementById('treeContainer');
|
| 662 |
+
const tree = document.getElementById('tree');
|
| 663 |
+
const containerWidth = treeContainer.clientWidth;
|
| 664 |
+
const treeWidth = tree.scrollWidth * zoomLevel;
|
| 665 |
+
|
| 666 |
+
if (treeWidth > containerWidth) {
|
| 667 |
+
tree.style.transformOrigin = 'left top';
|
| 668 |
+
} else {
|
| 669 |
+
tree.style.transformOrigin = 'center top';
|
| 670 |
+
}
|
| 671 |
+
});
|
| 672 |
+
</script>
|
| 673 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 674 |
+
</body>
|
| 675 |
+
</html>
|