-
Notifications
You must be signed in to change notification settings - Fork 2
/
md.html
76 lines (75 loc) · 1.4 KB
/
md.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
<!DOCTYPE html>
<html>
<head>
<title>Md View</title>
<script>
async function readFile(file) {
return new Promise((resolve, reject) => {
let reader = new FileReader();
reader.addEventListener("load", () => resolve(reader.result));
reader.addEventListener("error", () => reject(reader.result));
reader.readAsText(file);
});
}
let handle = null;
async function reloadFile() {
if (handle == null) handle = (await showOpenFilePicker())[0];
document.getElementById("wrap").innerText =
await readFile(await handle.getFile());
}
</script>
<style>
body {
background-color: #212121;
margin: 0;
}
#head {
background-color: #424242;
width: 100%;
display: flex;
justify-content: space-around;
margin-bottom: 16px;
}
h1, #index {
color: #ffc107;
text-align: center;
font-family: monospace;
font-size: 42px;
flex-grow: 1;
padding: 16px;
margin: 0;
}
#index {
color: #ff5722;
text-decoration: none;
flex-grow: 0;
}
h2 {
color: #ff5722;
font-family: monospace;
}
a {
color: #ffc107;
font-family: monospace;
font-size: 16px;
cursor: pointer;
text-decoration: underline;
}
#wrap {
padding: 0 16px;
color: #f5f5f5;
font-family: monospace;
font-size: 16px;
}
</style>
</head>
<body>
<div id="head">
<a id="index" href="index.html"><</a>
<h1>Markdown Viewer</h1>
</div>
<div id="wrap" onclick="reloadFile()">
Click here to load file.
</div>
</body>
</html>