projects
/
outofuni
/
jsutils.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
6e42229
)
increase verbosity + only execute callback during update if defined
author
hackbard
<hackbard@hackdaworld.org>
Wed, 4 May 2016 20:30:37 +0000
(22:30 +0200)
committer
hackbard
<hackbard@hackdaworld.org>
Wed, 4 May 2016 20:30:37 +0000
(22:30 +0200)
idb.js
patch
|
blob
|
history
diff --git
a/idb.js
b/idb.js
index
20d5ea4
..
2e4c9e9
100644
(file)
--- a/
idb.js
+++ b/
idb.js
@@
-25,7
+25,8
@@
var idb = {
var store=idb.stores[sn]
var key={};
key[store['keytype']]=store['keyname'];
var store=idb.stores[sn]
var key={};
key[store['keytype']]=store['keyname'];
- cl("idb: creating store '"+sn+"'");
+ cl("idb: creating store '"+sn+"' ("+
+ store.keytype+": "+store.keyname+")");
store.os=idb.handle.createObjectStore(sn,key);
// indices
if(store.idx!==undefined) {
store.os=idb.handle.createObjectStore(sn,key);
// indices
if(store.idx!==undefined) {
@@
-87,6
+88,7
@@
var idb = {
idb.successcb=successcb;
if(upgradecb!==undefined)
idb.onupgradeneeded=upgradecb;
idb.successcb=successcb;
if(upgradecb!==undefined)
idb.onupgradeneeded=upgradecb;
+ cl("idb: init database '"+idb.name+"'");
var req=indexedDB.open(idb.name,idb.version);
req.onsuccess=idb.onsuccess;
req.onupgradeneeded=idb.onupgradeneeded;
var req=indexedDB.open(idb.name,idb.version);
req.onsuccess=idb.onsuccess;
req.onupgradeneeded=idb.onupgradeneeded;
@@
-165,7
+167,8
@@
var idb = {
var res=cursor.update(nitem);
res.onsuccess=function(event) {
cl("idb: updated cursor");
var res=cursor.update(nitem);
res.onsuccess=function(event) {
cl("idb: updated cursor");
- callback(event);
+ if(callback!==undefined)
+ callback(event);
};
res.onerror=function(error) {
cl("idb: cursor update error");
};
res.onerror=function(error) {
cl("idb: cursor update error");
@@
-177,7
+180,8
@@
var idb = {
var addreq=store.add(nitem,num);
addreq.onsuccess=function(event) {
cl("idb: added (update mode) key "+num);
var addreq=store.add(nitem,num);
addreq.onsuccess=function(event) {
cl("idb: added (update mode) key "+num);
- callback(event);
+ if(callback!==undefined)
+ callback(event);
}
addreq.onerror=function(error) {
cl("idb: error add (update mode)");
}
addreq.onerror=function(error) {
cl("idb: error add (update mode)");