Skip to content
Browse files

Updated Rllmuk Topic Pagination Tweak for IPB 3.2

  • Loading branch information...
1 parent 628cd97 commit 27c7c5686042a1142bbf3ad6c707abe7aa43fca3 @insin committed Feb 1, 2012
Showing with 24 additions and 19 deletions.
  1. +24 −19 rllmuktopicpaginationtweak.user.js
View
43 rllmuktopicpaginationtweak.user.js
@@ -6,38 +6,43 @@
// @include http://www.rllmukforum.com/*
// ==/UserScript==
+/* Changelog
+ * ---------
+ * 2012-02-01 Updated for IPB 3.2.
+ * 2011-05-03 Initial version.
+ * -------------------------------------------------------------------------- */
+
// Don't do anything if we're not on a topic listing page
if (window.location.href.indexOf("module=search") == -1 &&
- window.location.href.indexOf("/index.php?showforum=") == -1) {
- return;
+ window.location.href.indexOf("index.php?/forum") == -1) {
+ return
}
-var pageNumberRE = /(\d+)/;
-var startIndexRE = /&st=(\d+)/;
+var startIndexRE = /(\d+)$/
-var paginators = document.querySelectorAll("ul.mini_pagination");
+var paginators = document.querySelectorAll("ul.mini_pagination")
for (var i = 0, paginator; paginator = paginators[i]; i++) {
- var links = paginator.getElementsByTagName("a");
+ var links = paginator.getElementsByTagName("a")
if (links.length < 4) {
// Nothing to do - less than 4 links
- continue;
+ continue
}
- var lastPage = parseInt(links[3].textContent, 10);
+ var lastPage = parseInt(links[3].textContent, 10)
if (lastPage == 4) {
// Nothing to do - pages 1-4 being displayed
- continue;
+ continue
}
// Determine number of posts per page from second link
- var postsPerPage = parseInt(startIndexRE.exec(links[1].href)[1], 10);
-
- // Set new page numbers and start indices middle 2 links
- links[1].href = links[2].href.replace(startIndexRE, "&st=" + (postsPerPage * (lastPage - 3)));
- links[1].textContent = lastPage - 2;
- links[1].title = "Go to page " + (lastPage - 2);
- links[2].href = links[2].href.replace(startIndexRE, "&st=" + (postsPerPage * (lastPage - 2)));
- links[2].textContent = lastPage - 1;
- links[2].title = "Go to page " + (lastPage - 1);
-}
+ var postsPerPage = parseInt(startIndexRE.exec(links[1].href)[1], 10)
+
+ // Set new page numbers and start indices on middle 2 links
+ links[1].href = links[2].href.replace(startIndexRE, (postsPerPage * (lastPage - 3)))
+ links[1].textContent = lastPage - 2
+ links[1].title = "Go to page " + (lastPage - 2)
+ links[2].href = links[2].href.replace(startIndexRE, (postsPerPage * (lastPage - 2)))
+ links[2].textContent = lastPage - 1
+ links[2].title = "Go to page " + (lastPage - 1)
+}

0 comments on commit 27c7c56

Please sign in to comment.
Something went wrong with that request. Please try again.