-
Notifications
You must be signed in to change notification settings - Fork 0
/
codePrint.html
82 lines (75 loc) · 1.71 KB
/
codePrint.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
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
<meta charset="UTF-8">
<title></title>
<style>
@import url(https://fonts.googleapis.com/css?family=Source+Code+Pro:600);
* {
margin: 0;
padding: 0;
border: 0;
}
body {
background: hsla(0, 5%, 5%, 1);
}
h1 {
color: hsla(172, 5%, 85%, 1);
text-align: center;
font-size: 4em;
margin-top: 0;
}
pre {
position: absolute;
font-size: 1.1em;
font-family: 'Source Code Pro';
/* margin: 0% 5% 0% 7%;*/
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
width: 80%;
border-radius: 2px;
background-color: hsla(172, 5%, 85%, 1);
border: 1px solid hsla(0, 5%, 5%, 1);
padding: 1em 2em;
color: hsla(0, 5%, 15%, 1);
text-shadow: 1px 1px hsla(0, 5%, 5%, .4);
text-align: left;
}
</style>
</head>
<body>
<h1>*</h1>
<pre id="code"></pre>
<script type="text/javascript">
(function run() {
'use strict';
var pre = document.getElementById('code');
var text = run.toString();
// wait
function* wait(t) {
for (; t; t--) {
yield t;
}
}
// generate
var i = function*() {
yield * wait(10);
for (var j = 0; j < text.length; j++) {
pre.textContent += text[j];
yield * wait(1);
}
}();
// Call timer(setInterval)
var timer = setInterval(function() {
if (i.next().done) {
clearInterval(timer);
}
}, 1000 / 10);
// Write the code. Change the world.
})();
</script>
</body>
</html>