Quote:
Originally Posted by kindleloh
Hi ixtab,
I have append here a simple ebook from Wikipedia. Book created in odt format and then converted to mobi via calibre.
If you open the book and goto a chapter (e.g. Prelude) then you see a 0% bar. Go one page back (you get about 40%) and go one page forwards so you are at the begin of the chapter Prelude. Now the progress bar is not set to 0% instead it is set to 100%. The same occurs with when you normally read a book and go only forward. The first page in a chapter is always set to 100%.
Thank you very much for your investigation.
|
Ok, so I tried it with the book that you attached and a "debug" version of the patch. Here is the (commented) output:
Code:
# ctx means "context", i.e. the positions which are used for determining the
# start and end positions for the chapter; they are taken straight from the
# book's TOC; the numbers are in the internal format of the TOC.
# Unless ctxEnd == bookEnd, the following invariant always holds:
# ctxStart <= position < ctxEnd
# (if and only if position == bookEnd, the "<" becomes a "<=")
# 0. Open book, goto beginning, turn on chapter progress bar:
position: 0
ctx start: 0
ctx end: 2924
# 1. Goto "Prelude" chapter
position: 8282
ctx start: 8254
ctx end: 17950
# 2. Page back
position: 5968
ctx start: 2924
ctx end: 8254
# 3. Page forward
position: 8238
ctx start: 2924
ctx end: 8254
# 4. Goto "Prelude" chapter again
position: 8282
ctx start: 8254
ctx end: 17950
# 5. Page forward
position: 10225
ctx start: 8254
ctx end: 17950
# 6. Page back
position: 8282
ctx start: 8254
ctx end: 17950
So the code of the patch works absolutely correctly, but something else obviously doesn't. Note how the current position and the context start are
not the same in step 2. Also note that if you perform the abovementioned steps, step 3. actually puts the "Prelude" heading on the second line, while step 4. will put it back on the first line. Finally, paging back and forth will not always lead to the exact same position as where you started from (not even with all Amazon books: "Huckleberry Finns Abenteuer und Fahrten" has occasionally - but interestingly, not always - exposed the same behavior).
This is either a bug in the reader software, or a bug in the book's format, or a combination of both. In any case, it's not a bug in the progress bar patch, and I can't do anything about it. A position before the start of a chapter is a position in the previous chapter, period. In other words: we are going to have to live with it.