summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2020-11-20 21:05:02 +0300
committerAndrew Dolgov <[email protected]>2020-11-20 21:05:02 +0300
commit46a92eee384530354806ef527abbf1e37bb68810 (patch)
treeb749f159a2d6ffdd578a5b26a0e34722604f6911 /js
parentbb942df3554b4284ee501d0d4d5186b6d945d4fa (diff)
remove previous offline/online events, add endpoint for the app
Diffstat (limited to 'js')
-rw-r--r--js/app.js15
-rw-r--r--js/reader.js27
2 files changed, 20 insertions, 22 deletions
diff --git a/js/app.js b/js/app.js
index 910f687..6a7146e 100644
--- a/js/app.js
+++ b/js/app.js
@@ -54,7 +54,6 @@ const App = {
}
App.initNightMode();
- App.initOfflineEvents();
if ('serviceWorker' in navigator) {
navigator.serviceWorker.addEventListener('message', function(event) {
@@ -208,19 +207,6 @@ const App = {
appCheckOffline: function() {
EpubeApp.setOffline(!App.onLine);
},
- initOfflineEvents: function() {
- if (typeof EpubeApp != "undefined") {
- $(window).on('online', function() {
- EpubeApp.setOffline(false);
- });
-
- $(window).on('offline', function() {
- EpubeApp.setOffline(true);
- });
-
- EpubeApp.setOffline(!App.onLine);
- }
- },
initNightMode: function() {
if (typeof EpubeApp != "undefined") {
App.applyNightMode(EpubeApp.isNightMode());
@@ -253,7 +239,6 @@ const App = {
}
App.initNightMode();
- App.initOfflineEvents();
const query = $.urlParam("query");
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) {