diff options
author | Andrew Dolgov <[email protected]> | 2020-11-20 21:05:02 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2020-11-20 21:05:02 +0300 |
commit | 46a92eee384530354806ef527abbf1e37bb68810 (patch) | |
tree | b749f159a2d6ffdd578a5b26a0e34722604f6911 /js/reader.js | |
parent | bb942df3554b4284ee501d0d4d5186b6d945d4fa (diff) |
remove previous offline/online events, add endpoint for the app
Diffstat (limited to 'js/reader.js')
-rw-r--r-- | js/reader.js | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/js/reader.js b/js/reader.js index 40ed656..8d54701 100644 --- a/js/reader.js +++ b/js/reader.js @@ -23,15 +23,12 @@ const Reader = { Reader.Loader.init(); }, - initSecondStage: function() { - - if (typeof EpubeApp != "undefined") { - EpubeApp.setPage("PAGE_READER"); - } + onOfflineModeChanged: function(offline) { + console.log('onOfflineModeChanged', offline); - Reader.applyTheme(); + if (!offline) { + const book = window.book; - $(window).on('online', function() { console.log("we're online, storing lastread"); const currentCfi = book.rendition.currentLocation().start.cfi; @@ -49,6 +46,22 @@ const Reader = { window.location = "index.php"; } }); + } + }, + initSecondStage: function() { + + if (typeof EpubeApp != "undefined") { + EpubeApp.setPage("PAGE_READER"); + } + + Reader.applyTheme(); + + $(window).on('online', function() { + Reader.onOfflineModeChanged(false); + }); + + $(window).on('offline', function() { + Reader.onOfflineModeChanged(true); }); localforage.getItem(Reader.cacheId("book")).then(function(item) { |