Post by Peter on Apr 29, 2006 13:24:32 GMT
<script type="text/javascript">
<!--
/*
PBv3 Style Pagination Links
Created by Peter
This code cannot be reposted at anywhere other than SSDesigns or ProBoards, without permission.
This header must stay intact at all times.
*/
// Min. amount of pages before sliding effect takes place. Min. is 10.
var iMin = 10;
var pageObj = {
pages: 0
};
var iSelect = document.getElementsByTagName("select");
var iSpan = document.createElement("span");
function pagination(base, pages, start, min){
var string = "";
var count = countb = 0;
for(i = 1; i <= (pages); i ++){
if(i == start){
string += "<b>" + i + "</b> ";
} else if(pages > min){
if(start > 4 && i > 3 && i < (start - 1) && i < (pages - 3)){
count ++;
string += (count == 1)? "... " : "";
} else if(i > (start + 2) && i < (pages - 2)){
countb ++;
string += (countb == 1)? "... " : "";
} else {
string += "<a href='" + base + i + "'>" + i + "</a> ";
}
} else {
string += "<a href='" + base + i + "'>" + i + "</a> ";
}
}
return string;
}
function swapSel(){
var count = 1;
for(s = 0; s < iSelect.length; s ++){
if(iSelect.item(s).name == "pageMenu"){
pageObj.pages = (iSelect.item(s).options.length);
iSpan.id = "pagelinks" + count;
iSelect.item(s).parentNode.replaceChild(iSpan.cloneNode(true), iSelect.item(s));
s --;
count ++;
}
}
}
if(location.href.match(/board=(\w+)/i)){
swapSel();
var iCur, curBase;
if(location.href.match(/board=(\w+)(&page=(\d+))?$/i)){
iCur = (RegExp.$3.length == 0)? 1 : RegExp.$3;
curBase = "index.cgi?board=" + RegExp.$1 + "&page=";
} else if(location.href.match(/(action=display&)?board=(\w+)(&)(.*thread=\d+)(&page=(\d+))?/i)){
iCur = (RegExp.$6.length == 0)? 1 : RegExp.$6;
curBase = "index.cgi?" + "board=" + RegExp.$2 + "&" + RegExp.$1 + RegExp.$4 + "&page=";
pageObj.pages = (parseInt(pageObj.pages) - 1);
}
var newLinks = pagination(curBase, pageObj.pages, parseInt(iCur), iMin);
for(c = 1; c <= 2; c ++){
if(document.getElementById("pagelinks" + c)){
document.getElementById("pagelinks" + c).innerHTML = newLinks;
}
}
}
//-->
</script>
This was a fun one to write, basically it changes the drop down lists for the pages which is show on the thread display page, and in threads. It changes the drop downs back to the ProBoards v3 style with the pagination slider...
1 2 3 ... 8 9 10 ... 78 79 80
Add the script to the global footers.
<!--
/*
PBv3 Style Pagination Links
Created by Peter
This code cannot be reposted at anywhere other than SSDesigns or ProBoards, without permission.
This header must stay intact at all times.
*/
// Min. amount of pages before sliding effect takes place. Min. is 10.
var iMin = 10;
var pageObj = {
pages: 0
};
var iSelect = document.getElementsByTagName("select");
var iSpan = document.createElement("span");
function pagination(base, pages, start, min){
var string = "";
var count = countb = 0;
for(i = 1; i <= (pages); i ++){
if(i == start){
string += "<b>" + i + "</b> ";
} else if(pages > min){
if(start > 4 && i > 3 && i < (start - 1) && i < (pages - 3)){
count ++;
string += (count == 1)? "... " : "";
} else if(i > (start + 2) && i < (pages - 2)){
countb ++;
string += (countb == 1)? "... " : "";
} else {
string += "<a href='" + base + i + "'>" + i + "</a> ";
}
} else {
string += "<a href='" + base + i + "'>" + i + "</a> ";
}
}
return string;
}
function swapSel(){
var count = 1;
for(s = 0; s < iSelect.length; s ++){
if(iSelect.item(s).name == "pageMenu"){
pageObj.pages = (iSelect.item(s).options.length);
iSpan.id = "pagelinks" + count;
iSelect.item(s).parentNode.replaceChild(iSpan.cloneNode(true), iSelect.item(s));
s --;
count ++;
}
}
}
if(location.href.match(/board=(\w+)/i)){
swapSel();
var iCur, curBase;
if(location.href.match(/board=(\w+)(&page=(\d+))?$/i)){
iCur = (RegExp.$3.length == 0)? 1 : RegExp.$3;
curBase = "index.cgi?board=" + RegExp.$1 + "&page=";
} else if(location.href.match(/(action=display&)?board=(\w+)(&)(.*thread=\d+)(&page=(\d+))?/i)){
iCur = (RegExp.$6.length == 0)? 1 : RegExp.$6;
curBase = "index.cgi?" + "board=" + RegExp.$2 + "&" + RegExp.$1 + RegExp.$4 + "&page=";
pageObj.pages = (parseInt(pageObj.pages) - 1);
}
var newLinks = pagination(curBase, pageObj.pages, parseInt(iCur), iMin);
for(c = 1; c <= 2; c ++){
if(document.getElementById("pagelinks" + c)){
document.getElementById("pagelinks" + c).innerHTML = newLinks;
}
}
}
//-->
</script>
This was a fun one to write, basically it changes the drop down lists for the pages which is show on the thread display page, and in threads. It changes the drop downs back to the ProBoards v3 style with the pagination slider...
1 2 3 ... 8 9 10 ... 78 79 80
Add the script to the global footers.