blob: 5ec4aa404f20cfd8838023cd9c1f57398df557a8 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
// this is a userscript inspired by "Pipermail Navigation Links" by Michael
// Stone <http://userscripts.org/scripts/show/3174>.
// it adds previous month/next month navigation links in pipermail mailing
// list archives.
// we wrap the whole thing in a function (that gets called immediately) so
// that this script doesn't interfere with any javascript in the page.
(function() {
// figure out what page we're looking at right now
var urlparts = document.location.toString().split("/");
var currView = urlparts[urlparts.length-1].split("#")[0];
var currDate = urlparts[urlparts.length-2].split("-");
// figure out the URLs to the next month and previous month
var months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December' ];
var thisMonth = currDate[1];
var prevMonth;
var nextMonth;
var thisYear = currDate[0];
var prevYear = thisYear;
var nextYear = thisYear;
if(thisMonth == 'January') {
prevMonth = "December";
nextMonth = "February";
prevYear = parseInt(thisYear) - 1;
} else if(thisMonth == 'December') {
prevMonth = "November";
nextMonth = "January";
nextYear = parseInt(thisYear) + 1;
} else {
var monthNum = months.indexOf(thisMonth);
prevMonth = months[monthNum - 1];
nextMonth = months[monthNum + 1];
}
var prevHref = "../" + prevYear + "-" + prevMonth + "/" + currView;
var nextHref = "../" + nextYear + "-" + nextMonth + "/" + currView;
// find the navigation header and footer
var selector = "a[href='date.html#start']";
// if we're on a "date" page then the date link isn't displayed
if(currView == "date.html")
selector = "a[href='author.html#start']";
var navLinks = document.querySelectorAll(selector);
// append the prev/next links to the navigation header and footer
for(var i = 0; i < navLinks.length; i++) {
var victim = navLinks[i].parentNode;
var prevEl = document.createElement("a");
prevEl.textContent = "[ prev month ]";
prevEl.href = prevHref;
var nextEl = document.createElement("a");
nextEl.textContent = "[ next month ]";
nextEl.href = nextHref;
victim.appendChild(prevEl);
victim.appendChild(document.createTextNode(" "));
victim.appendChild(nextEl);
}
})();
|