(function(e){if(e.BX.dataBase)return;var t=e.BX;t.dataBase=function(t){this.tableList=[];if(typeof e.openDatabase!="undefined")this.dbObject=e.openDatabase(t.name,t.version,t.displayName,t.capacity)};t.dataBase.create=function(a){return typeof e.openDatabase!="undefined"?new t.dataBase(a):null};t.dataBase.prototype.isTableExists=function(e,t){var a=this;var r=function(){var r=a.tableList.length;for(var s=0;s0){for(var r=0;r0)u=r[l];if(u.length>0){if(f.length>0)f+=","+u.toUpperCase();else f=u.toUpperCase()}}}n="CREATE TABLE IF NOT EXISTS "+o.toUpperCase()+" ("+f+") ";break}case"drop":{n="DROP TABLE IF EXISTS "+o.toUpperCase();break}case"select":{n="SELECT "+this.getValueArrayString(r,"*")+" FROM "+o.toUpperCase()+" "+this.getFilter(a);t=this.getValues([a]);break}case"insert":{t=this.getValues([s]);n="INSERT INTO "+o.toUpperCase()+" ("+this.getKeyString(s)+") VALUES(%values%)";var p="";for(var c=0;c0)p+=",?";else p="?"}n=n.replace("%values%",p);break}}return{query:n,values:t}};t.dataBase.prototype.getFieldPair=function(e,t){var a="";var r=t||"";if(typeof e=="object"){var s=0;for(var i in e){var o=(s>0?", ":"")+(i.toUpperCase()+"="+"?");if(a.length==0&&r.length>0)a=r;a+=o;s++}}return a};t.dataBase.prototype.getFilter=function(e){var t="";var a="WHERE ";if(typeof e=="object"){var r=0;for(var s in e){var i="";var o=1;if(typeof e[s]=="object")o=e[s].length;for(var n=0;n0?i+" OR ":"(")+(s.toUpperCase()+"="+"?");if(n+1==o)i+=")"}t+=i;r++}}return t==""?"":"WHERE "+t};t.dataBase.prototype.getKeyString=function(e,t){var a="";if(!t)t="";if(typeof e=="array"){for(var r=0;r0)a+=","+valuesItem[r].toUpperCase();else a=valuesItem[r].toUpperCase()}}else if(typeof e=="object"){for(var s in e){if(a.length>0)a+=","+s.toUpperCase();else a=s.toUpperCase()}}if(a.length==0)a=t;return a};t.dataBase.prototype.getValueArrayString=function(e,t){var a="";if(!t)t="";if(typeof e=="object"){for(var r=0;r0)a+=","+e[r].toUpperCase();else a=e[r].toUpperCase()}}if(a.length==0)a=t;return a};t.dataBase.prototype.getValues=function(e){var t=[];for(var a=0;a=0){r.count=s;r.items=[];for(var i=0;i