templates/blog.html (view raw)
1{% extends "base.html" %}
2
3{% block content %}
4<h2 class="title">{{ section.title }}</h2>
5<p id="welcome" onclick="pls_stop()">Welcome to my blog!</p>
6
7<p>I will post about anything I find interesting or noteworthy, be it
8related to irl stuff or the tech world. I hope someone can read this
9and maybe find it inspiring? If you do, feel free to let me know.</p>
10
11<hr>
12
13<ul>
14 {% for page in section.pages %}
15 <li><a href="{{ page.permalink | safe }}">{{ page.title }}</a><span class="dim">
16 {% if page.taxonomies.category %}
17 [mod {{ page.taxonomies.category[0] }};
18 {% for t in page.taxonomies.tags %}'{{ t }}{% if not loop.last %}, {% endif %}{% endfor %}]
19 {% endif %}
20 </span></li>
21 {% endfor %}
22</ul>
23
24<script>
25 const WELCOME_EN = 'Welcome to my blog!'
26 const WELCOME_IT = 'Benvenuto al mio blog!'
27 const APOLOGIES = "sorry i'll stop"
28 const REWRITE_DELAY = 5000
29 const CHAR_DELAY = 30
30 const welcome = document.getElementById('welcome')
31
32 let deleting = true
33 let english = false
34 let stopped = false
35
36 const pls_stop = () => {
37 stopped = true
38 welcome.innerHTML = APOLOGIES
39 }
40
41 const begin_rewrite = () => {
42 if (stopped) {
43 // now our visitor is angry :(
44 } else if (deleting) {
45 if (welcome.innerHTML == '…') {
46 deleting = false
47 } else {
48 welcome.innerHTML = welcome.innerHTML.slice(0, -1) || '…'
49 }
50 setTimeout(begin_rewrite, CHAR_DELAY)
51 } else {
52 let text = english ? WELCOME_EN : WELCOME_IT
53 welcome.innerHTML = text.slice(0, welcome.innerHTML.length + 1)
54 deleting = welcome.innerHTML.length == text.length
55 english = deleting - english
56 setTimeout(begin_rewrite, deleting ? REWRITE_DELAY : CHAR_DELAY)
57 }
58 }
59
60 setTimeout(begin_rewrite, REWRITE_DELAY)
61</script>
62{% endblock %}