myDebug(' (c) IndexDB select localStorage '+k+' -> null on ne fait donc pas le localStorage :-)');
}
cursor.continue();
myDebug("IndexDB : read OK");
$('#loadingStep').text('Etape 7a');
switchLoginOrMenu();
}
else{
$('#loadingStep').text('Etape 6b');
myDebug("No more entries!");
switchLoginOrMenu();
}
};
objectStore.openCursor().onerror=function(event){
myDebug(" IndexDB Error "+error.message);
$('#loadingStep').text('Etape 7b');
switchLoginOrMenu();
});
}
else{
}
};
openRequest.onupgradeneeded=function(event){
$('#loadingStep').text('Etape 4b');
ons.notification.alert("Un élément nécessaire au bon fonctionnement de l'application n'est pas disponible ! (Erreur SQLite)",{title:"Erreur"}).then(function(){
closePage(true);
});
}
myDebug("global db upgrade or create");
// This is either a newly created database, or a new version number
// has been submitted to the open() call.
vardb=event.target.result;
db.onerror=function(){
myDebug(db.errorCode);
};
// Create an object store and indexes. A key is a data value used to organize
// and retrieve values in the object store. The keyPath option identifies where
// the key is stored. If a key path is specified, the store can only contain
// JavaScript objects, and each object stored must have a property with the
// same name as the key path (unless the autoIncrement option is true).
ajaxDownloadCSS.abort();varajaxDownloadCSS=$.ajax({type:"POST",timeout:5000,url:localGetData("api_server")+"/api/CustomizingApp/css",data:{email:localGetData("email"),},beforeSend:function(xhr){xhr.setRequestHeader('Authorization','Bearer '+localGetData("api_token"));},xhrFields:{responseType:'arraybuffer',withCredentials:true},success:function(data){globalNetworkResponse=Date.now();hideWait();myDebug('downloadCustomCSS : done');letblob=newBlob([data],{type:"text/css"});letcssFileName='/custom.css';myDebug(blob.size);myDebug(data);window.resolveLocalFileSystemURL(cordova.file.cacheDirectory,function(directoryEntry){myDebug('downloadCustomCSS Write to '+cordova.file.cacheDirectory);directoryEntry.getFile(cssFileName,{create:true},function(fileEntry){myDebug('downloadCustomCSS Write to '+cssFileName);fileEntry.createWriter(function(fileWriter){fileWriter.onwriteend=function(e){myDebug('downloadCustomCSS Write of file completed.');myDebug(fileEntry.fullPath);myDebug(fileEntry);loadCustomCSS();};fileWriter.onerror=function(e){};fileWriter.write(data);});});});},error:function(result){hideWait();myDebug('downloadCustomCSS error.');}});}
ons.ready(function(){ons.enableDeviceBackButtonHandler();ons.setDefaultDeviceBackButtonListener(function(event){fn.back();});varpath=window.location.pathname;varpage=path.split("/").pop();if(page!="index.html"){if(globalDB==null){if(typeofwindow.sqlitePlugin!='undefined'){globalDB=window.sqlitePlugin.openDatabase({name:'doliscan.db',location:'default',androidDatabaseProvider:'system'},function(){});}}}});document.addEventListener("deviceready",NDFonDeviceReady,false);functionNDFonDeviceReady(){myDebug("NDFonDeviceReady de ndf.js");if(navigator.camera!==undefined){globalMyCamera=navigator.camera;globalPictureSource=navigator.camera.PictureSourceType;globalDestinationType=navigator.camera.DestinationType;globalMyCamera.cleanup();}
ons.ready(function(){ons.enableDeviceBackButtonHandler();ons.setDefaultDeviceBackButtonListener(function(event){fn.back();});varpath=window.location.pathname;varpage=path.split("/").pop();if(page!="index.html"){if(globalIndexDB==null){varopenRequest=window.indexedDB.open(databaseName,databaseVersion);openRequest.onerror=function(event){myDebug(openRequest.errorCode);};openRequest.onsuccess=function(event){globalIndexDB=openRequest.result;myDebug("global db type indexDB open ok");}}}});document.addEventListener("deviceready",NDFonDeviceReady,false);functionNDFonDeviceReady(){myDebug("NDFonDeviceReady de ndf.js");if(navigator.camera!==undefined){globalMyCamera=navigator.camera;globalPictureSource=navigator.camera.PictureSourceType;globalDestinationType=navigator.camera.DestinationType;globalMyCamera.cleanup();}
else{myDebug("Erreur: camera introuvable !");}
myDebug("NDFonDeviceReady de ndf.js : camera ready");}
if(globalIndexDB==null){varopenRequest=window.indexedDB.open(databaseName,databaseVersion);openRequest.onerror=function(event){myDebug(openRequest.errorCode);myDebug("global db type indexDB re-open error");};openRequest.onsuccess=function(event){globalIndexDB=openRequest.result;myDebug("global db type indexDB re-open ok");}}
if(globalIndexDB!==null){myDebug("global db type indexDB put data asked ...");vartransaction=globalIndexDB.transaction(["config"],"readwrite");varobjectStore=transaction.objectStore("config");varrequest=objectStore.put({key:lakey,data:lavalue});request.oncomplete=function(){myDebug("objectStore.put ok");}
request.onerror=function(){myDebug("objectStore.put err pour "+lakey+" : "+lavalue);}}
else{myDebug(" ERR: Accès à globalIndexDB impossible pour stocker "+lakey+" val "+lavalue);}}