3 document
.addEventListener("DOMContentLoaded", function() {
4 const doTransition = function(e
, trans
, state
, speed
) {
5 e
.classList
.remove(trans
+ "-in", trans
+ "-out", "trans-slow", "trans-fast");
6 e
.classList
.add(trans
+ "-" + state
, "trans-" + speed
);
7 return (cb
) => setTimeout(cb
, speed
=== "slow" ? 600 : 200);
9 const letElementBlink = function(e
, last
) {
10 setTimeout(() => doTransition(e
, "fade", "out", "fast")(function() {
11 e
.classList
.add("blink");
12 doTransition(e
, "fade", "in", "fast")(function() {
13 e
.classList
.remove("blink");
14 doTransition(e
, "fade", "out", "slow")(function () {
15 doTransition(e
, "fade", "in", "slow");
20 const onHashChange = function() {
21 if (location
.hash
.length
> 1) {
22 let hash
= decodeURIComponent(location
.hash
.substring(1));
23 let e
= document
.getElementById(hash
) || document
.getElementById(location
.hash
.substring(1));
27 if (hash
.substring(hash
.length
-1) === "*") {
28 hash
= hash
.substring(0, hash
.length
-1);
30 let klass
= (hash
.substring(0,1) === "$") ? "var" : "constant";
32 Array
.prototype.forEach
.call(document
.getElementsByClassName(klass
), function(e
) {
33 if (e
.textContent
.substring(0, hash
.length
) !== hash
) {
38 window
.scrollTo(0, e
.offsetTop
> 64 ? e
.offsetTop
- 64 : 0);
47 window
.addEventListener("hashchange", onHashChange
);
48 setTimeout(()=>document
.getElementsByTagName("footer")[0].classList
.add("hidden"), 1000);