-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
57 lines (51 loc) · 1.53 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
<!DOCTYPE html>
<html lang="en" color-mode="user">
<head>
<link rel="stylesheet" href="https://unpkg.com/mvp.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Duration Parser</title>
</head>
<body>
<header>
<nav>
</nav>
<h1>ISO8601 Duration Parser</h1>
</header>
<main>
<input type="text" id="txtduration">
<br>
<section>
<aside>
<pre id="output"></pre>
</aside>
</section>
</main>
<footer>
<hr>
<p>
<small><a href="https://github.com/alicekaerast">alice</a></small>
</p>
</footer>
<script>var exports = {"__esModule": true};</script>
<script src="https://unpkg.com/tinyduration@3.3.0/dist/index.js"></script>
<script>
function compute() {
document.querySelector("#txtduration").value = window.location.hash.substring(1) || "P1D";
document.querySelector("#output").textContent = JSON.stringify(parse(document.querySelector("#txtduration").value), null, 2)
}
compute()
document.querySelector("#txtduration").oninput = function () {
try {
document.querySelector("#output").textContent = JSON.stringify(parse(document.querySelector("#txtduration").value), null, 2)
} catch (e) {
document.querySelector("#output").textContent = e.toString()
}
window.location.hash = document.querySelector("#txtduration").value
};
window.addEventListener('hashchange', function () {
compute()
})
</script>
</body>
</html>