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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix problems such as leading to blank page
- Loading branch information
1 parent
e98617d
commit 81f62f5
Showing
3 changed files
with
45 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
{{Body}} | ||
|
||
<head> | ||
<meta name="renderer" content="webkit"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
|
@@ -31,10 +32,21 @@ | |
<script src="https://cdn.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 resp.text()); | ||
document.querySelector("#readme").innerHTML = window.markdownit().render(await fHook(resp).text().catch(e => { | ||
throw e; | ||
})); | ||
Prism.highlightAll() | ||
} | ||
|
||
|
@@ -45,9 +57,7 @@ | |
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 units = si ? ['kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'] : ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']; | ||
var u = -1; | ||
do { | ||
bytes /= thresh; | ||
|
@@ -61,33 +71,26 @@ | |
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>' : '') | ||
((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}} | ||
{{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}} | ||
{{PaginationSingleEnd}} {{PaginationPrev}} | ||
<input type='button' class='prevpage' value='←' onclick="location.href='{[PrevLink]}'"></input> | ||
{{PaginationPrevEnd}} | ||
{{PaginationNext}} | ||
{{PaginationPrevEnd}} {{PaginationNext}} | ||
<input type='button' class='nextpage' value='→' onclick="location.href='{[NextLink]}'"></input> | ||
{{PaginationNextEnd}} | ||
{{PreviewBody}} | ||
{{PaginationNextEnd}} {{PreviewBody}} | ||
|
||
<head> | ||
<meta name="renderer" content="webkit"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
|
@@ -114,57 +117,52 @@ | |
function jumpreview() { | ||
window.open('{[PreviewUrl]}', '_blank'); | ||
} | ||
var dl=location.href.split('?'); | ||
dl.pop(); | ||
dl=dl.join('?'); | ||
document.getElementById('du').value=dl; | ||
function down() { | ||
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}} | ||
{{PreviewBodyEnd}} {{ImgPreview}} | ||
<div class='previewitems'> | ||
<div style='min-width:300px'> | ||
<img style='max-width:100%' src='{[FileRawUrl]}'></img> | ||
</div> | ||
</div> | ||
{{ImgPreviewEnd}} | ||
{{AudioPreview}} | ||
{{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}} | ||
{{AudioPreviewEnd}} {{VideoPreview}} | ||
<div class='previewitems'> | ||
<div style='min-width:300px'> | ||
<video style='max-width:100%' src='{[FileRawUrl]}' controls="controls"></video> | ||
</div> | ||
</div> | ||
{{VideoPreviewEnd}} | ||
{{TxtPreview}} | ||
{{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}} | ||
{{TxtPreviewEnd}} {{MDPreview}} | ||
<div class='previewitems'> | ||
<div style='min-width:300px'> | ||
<div class='previewtext markdown-body' id='md'>{[FileContent]}</div> | ||
</div> | ||
</div> | ||
<script src='https://cdn.jsdelivr.net/npm/markdown-it@latest/dist/markdown-it.min.js'></script> | ||
<script> | ||
document.getElementById('md').innerHTML=window.markdownit().render(document.getElementById('md').innerHTML); | ||
document.getElementById('md').innerHTML = window.markdownit().render(document.getElementById('md').innerHTML); | ||
</script> | ||
{{MDPreviewEnd}} | ||
{{CodePreview}} | ||
{{MDPreviewEnd}} {{CodePreview}} | ||
<div class='previewitems'> | ||
<div style='min-width:300px'> | ||
<div class='previewtext markdown-body' id='codes'> | ||
|
@@ -176,16 +174,15 @@ | |
<script> | ||
Prism.highlightAllUnder(document.getElementById('codes')); | ||
</script> | ||
{{CodePreviewEnd}} | ||
{{OfficePreview}} | ||
{{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}} | ||
{{OfficePreviewEnd}} {{PasswordPage}} | ||
|
||
<head> | ||
<meta name="renderer" content="webkit"> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
|
@@ -208,7 +205,7 @@ <h2 style='margin-top:0;'>此预览需要前往Office</h2> | |
<h2>输入密码以继续</h2> | ||
<div class='passwordform'> | ||
<form action="#" method="post" style="display: flex;flex: 1;"> | ||
<input class='passwordinput' type="password" name="password" placeholder="password"></input><input type="hidden" name="requestfolder" value="{[FolderMD5]}"/><input type='submit' class='submitbtn' value='Submit'></input> | ||
<input class='passwordinput' type="password" name="password" placeholder="password"></input><input type="hidden" name="requestfolder" value="{[FolderMD5]}" /><input type='submit' class='submitbtn' value='Submit'></input> | ||
</form> | ||
</div> | ||
</div> | ||
|