HTML and CSS Reference
In-Depth Information
}
request.onerror = function(event) {
errorCallback('storage_not_initalized', 'It is not possible to initialized storage');
}
} else {
errorCallback('storage_api_not_supported', 'The web storage api is not supported');
}
},
initObjectStore : function(type, successCallback, errorCallback) {
if (!database) {
errorCallback('storage_api_not_initialized', 'The storage engine has not been initialized');
}
var exists = false;
$.each(database.objectStoreNames, function(i, v) {
if (v == type) {
exists = true;
}
});
if (exists) {
successCallback(null);
} else {
var version = database.version+1;
database.close();
var request = indexedDB.open(window.location.hostname+'DB', version);
request.onsuccess = function(event) {
successCallback(null);
}
request.onerror = function(event) {
errorCallback('storage_not_initalized', 'It is not possible to initialized storage');
}
request.onupgradeneeded = function(event) {
database = event.target.result;
var objectStore = database.createObjectStore(type, { keyPath: "id", autoIncrement: true });
Search WWH ::




Custom Search