Skip to content
Browse files

indexed db works in ff and chrome

  • Loading branch information...
1 parent 5bdc813 commit eeef5e522292568dd821d749eb116674d87051e1 @koto committed Apr 10, 2012
Showing with 15 additions and 5 deletions.
  1. +15 −5 console.html
View
20 console.html
@@ -453,6 +453,12 @@
req.onsuccess = function(event) {
db = event.target.result;
+ if (db.setVersion && !db.objectStoreNames.contains('screenshots')) { // chrome
+ db.setVersion('1').onsuccess = function(e) {
+ req.init(db);
+ }
+
+ }
}
req.onerror = function(event) {
@@ -461,9 +467,13 @@
req.onupgradeneeded = function(event) {
al('Upgrading DB...');
- event.target.result.createObjectStore("screenshots", {keyPath: "id", autoIncrement:true});
+ req.init(event.target.result);
db = event.target.result;
}
+
+ req.init = function(o) {
+ o.createObjectStore("screenshots", {keyPath: "id", autoIncrement:true});
+ }
}
function updateHookName(hookName) {
@@ -898,8 +908,8 @@
al('Error, no screenshots store. Database not initialized?');
return false;
}
-
- var t = db.transaction(["screenshots"], IDBTransaction.READ_WRITE);
+ var mode = window.webkitIDBTransaction ? webkitIDBTransaction.READ_WRITE : IDBTransaction.READ_WRITE;
+ var t = db.transaction(["screenshots"], mode);
t.objectStore('screenshots')
.add({
'hook': hook,
@@ -912,10 +922,10 @@
$('#screenshot-modal').modal('hide');
};
t.oncomplete = function() {
- console.log('complete');
+ //console.log('complete');
}
t.onerror = function() {
- console.log('e');
+ //console.log('e');
}
});

0 comments on commit eeef5e5

Please sign in to comment.
Something went wrong with that request. Please try again.