summaryrefslogtreecommitdiff
path: root/www/scripts/onload.js
blob: 539df36535e45c022f2c281adec0ba2fcb0f4d6a (plain)
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
function addNodes() {
	const collection = document.getElementsByTagName("section");
	const container = document.getElementById("progressContainer");

	for (var i = 0; i < collection.length; i++) {
	if (collection.item(i).getAttribute('data-excluded') != null) {
		continue;
	}
	var node = document.createElement("a");
	node.className = "node";
	container.appendChild(node);
	if (collection.item(i).getAttribute('id') == null) {
		collection.item(i).setAttribute('id', `section-${i}`);
	}
	node.setAttribute('id', `node-${i}`)
	node.href = `#${collection.item(i).getAttribute('id')}`
	}
	
	replaceExternalLinks();
}

function replaceExternalLinks() {
	for (var links = document.links, i = 0, a; a = links[i]; i++) {
		if (a.host !== location.host) {
			a.target = '_blank';
		}
	}
}

function blog(n) {
	// addNodes is called in loadPost(n);
	loadPost(n);
}

function index() {
	postList(2);
	addNodes();
}

function library() {
	postList();
	addNodes();
}

function blogPost() {
	postList(3);
	addNodes();
}