67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
var DataBaseJSRevision="$Revision: 58 $".split(' ')[1]
|
|
|
|
function openOrCreateDatabase(){
|
|
db=$.indexedDB("ShoppingList", {
|
|
"schema" : {
|
|
"1": function(transaction){
|
|
/* maxModified */
|
|
var maxModi=transaction.createObjectStore("maxModified", {
|
|
"autoIncrement": false,
|
|
"keyPath":"objectId"
|
|
});
|
|
|
|
/* Entry */
|
|
var entry=transaction.createObjectStore("Entry", {
|
|
"autoIncrement": true
|
|
});
|
|
entry.createIndex("Description",{unique:false,multiEntry:false},"Description");
|
|
|
|
/* Config */
|
|
var config=transaction.createObjectStore("Config", {
|
|
"autoIncrement": false,
|
|
"keyPath": "Id"
|
|
});
|
|
|
|
/* TransferQ*/
|
|
var transferQ=transaction.createObjectStore("TransferQ", {
|
|
"autoIncrement": true
|
|
});
|
|
transferQ.createIndex("type",{unique:false,multiEntry:false},"type");
|
|
|
|
/* Shop */
|
|
var shop=transaction.createObjectStore("Shop", {
|
|
"autoIncrement": false,
|
|
"keyPath": "GlobalId"
|
|
})
|
|
},
|
|
"2": function(transaction){
|
|
transaction.objectStore("Shop").createIndex("Description",{unique:false,multiEntry:false},"Description");
|
|
}
|
|
}
|
|
}).progress(function(db,event) {
|
|
console.log("Progress creating DB",db,event);
|
|
}).done(function(db,event){
|
|
console.log("Success creating DB",db,event);
|
|
}).fail(function(error,event){
|
|
console.log("ERROR on DB Creation",error,event);
|
|
|
|
var errCode = "N/A";
|
|
|
|
try {
|
|
errCode=error.debug[1].code;
|
|
} catch (err) {}
|
|
|
|
if (5==errCode) {
|
|
console.log("Known timing issue with polyfill ...");
|
|
} else {
|
|
|
|
if (confirm('A problem with the local DB found ("' + error.message + '") deleting the DB might help - proceed?')) {
|
|
$.indexedDB("ShoppingList").deleteDatabase("Shoppinglist").done(function(){
|
|
window.location.reload()
|
|
});
|
|
}
|
|
}
|
|
|
|
});
|
|
}
|