]> hackdaworld.org Git - outofuni/jsutils.git/commitdiff
mods not yet commited
authorhackbard <hackbard@hackdaworld.org>
Thu, 12 Oct 2017 15:39:33 +0000 (17:39 +0200)
committerhackbard <hackbard@hackdaworld.org>
Thu, 12 Oct 2017 15:39:33 +0000 (17:39 +0200)
idb.js
utils.js

diff --git a/idb.js b/idb.js
index 2e4c9e9ed3a2a15d71ebdaea2b74724bba0b7161..f574688ea241eb78465222c14d67976971f5e04d 100644 (file)
--- 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");
index 30190b4e922bd198f0f5a88fc1ad91ae8df271c4..0d78e8ba33ca17cb8c762e0ebdeaa7bf6a7a2a65 100644 (file)
--- 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(/\&auml\;/g,"ä");
+       str=str.replace(/\&ouml\;/g,"ö");
+       str=str.replace(/\&uuml\;/g,"ü");
+       str=str.replace(/\&szlig\;/g,"ß");
+       return str;
+}
+
+function ascii2html(str) {
+       str=str.replace(/ä/g,"&auml;");
+       str=str.replace(/ö/g,"&ouml;");
+       str=str.replace(/ü/g,"&uuml;");
+       str=str.replace(/ß/g,"&szlig;");
+       return str;
+}
+