forked from MoeClub/OneList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
242 lines (242 loc) · 10.4 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OneList</title>
<style>
@font-face{
font-family: 'icomoon';
src : url("data:application/x-font-woff;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg8SBwQAAAC8AAAAYGNtYXDTrtL+AAABHAAAAGxnYXNwAAAAEAAAAYgAAAAIZ2x5Zizg66wAAAGQAAACOGhlYWQXasWNAAADyAAAADZoaGVhB8IDyQAABAAAAAAkaG10eBYAAJMAAAQkAAAAIGxvY2ECEgFAAAAERAAAABJtYXhwAA8AZgAABFgAAAAgbmFtZZlKCfsAAAR4AAABhnBvc3QAAwAAAAAGAAAAACAAAwOaAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADqQAPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwA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AQAAAAgAZAAGAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=") format('woff');
font-weight: normal;
font-style: normal;
font-display: block;
}
[class^="icon-"], [class*=" icon-"] {
font-family: 'icomoon' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-home:before {
content: "\e900";
}
.icon-folder-open:before {
content: "\e930";
}
.icon-file-text2:before {
content: "\e926";
}
.icon-arrow-left2:before {
content: "\ea40";
}
body {
background-color: rgb(247, 247, 249);
}
h1 {
text-align: center;
color: rgb(51, 51, 51);
font-size: 28px;
letter-spacing: 2px;
line-height: 64px;
}
a {
text-decoration: none;
color: black;
}
a:hover {
text-decoration: underline;
}
th {
font-weight: normal;
}
.list-wrapper {
width: 80%;
margin: 0 auto;
margin-bottom: 40px;
position: relative;
box-shadow: 0 0 32px 0 rgba(0, 0, 0, 0.1);
}
.list-header-container {
margin: 0;
border: 0 none;
padding: 15px 50px;
text-align: left;
font-weight: 400;
color: #000000;
background-color: #f7f7f9;
}
.list-title th {
font-weight: bold;
}
.list-body-container {
position: relative;
left: 0;
overflow-x: hidden;
overflow-y: auto;
box-sizing: border-box;
background: white;
}
.list-table {
width: 100%;
padding: 20px;
border-spacing: 0;
}
.list-table tr th{
text-align: right;
}
.list-table tr th:first-child {
text-align: left;
padding: 5px 0;
}
.item:hover {
font-weight: 200;
background-color: gainsboro;
}
#back{
position: absolute;
top: 35px;
right: 35px;
}
</style>
</head>
<body>
<h1>
<span onclick="Goto(RootPath);">OneList</span>
</h1>
<div class="list-wrapper">
<div class="list-container">
<div class="list-header-container">
<h3>OneList Local Path</h3>
<span id="back" class="icon-arrow-left2" onclick="Goto(Back());"></span>
</div>
<div class="list-body-container">
<table class="list-table">
<tr class="list-title">
<th onclick="View('name');">文件</th>
<th onclick="View('date');">时间</th>
<th onclick="View('size');">大小</th>
</tr>
</table>
</div>
</div>
</div>
</body>
<script>
var RootPath = "{{ escape(rootPath) }}";
var CurrentPath = "{{ escape(currentPath) }}";
var RawData = "{{ escape(items) }}";
if (CurrentPath === "/"){ CurrentPath = "" }
var Reverse = false;
var PageData = JSON.parse(window.atob(RawData));
var ArrayPath = new Array();
var ArrayFloder = new Array();
var ArrayFile = new Array();
for(var item in PageData){
if (item.indexOf("@") == 0) { continue }
if (PageData[item]['@type'] == 'file') {
ArrayFile.push(PageData[item]);
} else if (PageData[item]['@type'] == 'folder') {
ArrayFloder.push(PageData[item]);
}
}
function Goto(thePath) {window.location.href = thePath;}
function SizeNum(Size) {
var dataArray = Size.split(" ", 2);
var dataNum = 0;
if (dataArray[1] === "B"){
dataNum = 2 ** 0 * dataArray[0];
} else if (dataArray[1] === "KB"){
dataNum = 2 ** 10 * dataArray[0];
} else if (dataArray[1] === "MB"){
dataNum = 2 ** 20 * dataArray[0];
} else if (dataArray[1] === "GB"){
dataNum = 2 ** 30 * dataArray[0];
} else if (dataArray[1] === "TB"){
dataNum = 2 ** 40 * dataArray[0];
} else if (dataArray[1] === "PB"){
dataNum = 2 ** 50 * dataArray[0];
}
return dataNum;
}
function compare(property) {
if (property === "size") {
return function(a,b){
var value0 = SizeNum(a[property].toUpperCase());
var value1 = SizeNum(b[property].toUpperCase());
return value0 - value1;
}
} else {
return function(a,b){
var value0 = a[property].toLowerCase();
var value1 = b[property].toLowerCase();
return value0.localeCompare(value1);
}
}
}
function Clear() {
var ClassList = new Array("item");
for(var item in ClassList){
var Elem = document.getElementsByClassName(ClassList[item]);
for(var i = Elem.length-1; i >= 0 ; i--) {
Elem[i].parentNode.removeChild(Elem[i]);
}
}
var ElemH3 = document.getElementsByTagName("h3")[0];
var newH3 = document.createElement("h3");
var localPath = CurrentPath.trim().replace(/^\//, "").replace(/\/$/, "");
var localHtmlArray = new Array();
localHtmlArray.push("<a href='//" + window.location.host + RootPath + "'>" + '<span class="icon-home"></span>' + "</a>");
if (localPath !== "" ){
var localPathArray = localPath.split("/");
var localHref = "";
for(var j=0; j<localPathArray.length; j++){
localHref += "/" + localPathArray[j];
if (j === 0 && RootPath !== "/"){ continue }
localHtmlArray.push("<a href='//" + window.location.host + localHref + "'>" + localPathArray[j] + "</a>");
}
}
newH3.innerHTML = localHtmlArray.join(" / ");
ElemH3.replaceWith(newH3);
ArrayPath = localHtmlArray;
}
function Back() {
var Num = ArrayPath.length - 1;
var ElemNum = 0;
var ElemBack = document.createElement("div");
if (Num > 0){ElemNum = Num - 1;}
ElemBack.innerHTML = ArrayPath[ElemNum];
return ElemBack.childNodes[0].href
}
function View(Property) {
//console.log("sort:", Property, "reverse:", Reverse);
ArrayFloder.sort(compare(Property));
ArrayFile.sort(compare(Property));
if (Reverse) {
ArrayFloder.reverse();
ArrayFile.reverse();
}
Reverse = !(Reverse);
Clear();
var Elem = document.getElementsByClassName("list-table")[0];
var ArrayItem = ArrayFloder.concat(ArrayFile);
for(var item in ArrayItem){
var newChild = document.createElement("tr");
var iconHtml = "";
if (ArrayItem[item]['@type'] == 'folder') {
iconHtml = '<span class="icon-folder-open"> </span>';
} else if (ArrayItem[item]['@type'] == 'file') {
iconHtml = '<span class="icon-file-text2"> </span>';
} else { continue }
newChild.setAttribute('class', 'item');
newChild.innerHTML = "<th class=\"list-data\">" + iconHtml + "<a href='//" + window.location.host + CurrentPath + "/" + ArrayItem[item]['name'] +"'>" + ArrayItem[item]['name'] + "</a></th><th class=\"list-data\">" + ArrayItem[item]['date'] + "</th><th class=\"list-data\">" + ArrayItem[item]['size'] + "</th>";
Elem.lastChild.appendChild(newChild);
}
}
window.onload = View("name");
</script>
</html>