Files
ShoppingList/globals.js
2020-08-29 14:11:41 -05:00

82 lines
2.8 KiB
JavaScript

var GlobalsJSRevision="$Revision: 58 $".split(' ')[1]
var sGShoppingListName="";
var sGBrowserId="";
var isBlocked=false;
var revision="$Revision: 58 $".split(" ")[1];
var db=null;
function initSession(){
openOrCreateDatabase();
db.objectStore("Config").get("ShoppingListName").done(function(result, event){
if (result != null) {
sGShoppingListName=result.value
db.objectStore("Config").get("BrowserId").done(function(result, event){
if (result != null) {
sGBrowserId=result.value;
db.objectStore("Config").get("ActiveShopId").done(function(result, event){
if (result != null) {
console.log("Found Shop in Config",result.value);
loadAndShowShops(result.value);
} else {
console.log("No Shop in Config. ");
loadAndShowShops();
}
}).fail(function (error,event){
console.log("Error loading Shop from Config");
loadAndShowShops();
});
// on start check for item changes
check4Changes();
updateTransferQCounter();
setMode("Entries");
} else {
setMode("Branding");
}
})
} else {
setMode("Branding");
}
}).fail(function (error,event){
console.log("Error when reading the initial config information",error,event);
var errCode = "N/A";
try {
errCode=error.debug[1].code;
} catch (err) {}
if (5==errCode) {
console.log("Known timing issue with polyfill ..., re-triggering DB-creation..");
// re-trigger DB-creation... by the time the user is finished with the branding we should be fine...
openOrCreateDatabase();
setMode("Branding");
} else {
alert("Error while reading initial config information: " + error + ":" + event)
}
});
// Check if a new cache is available on page load. || TODO: the Server could notify for new versions, then the check would be done closer to time.
window.addEventListener('load', function(e) {
try{
window.applicationCache.addEventListener('updateready', function(e) {
if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
// Intentially not calling swapcache here, it's quite useless because it will only use the new verstion for newly loaded files anyway...
if (confirm('A new version of this site is available. Load it?')) {
window.location.reload();
}
} else {
// Manifest didn't changed. Nothing new to server.
}
}, false);
} catch (ex) {
console.log("Quick Fix - switch off AppCachea",ex);
}
}, false);
var indexHtmlRevision = $("#lbRevision").text().split(" ")[1];
$("#lbRevision").text("Index.html " + indexHtmlRevision + " | dataHandler " + DataHandlerJSRevision + " | transfer " + TransferJSRevision + " | helpers " + HelpersJSRevision + " | uictrl " + UiControlerJSRevision + " | database " + DataBaseJSRevision)
}