Commit a3d64535 authored by deuce's avatar deuce
Browse files

Fix everything up... total_pages is 1-based and firstpage and lastpage are

0-based.
parent 2105fdc0
......@@ -30,16 +30,16 @@ else {
var total_pages=Math.floor(msgarray.length/max_messages+(msgarray.length%max_messages?1:0));
var firstpage=0;
var lastpage=firstpage+max_pages-1;
if(lastpage>total_pages)
lastpage=total_pages;
if(lastpage>=total_pages)
lastpage=total_pages-1;
/* Ensure currpage is inside first/last */
var lcount=0;
while(currpage>lastpage) {
lcount++;
firstpage++;
lastpage=firstpage+max_pages-1;
if(lastpage>total_pages)
lastpage=total_pages;
if(lastpage>=total_pages)
lastpage=total_pages-1;
if(lcount>5000)
currpage=lastpage;
}
......@@ -50,8 +50,8 @@ while(currpage>firstpage+(max_pages/2) && lastpage<total_pages) {
lcount++;
firstpage++;
lastpage=firstpage+max_pages-1;
if(lastpage>total_pages)
lastpage=total_pages;
if(lastpage>=total_pages)
lastpage=total_pages-1;
if(lcount>5000)
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment