]> _ Git - fluidbook-html5.git/commitdiff
(no commit message)
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 15 Nov 2013 14:53:28 +0000 (14:53 +0000)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Fri, 15 Nov 2013 14:53:28 +0000 (14:53 +0000)
js/main.js

index 6c6fefa590c5d8fcd19060dcfda0416d073f62cd..6d40069a1d4a1f75c6a70fe15a508e335b0bb266 100644 (file)
@@ -62,9 +62,7 @@ try {
 
                document.addEventListener('deviceready', onDeviceReady, false);
                document.addEventListener("resume", onAppResume, false);
-               if (!OFFLINEAPP) {
-                       document.addEventListener("offline", onDeviceOffline, false);
-               }
+
 
                loadJSLibrary(
                                cordova
@@ -77,12 +75,14 @@ try {
                        return;
                }
 
-               if (!FINISHLOADING) {
-                       navigator.notification.alert(__('This publication is not available offline. To read it, an internet connection is required'),
-                                       function() {
-                                               window.location = window.sessionStorage.getItem('apphome');
-                                       }, __('An internet connection is required'));
+               if (FINISHLOADING) {
+                       return;
                }
+
+               navigator.notification.alert(__('This publication is not available offline. To read it, an internet connection is required'),
+                               function() {
+                                       window.location = window.sessionStorage.getItem('apphome');
+                               }, __('An internet connection is required'));
        }
 
        function onAppResume() {
@@ -93,6 +93,11 @@ try {
        }
 
        function onDeviceReady() {
+
+
+               document.addEventListener("offline", onDeviceOffline, false);
+
+
                var manifest = window.localStorage.getItem('manifest.' + DATAS.id);
                var fsprefix = window.sessionStorage.getItem('galfsprefix');
 
@@ -146,6 +151,7 @@ try {
                        gal.check('extras', function(info) {
                                if (info.success) {
                                        fb('set offline flag');
+                                       FINISHLOADING = true;
                                        window.localStorage.setItem('offline.' + DATAS.id, '1');
                                }
                        })
@@ -156,6 +162,7 @@ try {
                                }
                                if (info.bundleName == 'extras') {
                                        fb('set offline flag');
+                                       FINISHLOADING = true;
                                        window.localStorage.setItem('offline.' + DATAS.id, '1');
                                }
                                try {
@@ -479,6 +486,10 @@ function searchHints() {
        }
 }
 
+function __(str) {
+       return fluidbook.l10n.__(str);
+}
+
 function cacheUpdated(e) {
        applicationCache.swapCache();
        if (window.confirm(fluidbook.l10n.__('An update of the publication is available. Do you want to load it ?'))) {