From 12896a8faca829987f5fb79248b489536015ebd0 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 13 Nov 2013 13:52:02 +0000 Subject: [PATCH] --- js/libs/fluidbook/fluidbook.js | 4 +-- js/libs/fluidbook/fluidbook.loader.js | 2 +- js/main.js | 38 +++++++++++++++++---------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/js/libs/fluidbook/fluidbook.js b/js/libs/fluidbook/fluidbook.js index 7c730cbc..623b31fc 100644 --- a/js/libs/fluidbook/fluidbook.js +++ b/js/libs/fluidbook/fluidbook.js @@ -764,7 +764,7 @@ Fluidbook.prototype = { bookmark: 'thumbnails', video: 'extras'}; - if (this.gal != null && preload[view] != undefined) { + if (!OFFLINEAPP && this.gal != null && preload[view] != undefined) { var w = this.addWaiter(true); this.gal.downloadAndCall(preload[view], function() { if ($this.waiterActive(w)) { @@ -1249,7 +1249,7 @@ Fluidbook.prototype = { } var e = pdf.split('/'); pdfName = e.pop(); - if (this.gal) { + if (this.gal && !OFFLINEAPP) { this.displayLoader(); this.gal.downloadAndCall('extras', function() { $this._openFile(pdf, $("#print"), 'pdf', pdfName); diff --git a/js/libs/fluidbook/fluidbook.loader.js b/js/libs/fluidbook/fluidbook.loader.js index 0d15f9c9..a758d0fe 100644 --- a/js/libs/fluidbook/fluidbook.loader.js +++ b/js/libs/fluidbook/fluidbook.loader.js @@ -210,7 +210,7 @@ FluidbookLoader.prototype = { callback(); } else { var $this = this; - if (window.gal != undefined) { + if (window.gal != undefined && !OFLINEAPP) { window.gal.downloadAndCall('content_' + page, function() { $this.__loadBackground(page, callback); }, 250); diff --git a/js/main.js b/js/main.js index 29c14a10..3fdefc89 100644 --- a/js/main.js +++ b/js/main.js @@ -10,6 +10,7 @@ var startAfterLoading = false; var gal = null; var home = window.location.toString(); var resolution = 'auto'; +var OFFLINEAPP = false; try { $(function() { @@ -52,6 +53,8 @@ try { function loadPhonegap() { var cordova = 'data/cordova.js'; var cordovaStorage = window.localStorage.getItem('cordova'); + OFFLINEAPP = window.localStorage.getItem('offlineapp') == '1'; + if (cordovaStorage) { cordova = window.localStorage.getItem('cordova'); } @@ -62,7 +65,7 @@ try { loadJSLibrary( cordova , function() { - }); + }); } function onAppResume() { @@ -91,11 +94,11 @@ try { resolution = collection.res; } - if (DATAS.phonegap && !manifest) { + if (DATAS.phonegap && !manifest && !OFFLINEAPP) { manifest = collection.manifestPub[DATAS.id]; } - if (navigator.onLine && manifest) { + if (navigator.onLine && manifest && !OFFLINEAPP) { var readyToLoad = false; var finishedLoading = false; gal = new GameAssetLoader(JSON.parse(manifest), fsprefix); @@ -259,18 +262,25 @@ try { var id = $(this).data('id'); window.localStorage.setItem('locale', locale); - var topmanifest = window.sessionStorage.getItem('topmanifest'); - window.gallocale = new GameAssetLoader(JSON.parse(topmanifest), window.sessionStorage.getItem('galfsprefix')); - window.gallocale.init(function() { - window.gallocale.downloadAndCall('p_' + id, function() { - var url = window.home; - var replace = "/" + fluidbook.datas.id + "/"; - var replaceby = "/" + id + "/"; - url = url.replace(replace, replaceby); - var c = window.localStorage.getItem('collection'); - window.location = url; + if (OFFLINEAPP) { + /** + * + * @todo + */ + } else { + var topmanifest = window.sessionStorage.getItem('topmanifest'); + window.gallocale = new GameAssetLoader(JSON.parse(topmanifest), window.sessionStorage.getItem('galfsprefix')); + window.gallocale.init(function() { + window.gallocale.downloadAndCall('p_' + id, function() { + var url = window.home; + var replace = "/" + fluidbook.datas.id + "/"; + var replaceby = "/" + id + "/"; + url = url.replace(replace, replaceby); + var c = window.localStorage.getItem('collection'); + window.location = url; + }); }); - }); + } } catch (err) { } -- 2.39.5