var home = window.location.toString();
var resolution = 'auto';
var OFFLINEAPP = false;
+var FINISHLOADING = false;
try {
$(function() {
document.addEventListener('deviceready', onDeviceReady, false);
document.addEventListener("resume", onAppResume, false);
+ if (!OFFLINEAPP) {
+ document.addEventListener("offline", onDeviceOffline, false);
+ }
loadJSLibrary(
cordova
});
}
+ 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;
}
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') {
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;
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);