-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
91 lines (91 loc) · 2.42 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Fastify Files</title>
<link rel="stylesheet" href="https://unpkg.com/purecss@2.1.0/build/pure-min.css" />
<style>
a {
border-radius: 10px;
box-shadow: 0 0 2px #888;
display: block;
margin: 5px;
padding: 5px;
}
</style>
<script src="https://unpkg.com/lightue@0.2.2/lightue.min.js"></script>
</head>
<body>
<script>
var L = Lightue,
S = L.useState({
curPath: ['/'],
files: [],
}),
xhr = new XMLHttpRequest()
xhr.responseType = 'json'
xhr.onload = () => {
S.files = xhr.response.files
}
function getLs() {
xhr.open('get', 'ls?path=' + encodeURIComponent(S.curPath.join('')))
xhr.send()
}
getLs()
L({
pureMenu: L.div.pureMenuHorizontal({
pureMenuHeading: L.a.pureMenuLink({
_href: '#',
$$: 'Fastify Files',
}),
pureMenuList: L.ul({
$$: () =>
S.curPath.map((level, i) =>
L.li.pureMenuItem({
pureMenuLink: L.a({
_href: '#',
$$: level,
onclick: (e) => {
e.preventDefault()
if (i < S.curPath.length - 1) {
S.curPath = S.curPath.slice(0, i + 1)
getLs()
}
},
}),
})
),
}),
}),
files: {
back: L.a({
_href: '#',
$$: '..',
onclick: (e) => {
e.preventDefault()
if (S.curPath.length > 1) {
S.curPath = S.curPath.slice(0, -1)
getLs()
}
},
}),
$$: () =>
S.files.map((file) =>
L.a({
_href: S.curPath.join('') + file.name,
$$: file.name,
onclick: (e) => {
if (file.dir) {
e.preventDefault()
S.curPath.push(file.name + '/')
getLs()
}
},
})
),
},
})
</script>
</body>
</html>