-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
94 lines (91 loc) · 2.92 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
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
<!DOCTYPE html>
<html>
<head>
<title>Dedans</title>
<meta charset="utf-8">
<meta name="description" content="What's inside ?"/>
<meta name="keywords" content="html, reader, read, art, loop, larsen, hugohil"/>
<meta name="author" content="hugohil"/>
<meta name="copyright" content="zero"/>
<meta name="application-name" content="Dedans"/>
<meta property="og:title" content="Dedans"/>
<meta property="og:type" content="page"/>
<meta property="og:image" content="http://hugohil.github.io/dedans/picture.png"/>
<meta property="og:url" content="http://hugohil.github.io/dedans/"/>
<meta property="og:description" content="What's inside ?"/>
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="Dedans"/>
<meta name="twitter:description" content="What's inside ?"/>
<meta name="twitter:image" content="http://hugohil.github.io/dedans/picture.png"/>
<style>
html, body {
margin: 0;
padding: 0;
width: 100%;
background: #F1F1F1;
font-family: monospace;
}
.container {
width: 100%;
color: #0F0F0F;
text-align: center;
line-height: 100vh;
}
</style>
</head>
<body>
<div class="container"></div>
<script type="text/javascript">
var container = document.querySelector('.container')
;(function init () {
var req = new window.XMLHttpRequest()
req.open('GET', '#/', true)
req.onreadystatechange = function (state) {
if (req.readyState === 4) {
if (req.status === 200) {
var res = req.responseText
read(res)
} else {
console.log('Error:', req.status)
}
}
}
req.send(null)
})()
function read (text) {
if (!text.length) {
return false
}
var splitted = text.split(/\n/)
for (var i = 0; i < splitted.length + 1; i++) {
if (i < splitted.length) {
(function (line, index) {
setTimeout(function () {
resize(line, container)
container.textContent = line
}, 100 * index)
})(splitted[i], i)
} else {
setTimeout(function () {
var replay = document.createElement('button')
replay.textContent = 'replay'
replay.addEventListener('click', function (event) {
read(text)
})
document.querySelector('.container').appendChild(replay)
}, 100 * i)
}
}
}
function resize (line, element) {
var length = line.length
if (length) {
var width = window.innerWidth / length
element.style.fontSize = Math.floor(width) + 'px'
} else {
element.style.fontSize = 'inherit'
}
}
</script>
</body>
</html>