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

index da0d2cc5400491c8c4f1edb336c2f2dc9f4f07ac..da9692c4ed48eb9a7a250e947561fb2c91190743 100644 (file)
@@ -19,10 +19,9 @@ function json_parse(str, info) {
                return JSON.parse(str);
        } catch (err) {
                if (info != undefined) {
-                       fb('::::' + info);
+                       
                }
                fb(err);
-               fb(str);
        }
 }
 
index dd00146933913e26a3403551f93e0005dbc1c3c2..6c6fefa590c5d8fcd19060dcfda0416d073f62cd 100644 (file)
@@ -11,6 +11,7 @@ var gal = null;
 var home = window.location.toString();
 var resolution = 'auto';
 var OFFLINEAPP = false;
+var FINISHLOADING = false;
 
 try {
        $(function() {
@@ -61,6 +62,9 @@ try {
 
                document.addEventListener('deviceready', onDeviceReady, false);
                document.addEventListener("resume", onAppResume, false);
+               if (!OFFLINEAPP) {
+                       document.addEventListener("offline", onDeviceOffline, false);
+               }
 
                loadJSLibrary(
                                cordova
@@ -68,6 +72,19 @@ try {
                                });
        }
 
+       function onDeviceOffline() {
+               if (OFFLINEAPP) {
+                       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'));
+               }
+       }
+
        function onAppResume() {
                if (!INITED) {
                        return;
@@ -76,7 +93,7 @@ try {
        }
 
        function onDeviceReady() {
-               var manifest = window.sessionStorage.getItem('manifest.' + DATAS.id);
+               var manifest = window.localStorage.getItem('manifest.' + DATAS.id);
                var fsprefix = window.sessionStorage.getItem('galfsprefix');
 
                if (DATAS.phonegap == 'ios') {
@@ -109,7 +126,7 @@ try {
                if (navigator.onLine && manifest && !OFFLINEAPP) {
                        var readyToLoad = false;
                        var finishedLoading = false;
-                       gal = new GameAssetLoader(json_parse(manifest), fsprefix);
+                       gal = new GameAssetLoader(json_parse(manifest, 'manifest'), fsprefix);
 
                        gal.init(function() {
                                startAfterLoading = true;
@@ -276,8 +293,8 @@ try {
                                if (OFFLINEAPP) {
                                        window.location = getPublicationURL(id);
                                } else {
-                                       var topmanifest = window.sessionStorage.getItem('topmanifest');
-                                       window.gallocale = new GameAssetLoader(json_parse(topmanifest,'topmanifest'), window.sessionStorage.getItem('galfsprefix'));
+                                       var topmanifest = window.localStorage.getItem('topmanifest');
+                                       window.gallocale = new GameAssetLoader(json_parse(topmanifest, 'topmanifest'), window.sessionStorage.getItem('galfsprefix'));
                                        window.gallocale.init(function() {
                                                window.gallocale.downloadAndCall('p_' + id, function() {
                                                        window.location = getPublicationURL(id);