aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/public
diff options
context:
space:
mode:
authorHsiangNianian <i@jyunko.cn>2024-08-19 17:58:55 +0800
committerHsiangNianian <i@jyunko.cn>2024-08-19 17:58:55 +0800
commitb5c3c046f17eb28555f9398bcbc741ae8240676b (patch)
tree6632d44cd46591fbf886290202321f7814463963 /public
parentcf2d0d388fc2a4b12a23cd0328fcd566ba19fd31 (diff)
downloadfiles-b5c3c046f17eb28555f9398bcbc741ae8240676b.tar.gz
files-b5c3c046f17eb28555f9398bcbc741ae8240676b.zip
chore: update content
Diffstat (limited to 'public')
-rw-r--r--public/index.html53
1 files changed, 53 insertions, 0 deletions
diff --git a/public/index.html b/public/index.html
new file mode 100644
index 0000000..a232c7c
--- /dev/null
+++ b/public/index.html
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <meta charset="UTF-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <title>Directory Tree</title>
+ <style>
+ ul {
+ list-style-type: none;
+ }
+ .directory {
+ font-weight: bold;
+ }
+ </style>
+</head>
+<body>
+ <h1>Files Directory Tree</h1>
+ <div id="directory-tree"></div>
+
+ <script>
+ async function fetchDirectoryTree() {
+ const response = await fetch('/api/files');
+ return response.json();
+ }
+
+ function createTreeElement(node) {
+ const li = document.createElement('li');
+ li.textContent = node.name;
+ if (node.isDirectory) {
+ li.classList.add('directory');
+ const ul = document.createElement('ul');
+ node.children.forEach(child => {
+ ul.appendChild(createTreeElement(child));
+ });
+ li.appendChild(ul);
+ }
+ return li;
+ }
+
+ async function displayDirectoryTree() {
+ const tree = await fetchDirectoryTree();
+ const treeContainer = document.getElementById('directory-tree');
+ const ul = document.createElement('ul');
+ tree.forEach(node => {
+ ul.appendChild(createTreeElement(node));
+ });
+ treeContainer.appendChild(ul);
+ }
+
+ displayDirectoryTree();
+ </script>
+</body>
+</html> \ No newline at end of file