mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
New function to count the actual page of the current chapter
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user