From: Vincent Vanwaelscappel Date: Fri, 15 Nov 2013 14:53:28 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=f3df4b68263904db8a0e817b75620139ce152e20;p=fluidbook-html5.git --- diff --git a/js/main.js b/js/main.js index 6c6fefa5..6d40069a 100644 --- a/js/main.js +++ b/js/main.js @@ -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 ?'))) {