all repos — gemini-redirect @ 14474560fedb9c669ce9d1755f94f96a719bac1a

templates/blog.html (view raw)

 1{% extends "base.html" %}
 2
 3{% block content %}
 4<h1 class="title">{{ section.title }}</h1>
 5<p id="welcome" onclick="pls_stop()">Welcome to my blog!</p>
 6
 7<p>Here I occasionally post new entries, mostly tech related. Perhaps it's tips for a new game I'm playing, perhaps it has something to do with FFI, or perhaps I'm fighting the borrow checker (just kidding, I'm over that. Mostly).</p>
 8
 9<hr>
10
11<ul>
12    {% for page in section.pages %}
13    <li><a href="{{ page.permalink | safe }}">{{ page.title }}</a><span class="dim">
14        {% if page.taxonomies.category %}
15        [mod {{ page.taxonomies.category[0] }};
16        {% for t in page.taxonomies.tags %}'{{ t }}{% if not loop.last %}, {% endif %}{% endfor %}]
17        {% endif %}
18    </span></li>
19    {% endfor %}
20</ul>
21
22<script>
23    const WELCOME_EN = 'Welcome to my blog!'
24    const WELCOME_IT = 'Benvenuto al mio blog!'
25    const APOLOGIES = "ok sorry i'll stop"
26    const REWRITE_DELAY = 5000
27    const CHAR_DELAY = 30
28    const welcome = document.getElementById('welcome')
29
30    let deleting = true
31    let english = false
32    let stopped = false
33
34    const pls_stop = () => {
35        stopped = true
36        welcome.innerHTML = APOLOGIES
37    }
38
39    const begin_rewrite = () => {
40        if (stopped) {
41            // now our visitor is angry :(
42        } else if (deleting) {
43            if (welcome.innerHTML == '…') {
44                deleting = false
45            } else {
46                welcome.innerHTML = welcome.innerHTML.slice(0, -1) || '…'
47            }
48            setTimeout(begin_rewrite, CHAR_DELAY)
49        } else {
50            let text = english ? WELCOME_EN : WELCOME_IT
51            welcome.innerHTML = text.slice(0, welcome.innerHTML.length + 1)
52            deleting = welcome.innerHTML.length == text.length
53            english = deleting - english
54            setTimeout(begin_rewrite, deleting ? REWRITE_DELAY : CHAR_DELAY)
55        }
56    }
57
58    setTimeout(begin_rewrite, REWRITE_DELAY)
59</script>
60{% endblock %}