From: hackbard Date: Wed, 4 May 2016 20:30:37 +0000 (+0200) Subject: increase verbosity + only execute callback during update if defined X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1395597e615dce174f454251ed4e462edd529659;p=outofuni%2Fjsutils.git increase verbosity + only execute callback during update if defined --- diff --git a/idb.js b/idb.js index 20d5ea4..2e4c9e9 100644 --- a/idb.js +++ b/idb.js @@ -25,7 +25,8 @@ var idb = { 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) { @@ -87,6 +88,7 @@ var idb = { 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; @@ -165,7 +167,8 @@ var idb = { 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"); @@ -177,7 +180,8 @@ var idb = { 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)");