ทำต่อให้จบ
Browse files- index.html +23 -4
- style.css +1 -27
index.html
CHANGED
|
@@ -411,11 +411,30 @@
|
|
| 411 |
}
|
| 412 |
});
|
| 413 |
}
|
| 414 |
-
|
| 415 |
function setScale(newScale) {
|
| 416 |
scale = newScale;
|
| 417 |
treeContainer.style.transform = `scale(${scale})`;
|
| 418 |
-
document.
|
| 419 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 420 |
</body>
|
| 421 |
-
</html>
|
|
|
|
| 411 |
}
|
| 412 |
});
|
| 413 |
}
|
|
|
|
| 414 |
function setScale(newScale) {
|
| 415 |
scale = newScale;
|
| 416 |
treeContainer.style.transform = `scale(${scale})`;
|
| 417 |
+
document.getElementById('zoomLevel').textContent = Math.round(scale * 100) + '%';
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
// Render tree and hook up events
|
| 421 |
+
treeContainer.appendChild(buildTree());
|
| 422 |
+
attachToggleEvents();
|
| 423 |
+
|
| 424 |
+
// Zoom controls
|
| 425 |
+
document.getElementById('zoomIn').addEventListener('click', () => {
|
| 426 |
+
if (scale < 2) setScale(scale + 0.1);
|
| 427 |
+
});
|
| 428 |
+
document.getElementById('zoomOut').addEventListener('click', () => {
|
| 429 |
+
if (scale > 0.5) setScale(scale - 0.1);
|
| 430 |
+
});
|
| 431 |
+
|
| 432 |
+
// Global expand / collapse
|
| 433 |
+
document.getElementById('expandAll').addEventListener('click', expandAll);
|
| 434 |
+
document.getElementById('collapseAll').addEventListener('click', collapseAll);
|
| 435 |
+
|
| 436 |
+
// Center the tree on load
|
| 437 |
+
setScale(scale);
|
| 438 |
+
</script>
|
| 439 |
</body>
|
| 440 |
+
</html>
|
style.css
CHANGED
|
@@ -1,28 +1,2 @@
|
|
| 1 |
-
body {
|
| 2 |
-
padding: 2rem;
|
| 3 |
-
font-family: -apple-system, BlinkMacSystemFont, "Arial", sans-serif;
|
| 4 |
-
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
font-size: 16px;
|
| 8 |
-
margin-top: 0;
|
| 9 |
-
}
|
| 10 |
-
|
| 11 |
-
p {
|
| 12 |
-
color: rgb(107, 114, 128);
|
| 13 |
-
font-size: 15px;
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
-
}
|
| 17 |
-
|
| 18 |
-
.card {
|
| 19 |
-
max-width: 620px;
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
-
}
|
| 25 |
-
|
| 26 |
-
.card p:last-child {
|
| 27 |
-
margin-bottom: 0;
|
| 28 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
/* nothing to see here – all styles live inline in index.html */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|