New function to count the actual page of the current chapter

This commit is contained in:
WS64
2014-07-03 18:19:28 +02:00
parent 1de31b9184
commit cc81d49cc9

View File

@@ -111,7 +111,7 @@ function ReaderToc:_getChapterPagesLeft(pageno,pages)
j=0
if #self.toc > 0 then
for i=1, #self.toc do
for i = 1, #self.toc do
v = self.toc[i]
if v.page > pageno then
j = v.page
@@ -119,13 +119,45 @@ function ReaderToc:_getChapterPagesLeft(pageno,pages)
end
end
end
if j==0 then
return pages-pageno
if j == 0 then
if pages > 0 then
return pages-pageno
else
return ""
end
else
return j-pageno-1
end
end
function ReaderToc:_getChapterPagesDone(pageno)
if not self.toc then
-- build toc when needed.
self:fillToc()
end
-- no table of content
if #self.toc == 0 then
return ""
end
j=0
if #self.toc > 0 then
for i = 1, #self.toc do
v = self.toc[i]
if v.page >= pageno then
break
end
j = v.page
end
end
if j < 2 then
return ""
else
return j-pageno
end
end
function ReaderToc:onShowToc()
if not self.toc then