-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfe.html
executable file
·122 lines (116 loc) · 3.32 KB
/
fe.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<body ctx=body>
<link rel="stylesheet" href="ui.css" type="text/css" media="all" />
<script>
window.hmm=window.parent.hmm
window._AppName = "fe"
back = window.parent.hmm.t("apps.fe.goback")
</script>
<link rel="stylesheet" href="style.css">
<script src="ctx.js" type="text/javascript" charset="utf-8"></script>
<script>
window.ctxs = {
body: `
<div id="add" onclick="
hmm.popup(\`${hmm.t('apps.fe.namefile')}<br>
<input id=n><br><button default>${hmm.t('ui.create')}</button><button id=no>${hmm.t('ui.cancel')}</button>\`).then(e=>{
//window.parent.console.log(e)
if(e.button=='no')return
var n=e.popup.querySelector('#n').value
if(n in hmm.pathToJs(path)){hmm.popup('${hmm.t('apps.fe.alreadyexists')}<br><button default>${hmm.t('ui.ok')}');return}
eval(hmm.pathToDot(path+n)+'=\`\`')
loadpath()
})
" class="ctx-option">${hmm.t("apps.fe.addfile")}</div>
<div id="mkdir" onclick="
hmm.popup(\`${hmm.t('apps.fe.namedir')}<br>
<input id=n><br><button default>${hmm.t('ui.create')}</button><button id=no>${hmm.t('ui.cancel')}</button>\`).then(e=>{
if(e.button=='no')return
var n=e.popup.querySelector('#n').value
if(n in hmm.pathToJs(path)){hmm.popup('${hmm.t('apps.fe.alreadyexists')}<br><button default>${hmm.t('ui.ok')}');return}
eval(hmm.pathToDot(path+n)+'={}')
loadpath()
})
" class="ctx-option">${hmm.t("apps.fe.adddir")}</div>
<div id="del" onclick="
hmm.popup(\`${hmm.t("ui.delete")}?<br>
<button id=yes>${hmm.t('ui.yes')}</button>
<button id=no>${hmm.t('ui.cancel')}</button>
\`).then(e=>{
if(e.button=='no'|| path=='/'||path=='/apps')return;
eval('delete '+hmm.pathToDot(path.slice(0,-1)))
path=path.split('/').slice(0,-2).join('/')+'/'
loadpath()
})
" class="ctx-option">${hmm.t("apps.fe.deletefolder")}</div>
`//todo delete current folder
}
</script>
<style>
body {
overflow: auto;
}
div.file:nth-child(odd) {
background-color: #333;
border-radius: 5px;
}
div.folder::after {
content: ">";
float: right;
color: #aaa;
}
div.add {
color: #27f;
text-decoration: underline;
}
#pathlabel {
font-family: menlo, monospace;
}
</style>
<span id="pathlabel"></span>
<div id="files"></div>
<script>
window.hmm = window.parent.hmm;
path = "/"
loadpath = () => {
document.getElementById('pathlabel').innerText = path
document.getElementById('files').innerHTML = (path != "/") ? `
<div class="add file" onclick="path=path.slice(0,path.slice(0,-1).lastIndexOf('/')+1);loadpath()">← ${back}</div>
` : ''
Object.keys(hmm.pathToJs(path)).sort().forEach(e => {
var el = document.createElement('div')
el.classList.add('file')
if (typeof(hmm.pathToJs(path)[e]) == "object") {
el.classList.add('folder')
el.onclick = () => {
path += e + '/'
loadpath()
}
} else {
el.onclick = (ev) => {
hmm.$("open " + path + ev.target.innerText)
}
}
if (e.startsWith('.')) el.style.color = "#aaa"
el.innerText = e
document.getElementById('files').appendChild(el)
})
let end=document.createElement('div')
end.classList.add('file')
end.setAttribute('ctx','body')
end.innerHTML=" "
document.getElementById('files').appendChild(end)
}
setTimeout(() => {
if ((window.arg || '').startsWith("$open ")) {
path = window.arg.slice(6)
loadpath()
}
}, 100)
loadpath()
</script>
<br>
<br>
<br>
<br>
<br>
</body>