parent
3d512bf5c4
commit
9b620ba18a
@ -294,19 +294,24 @@ angular.module('izhukov.utils', [])
|
|||||||
return openDbPromise;
|
return openDbPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = indexedDB.open(dbName, dbVersion),
|
try {
|
||||||
deferred = $q.defer(),
|
var request = indexedDB.open(dbName, dbVersion),
|
||||||
createObjectStore = function (db) {
|
deferred = $q.defer(),
|
||||||
db.createObjectStore(dbStoreName);
|
createObjectStore = function (db) {
|
||||||
};
|
db.createObjectStore(dbStoreName);
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
storageIsAvailable = false;
|
||||||
|
return $q.reject(error);
|
||||||
|
}
|
||||||
|
|
||||||
request.onsuccess = function (event) {
|
request.onsuccess = function (event) {
|
||||||
db = request.result;
|
db = request.result;
|
||||||
|
|
||||||
db.onerror = function (event) {
|
db.onerror = function (error) {
|
||||||
storageIsAvailable = false;
|
storageIsAvailable = false;
|
||||||
console.error("Error creating/accessing IndexedDB database", event);
|
console.error('Error creating/accessing IndexedDB database', error);
|
||||||
deferred.reject(event);
|
deferred.reject(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Interim solution for Google Chrome to create an objectStore. Will be deprecated
|
// Interim solution for Google Chrome to create an objectStore. Will be deprecated
|
||||||
@ -326,6 +331,12 @@ angular.module('izhukov.utils', [])
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
request.onerror = function (event) {
|
||||||
|
storageIsAvailable = false;
|
||||||
|
console.error('Error creating/accessing IndexedDB database', event);
|
||||||
|
deferred.reject(event);
|
||||||
|
}
|
||||||
|
|
||||||
request.onupgradeneeded = function (event) {
|
request.onupgradeneeded = function (event) {
|
||||||
createObjectStore(event.target.result);
|
createObjectStore(event.target.result);
|
||||||
};
|
};
|
||||||
@ -385,6 +396,8 @@ angular.module('izhukov.utils', [])
|
|||||||
return $q.when(fakeWriter);
|
return $q.when(fakeWriter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openDatabase();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAvailable: isAvailable,
|
isAvailable: isAvailable,
|
||||||
saveFile: saveFile,
|
saveFile: saveFile,
|
||||||
@ -481,6 +494,8 @@ angular.module('izhukov.utils', [])
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requestFS();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
isAvailable: isAvailable,
|
isAvailable: isAvailable,
|
||||||
saveFile: saveFile,
|
saveFile: saveFile,
|
||||||
|
Loading…
Reference in New Issue
Block a user