-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
174 lines (163 loc) · 4.24 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<style>
* {
box-sizing: border-box;
font-family: monospace;
}
#content {
white-space: pre-wrap;
-webkit-user-modify: read-write-plaintext-only;
display: block;
}
</style>
<style contenteditable id="content">/**
* Hi Human!
*
* I am Website.
*
* Not much too see here at the moment...
* I am just a simple style block.
* with some autotyping javascript.
*
* Let's make Website look nice!
*/
/**
* Some smooth transitions are always good
*/
* {
transition: 0.8s all;
}
/**
* Hm, nothing happened..
* Not yet.. ;)
*
* Do you like dark mode, Human?
*/
body {
margin: 14px;
background: rgb(43, 50, 71);
/* That's a bit hard to read, sorry! */
color: white;
}
/**
* That's better!
* Now you can see me again.
*
* Let's make us look like cool hackers.
*/
#content {
overflow: auto;
padding: 12px;
max-height: 300px;
height: 50vh;
width: 600px;
max-width: 100%;
padding: 12px;
margin: 0 auto;
background: rgb(48, 48, 48);
color: lime;
border: 1px solid #ccc;
border-radius: 4px;
box-shadow: 5px 5px 5px 0 rgba(0,0,0,0.3);
}
/**
* Let's have some fun..
* By flipping Website!
*/
#content {
perspective: 1000px;
transform-style: preserve-3d;
transform: rotateY(180deg);
}
/**
* That looks really cool,
* but a bit unpractical.
* Let's flip it back
*/
#content {
transform: rotateY(0deg);
/* but let's make a rainbow background instead! */
background: rgba(0, 0, 0, 0) linear-gradient(45deg, rgb(255, 0, 0) 0%, rgb(255, 154, 0) 10%, rgb(208, 222, 33) 20%, rgb(79, 220, 74) 30%, rgb(63, 218, 216) 40%, rgb(47, 201, 226) 50%, rgb(28, 127, 238) 60%, rgb(95, 21, 242) 70%, rgb(186, 12, 248) 80%, rgb(251, 7, 217) 90%, rgb(255, 0, 0) 100%) repeat scroll 0% 0% / 300% 300%;
background-size: 300%;
color: black;
}
/**
* That is so cool!
* Let's make it even cooler with animations
*/
@keyframes moveGradient {
0% {
background-position: 0 0;
}
100% {
background-position: 100% 0%;
}
}
#content {
/* Let's animate this rainbow forever */
animation: moveGradient 3s linear alternate infinite;
}
/**
* Alright that was fun!
* But forever might be a bit long...
* I'll restore the background
*/
#content {
color: lime;
background: rgb(48, 48, 48);
}
/**
* And finally:
* The author of the source code.
* not that he did a lot,
* I styled myself, but anyway:
*/
#content:after {
display: block;
color: white;
margin-top: 10px;
content: "author: Laurens Verspeek";
}
/*
* I am done for now...
* But you can also edit this box
* Try to play around with it
*/
#content {
/* For example, you could add a text shadow */
text-shadow: 2px 2px 3px black;
}
</style>
<script>
document.addEventListener("DOMContentLoaded", function() {
style = document.getElementById('content');
const initial = style.innerHTML;
style.innerHTML = '';
type(initial, style);
});
// Append a single character at a time to a element
function type (string, el, interval = 26, index = 0) {
if (index < string.length) {
const char = string[index++];
el.innerHTML += char;
// Scroll to bottom of el
window.scrollTo(0, el.scrollHeight);
el.scrollTop = el.scrollHeight;
let multiplier = 1;
// Slow down after certain characters
if (['\n','.','!','?','}'].includes(char)) multiplier = 10;
else if ([',',';',':','{'].includes(char)) multiplier = 5;
else if ([].includes(char)) multiplier = 2;
// Repeat for next characters
setTimeout(() => {
type(string, el, interval, index);
}, interval * multiplier);
}
}
</script>
</body>
</html>