Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save and track reading progress #726

Open
rayssafs opened this issue Aug 7, 2019 · 1 comment
Open

Save and track reading progress #726

rayssafs opened this issue Aug 7, 2019 · 1 comment

Comments

@rayssafs
Copy link

rayssafs commented Aug 7, 2019

Hello, I would like to know if there is a way to save and track the reading progress, without saving this information in local storage/ browser. For example, if the users use the reading channel in different devices, they should be able to start on the same page they stop the reading.

@danielweck
Copy link
Member

The functionality you are describing is currently not implemented, but you can of course replace the LocalStorage code with an alternative method. There is currently no "extensibility" API to introduce such feature, so you would have to modify the existing code.

From the top of my head, I would suggest looking into the savePlace() function:

var savePlace = function(){
var bookmarkString = readium.reader.bookmarkCurrentPage();
// Note: automatically JSON.stringify's the passed value!
// ... and bookmarkCurrentPage() is already JSON.toString'ed, so that's twice!
Settings.put(ebookURL_filepath, bookmarkString, $.noop);
if (!isChromeExtensionPackagedApp // History API is disabled in packaged apps
&& window.history && window.history.replaceState) {
var urlParams = Helpers.getURLQueryParams();
var ebookURL = urlParams['epub'];
if (!ebookURL) return;
ebookURL = ensureUrlIsRelativeToApp(ebookURL);
var bookmark = JSON.parse(bookmarkString) || {};
var epubs = urlParams['epubs'];
var gotoParam = generateQueryParamCFI(bookmark);
var url = Helpers.buildUrlQueryParameters(undefined, {
epub: ebookURL,
epubs: (epubs ? epubs : " "),
embedded: " ",
goto: {value: gotoParam ? gotoParam : " ", verbatim: true}
});
history.replaceState(
{epub: ebookURL, epubs: (epubs ? epubs : undefined)},
"Readium Viewer",
url
);
}
};

...more specifically reader.bookmarkCurrentPage() and Settings.put() which you could use as a hook / extension point for your distributed / remote storage facility:

var bookmarkString = readium.reader.bookmarkCurrentPage();
// Note: automatically JSON.stringify's the passed value!
// ... and bookmarkCurrentPage() is already JSON.toString'ed, so that's twice!
Settings.put(ebookURL_filepath, bookmarkString, $.noop);

Settings = {
put : function(key, val, callback){
if (!isLocalStorageEnabled()) {
if (callback) callback();
return;
}
var val = JSON.stringify(val);
localStorage[key] = val;
if (callback){
callback();
}
},

I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants