This repository has been archived by the owner on Jul 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
template.html
221 lines (207 loc) · 9.2 KB
/
template.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
{{Body}}
<head>
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="//fastly.jsdelivr.net/gh/SomeBottle/[email protected]/assets/style.css" rel="stylesheet">
<link href='//fastly.jsdelivr.net/gh/SomeBottle/[email protected]/assets/woff.css' rel='stylesheet'>
<link href='//fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="//fastly.jsdelivr.net/npm/[email protected]/themes/prism.min.css">
<title>OdIndex - /{[Path]}</title>
</head>
<body>
<nav>
<div class='headt'>📁 OdIndex</div>
</nav>
<div class='container'>
<div class='pathshow'><a href='{[HomePath]}' target='_self'>🥔</a> > / {[PathItems]}</div>
<div class='items'>
<div style='min-width:600px'>{[Items]}</div>
</div>
<!--CurrentPage:{[CurrentPage]}-->{[Pagination]}
<div class='readme'>
<div class='markdown-body' id='readme'></div>
</div>
</div>
</body>
<script src="//fastly.jsdelivr.net/npm/prismjs/prism.min.js"></script>
<script src='//fastly.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script>
<script src="//fastly.jsdelivr.net/gh/SomeBottle/[email protected]/othumb.m.js"></script>
<script>
var readmefile = "{[ReadmeFile]}";
function fHook(resp) { /*用于判断fetch状态码的一个hook*/
let statusStart = Math.floor(resp.status / 100);
if ([2, 3].includes(statusStart)) {
return resp;
} else {
throw resp.status;
}
}
async function renderReadme() {
const resp = await fetch(readmefile)
if (!resp.ok) return
document.querySelector("#readme").innerHTML = window.markdownit().render(await fHook(resp).text().catch(e => {
throw e;
}));
Prism.highlightAll()
}
function humanFileSize(bytes, si) {
bytes = parseInt(bytes, 10)
var thresh = si ? 1000 : 1024;
if (Math.abs(bytes) < thresh) {
return bytes + ' B';
}
var units = si ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
var u = -1;
do {
bytes /= thresh;
++u;
} while (Math.abs(bytes) >= thresh && u < units.length - 1);
return bytes.toFixed(1) + ' ' + units[u];
}
document.addEventListener("DOMContentLoaded", function() {
document.querySelectorAll("a.item").forEach(function(i) {
i.insertAdjacentHTML('beforeend',
'<div style="flex-grow:1"></div>' +
((i.hasAttribute("size") && Number(i.getAttribute("size")) > 0) ? '<span class="size">' + humanFileSize(i.getAttribute("size"), true) + '</span>' : '')
)
})
});
renderReadme().catch(console.error)
</script>
{{BodyEnd}} {{PathSingle}}
<a href='{[FolderLink]}'>{[FolderName]}</a> {{PathSingleEnd}} {{ItemSingle}}
<a href="{[ItemLink]}" class="item" size="{[ItemSize]}" mimetype="{[MimeType]}" lastmodified="{[LastModifiedDateTime]}" created="{[CreatedDateTime]}"><i class="material-icons">{[MimeIcon]}</i>{[ItemName]}</a> {{ItemSingleEnd}} {{PaginationSingle}}
<div class='pagination'>
{[Prev]}{[Next]}
</div>
{{PaginationSingleEnd}} {{PaginationPrev}}
<input type='button' class='prevpage' value='←' onclick="location.href='{[PrevLink]}'"></input>
{{PaginationPrevEnd}} {{PaginationNext}}
<input type='button' class='nextpage' value='→' onclick="location.href='{[NextLink]}'"></input>
{{PaginationNextEnd}} {{PreviewBody}}
<head>
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="//fastly.jsdelivr.net/gh/SomeBottle/[email protected]/assets/style.css" rel="stylesheet">
<link href='//fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="//fastly.jsdelivr.net/npm/[email protected]/themes/prism.min.css">
<title>OdIndex Preview</title>
</head>
<body>
<nav>
<div class='headt'>📁 OdIndex</div>
</nav>
<div class='container'>
<div class='pathshow'><a href='{[HomePath]}' target='_self'>🥔</a> > / {[PathItems]} {[FileName]}</div>
{[PreviewContent]}
<div class='down'>
<input type='button' class='downbtn' value='Download' onclick='down()'></input><input type='text' class='downurl' id='du' value='' disabled></input>
</div>
<!--createdTime:{[CreatedDateTime]} modifiedTime:{[LastModifiedDateTime]} mimeType:{[MimeType]}-->
<script>
function jumpreview() {
window.open('{[PreviewUrl]}', '_blank');
}
var dl = location.href.split('?');
dl.pop();
dl = dl.join('?');
document.getElementById('du').value = dl;
function down() {
window.open(dl, '_self');
}
</script>
</div>
</body>
{{PreviewBodyEnd}} {{ImgPreview}}
<div class='previewitems'>
<div style='min-width:300px'>
<img style='max-width:100%' src='{[FileRawUrl]}'></img>
</div>
</div>
{{ImgPreviewEnd}} {{AudioPreview}}
<div class='previewitems'>
<div style='min-width:300px'>
<audio style='width:80%;margin:10px 0;' src="{[FileRawUrl]}" controls="controls"></audio>
</div>
</div>
{{AudioPreviewEnd}} {{VideoPreview}}
<div class='previewitems'>
<div style='min-width:300px'>
<video style='max-width:100%' src='{[FileRawUrl]}' controls="controls"></video>
</div>
</div>
{{VideoPreviewEnd}} {{TxtPreview}}
<div class='previewitems'>
<div style='min-width:300px'>
<div class='previewtext markdown-body'><pre><code>{[FileContent]}</code></pre></div>
</div>
</div>
{{TxtPreviewEnd}} {{MDPreview}}
<div class='previewitems'>
<div style='min-width:300px'>
<div class='previewtext markdown-body' id='md'>{[FileContent]}</div>
</div>
</div>
<script src='//fastly.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script>
<script>
document.getElementById('md').innerHTML = window.markdownit().render(document.getElementById('md').innerHTML);
</script>
{{MDPreviewEnd}} {{CodePreview}}
<div class='previewitems'>
<div style='min-width:300px'>
<div class='previewtext markdown-body' id='codes'>
<pre><code class="language-{[PrismTag]}">{[FileContent]}</code></pre>
</div>
</div>
</div>
<script src="//fastly.jsdelivr.net/npm/prismjs/prism.min.js"></script>
<script>
Prism.highlightAllUnder(document.getElementById('codes'));
</script>
{{CodePreviewEnd}} {{OfficePreview}}
<div class='previewitems'>
<div style='min-width:300px;padding:10px 0;'>
<h2 style='margin-top:0;'>此预览需要前往Office</h2>
<input type='button' style='padding:10px 10px;' class='downbtn' value='点击跳转预览' onclick='jumpreview()'>
</div>
</div>
{{OfficePreviewEnd}} {{PasswordPage}}
<head>
<meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
<link href="//fastly.jsdelivr.net/gh/SomeBottle/[email protected]/assets/style.css" rel="stylesheet">
<link href='//fastly.jsdelivr.net/npm/github-markdown-css/github-markdown-light.css' rel='stylesheet'>
<link rel="stylesheet" href="//fastly.jsdelivr.net/npm/[email protected]/themes/prism.min.css">
<script src='//fastly.jsdelivr.net/npm/[email protected]/build/md5.min.js'></script>
<script>
function md5zme() {
document.getElementById('password').value = md5(md5(document.getElementById('password').value))
}
</script>
<title>OdIndex - /{[Path]}</title>
</head>
<body>
<nav>
<div class='headt'>📁 OdIndex</div>
</nav>
<div class='container'>
<div class='pathshow'><a href='{[HomePath]}' target='_self'>🥔</a> > / {[PathItems]}</div>
<div class='passworditem'>
<div style='min-width:300px'>
<h2>输入密码以继续</h2>
<div class='passwordform'>
<form action="#" method="post" style="display: flex;flex: 1;" onsubmit="md5zme()">
<input class='passwordinput' type="password" name="password" id="password" placeholder="password"></input><input type="hidden" name="requestfolder" value="{[FolderMD5]}" /><input type='submit' class='submitbtn' value='Submit'></input>
</form>
</div>
</div>
</div>
</div>
</body>
{{PasswordPageEnd}}