window.IndexedDB = { indexedDB : window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB, storeParams: {keyPath:'key', autoIncrement:false}, open : function(cbk, mod) { var orq = this.indexedDB.open('geos'); orq.onsuccess = function(e) { if (window.mozIndexedDB) { try { cbk(e.target.result.transaction(['pos'], mod).objectStore('pos')); } catch(l) { cbk(e.target.result.transaction(['pos'], ((mode === 0)?'readonly':'readwrite')).objectStore('pos')); } } else { cbk(e.target.result.transaction(['pos'], mod).objectStore('pos')); } }}, reinstall : function() { this.indexedDB.deleteDatabase('geos'); var orq = this.indexedDB.open('geos'); orq.onupgradeneeded = function(e) { e.target.result.createObjectStore('pos', IndexedDB.storeParams); }; orq.onsuccess = function(e) { if (e.target.result.setVersion) { //chromium var crq = e.target.result.setVersion(2); crq.onsuccess = function(e) { e.target.source.createObjectStore('pos', IndexedDB.storeParams); }}}; }, read : function(key, cbk) { this.open(function(obst) { obst.get(key).onsuccess = function(e) {cbk(e.target.result);} }, 0); }, save : function(obj) { this.open(function(obst) {obst.put(obj);}, 1); } };