-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_blog-footer.html
More file actions
76 lines (69 loc) · 2.62 KB
/
_blog-footer.html
File metadata and controls
76 lines (69 loc) · 2.62 KB
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
<!-- This is where you put the link to the archives. :-/ -->
(this is in _blog-footer.html)
<div id="blog_nav" style="display:none"></div>
<a href="/blog/archives.html">All blog posts</a> / <a href="">RSS</a>
<script lang="javascript">
function addBlogNav(e){
var myText = oReq.responseText.trim();
var lines = myText.split("\n");
var posts = new Array();
var docPathName = document.location.pathname;
if(docPathName.substring(0, 5) != '/blog' || docPathName == "/blog/archives.html"){
return;
}else{
docPathName = docPathName.substring(6);
}
//console.log("path", docPathName);
var postIndex = -1;
var n = 0;
for (line in lines){
var text = lines[line];
if(line % 2){
posts[n][2] = text.trim();
n += 1;
}else{
var a = text.split(' ');
posts[n] = new Array(a[0],a[1],"");
if(a[1] == docPathName){
//console.log(n,a[1]);
postIndex = n;
}
}
}
var nav_links = "";
var youngerPostMarker = '← ';
var olderPostMarker = '→ ';
if(postIndex > -1){
for(var i=0; i<posts.length; i++ ){
if(i == postIndex - 1){//to younger post
// <span class="date">'+posts[i][0] +'</span>
nav_links +='<div class="index_item">'+youngerPostMarker+'<span class="title"><a href="/blog/'+posts[i][1]+'" title="'+posts[i][0] + ', ' + posts[i][2]+'">'+posts[i][2]+'</a></span></div>\n';
}
if(i == postIndex + 1){// to older post
//<span class="date">'+posts[i][0] +'</span>
nav_links +='<div class="index_item">'+olderPostMarker+'<span class="title"><a href="/blog/'+posts[i][1]+'" title="'+posts[i][0] + ', ' + posts[i][2]+'">'+posts[i][2]+'</a></span></div>\n';
}
}
//console.log(nav_links);
if(nav_links.length > 0){
document.getElementById('blog_nav').innerHTML = nav_links;
document.getElementById('blog_nav').style.display = "block";
}
}else{
//console.log("Post not found, not creating the nav");
}
}
var docPathName = document.location.pathname;
//console.log(docPathName);
if(docPathName == '/blog/' || docPathName == "/blog/archives.html" || docPathName.substring(0, 5) != '/blog'){
// blog index page, archive page or home page.
document.getElementById('blog_end').style.display = "none";
}else{
docPathName = docPathName.substring(6);
var oReq = new XMLHttpRequest();
oReq.open("GET", '/blog/titles', true);
oReq.onload = addBlogNav;
oReq.send();
}
</script>
(end of _blog-footer.html)