This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
forked from JulienChebance/bs-drawdown
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
46 lines (41 loc) · 1.5 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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta charset="UTF-8">
<meta name="google" content="notranslate"/>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
<style>
textarea {
resize: none;
}
</style>
<title>drawdown-ss14 preview</title>
</head>
<body>
<textarea class="plain position-absolute w-50 h-100 border-0 border-end font-monospace small"></textarea>
<div class="markdown position-absolute start-50 w-50 h-100 px-2 overflow-auto"></div>
<script type="module">
import markdown from './drawdown-ss14.mjs'
const ein = document.querySelector('.plain')
const eout = document.querySelector('.markdown')
ein.innerHTML = await fetch('https://zerodaydaemon.github.io/drawdown-ss14/README.md').then((res) => res.text())
const update = () => eout.innerHTML = markdown(ein.value)
ein.addEventListener('input', update)
update()
// Synchronize scrollbars
let preventScroll = false;
const scroll = (e) => {
if (preventScroll) {
preventScroll = false
} else {
const other = e.target == ein?eout:ein
preventScroll = true
other.scrollTo(0, (other.scrollHeight - other.clientHeight) * e.target.scrollTop / (e.target.scrollHeight - e.target.clientHeight))
}
}
ein.addEventListener('scroll', scroll)
eout.addEventListener('scroll', scroll)
</script>
</body>
</html>