From: hackbard Date: Thu, 12 Oct 2017 15:39:33 +0000 (+0200) Subject: mods not yet commited X-Git-Url: https://hackdaworld.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a74eb693d6d0c721af6c418263c75eb7bc1628bf;p=outofuni%2Fjsutils.git mods not yet commited --- diff --git a/idb.js b/idb.js index 2e4c9e9..f574688 100644 --- a/idb.js +++ b/idb.js @@ -95,6 +95,15 @@ var idb = { req.onerror=idb.onerror; req.onblocked=idb.onblocked; }, + del_store: function(store,callback) { + var tx=db.handle.transaction(store,'readwrite'); + var store=tx.objectStore(store); + var req=store.clear(); + req.onsuccess=function() { + cl("db: store "+store.name+" deleted"); + callback(); + }; + }, add_store_item: function(store,item,callback) { var tx=idb.handle.transaction(store,'readwrite'); var store=tx.objectStore(store); @@ -106,15 +115,6 @@ var idb = { cl("idb: add item error, "+error); }; }, - del_store: function(store,callback) { - var tx=db.handle.transaction(store,'readwrite'); - var store=tx.objectStore(store); - var req=store.clear(); - req.onsuccess=function() { - cl("db: store "+store.name+" deleted"); - callback(); - }; - }, del_store_item: function(store,num,callback) { var tx=db.handle.transaction(store,'readwrite'); var store=tx.objectStore(store); @@ -303,10 +303,11 @@ var idb = { }; }, - del: function() { + del: function(callback) { var req=indexedDB.deleteDatabase(idb.name); req.onsuccess=function() { cl("idb: deleted database '"+idb.name+"'"); + callback(); }; req.onblocked=function() { cl("idb: database delete blocked"); diff --git a/utils.js b/utils.js index 30190b4..0d78e8b 100644 --- a/utils.js +++ b/utils.js @@ -17,3 +17,35 @@ function objdbg(obj) { cl(msg); } +function anddbg(obj) { + var msg="debug object:\n"; + for(var k in obj) { + msg=msg+"--> "+k+": "+obj[k]+"\n"; + } + alert(msg); +} + +function vert_align_text(trg) { + $(trg).each(function() { + var lh=$(this).height(); + $(this).css('line-height',lh+'px'); + $(this).css('vertical-align','middle'); + }); +} + +function html2ascii(str) { + str=str.replace(/\ä\;/g,"ä"); + str=str.replace(/\ö\;/g,"ö"); + str=str.replace(/\ü\;/g,"ü"); + str=str.replace(/\ß\;/g,"ß"); + return str; +} + +function ascii2html(str) { + str=str.replace(/ä/g,"ä"); + str=str.replace(/ö/g,"ö"); + str=str.replace(/ü/g,"ü"); + str=str.replace(/ß/g,"ß"); + return str; +} +