var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; }; if (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } } { let window = _____WB$wombat$assign$function_____("window"); let self = _____WB$wombat$assign$function_____("self"); let document = _____WB$wombat$assign$function_____("document"); let location = _____WB$wombat$assign$function_____("location"); let top = _____WB$wombat$assign$function_____("top"); let parent = _____WB$wombat$assign$function_____("parent"); let frames = _____WB$wombat$assign$function_____("frames"); let opener = _____WB$wombat$assign$function_____("opener"); (function(e){if(e.BX.dataBase)return;var t=e.BX;t.dataBase=function(t){this.tableList=[];this.jsonFields={};if(typeof e.SQLitePlugin!="undefined"&&typeof e.SQLitePlugin.openDatabase=="function"){this.dbObject=e.SQLitePlugin.openDatabase(t);this.dbBandle="SQLitePlugin"}else if(typeof e.openDatabase!="undefined"){this.dbBandle="openDatabase";this.dbObject=e.openDatabase(t.name,t.version,t.displayName,t.capacity)}else{this.dbBandle="undefined";this.dbObject=null}};t.dataBase.create=function(i){if(typeof e.openDatabase!="undefined"||typeof e.SQLitePlugin!="undefined"&&typeof e.SQLitePlugin.openDatabase=="function"){return new t.dataBase(i)}else{return null}};t.dataBase.prototype.setJsonFields=function(e,i){if(typeof i=="string"){if(i==""){i=[]}else{i=[i]}}if(e&&t.type.isArray(i)){e=e.toString().toUpperCase();this.jsonFields[e]=[];if(i.length>0){for(var a=0;a-1){i(true,e);a.fulfill(e)}else{i(false,e);a.reject(e)}};if(this.tableList.length<=0){this.getTableList().then(s)}else{s(this.tableList)}return a};t.dataBase.prototype.getTableList=function(e){var i=new t.Promise;if(typeof e!="function"){e=function(){}}var a=e;this.query({query:"SELECT tbl_name from sqlite_master WHERE type = 'table'",values:[]}).then(function(e){this.tableList=[];if(e.result.count>0){for(var t=0;t0){p=n[y]}if(p.length>0){if(c.length>0)c+=","+p.toUpperCase();else c=p.toUpperCase()}}}l="CREATE TABLE IF NOT EXISTS "+u.toUpperCase()+" ("+c+") ";break}case"drop":{l="DROP TABLE IF EXISTS "+u.toUpperCase();break}case"select":{var g=[];if(s&&typeof s=="object"){for(var v in s){if(s.hasOwnProperty(v)){g.push(v+" "+(s[v]=="DESC"?"DESC":"ASC"))}}}var d=null;if(r){if(typeof r=="object"){d=parseInt(r.limit)+(r.offset?", "+parseInt(r.offset):"")}else if(typeof r=="number"){d=r}}l="SELECT "+this.getValueArrayString(n,"*")+" FROM "+u.toUpperCase()+" "+this.getFilter(a)+(g.length>0?" ORDER BY "+g.join(", ")+" ":"")+(d?" LIMIT "+d+" ":"");i=this.getValues([a]);break}case"replace":{var b=0;var m=0;var j="";if(t.type.isArray(o)){i=this.getValues(o,"insert");for(var S in o[0]){m++}b=o.length;j=this.getKeyString(o[0])}else{i=this.getValues([o],"insert");b=1;m=i.length;j=this.getKeyString(o)}l="REPLACE INTO "+u.toUpperCase()+" ("+j+") VALUES %values%";var q=[];var B=[];for(var S=0;S0?", ":"")+(r.toUpperCase()+"="+"?");if(i.length==0&&a.length>0)i=a;i+=n;s++}}return i};t.dataBase.prototype.getFilter=function(e){var t="";var i="WHERE ";if(typeof e=="object"){var a=0;for(var s in e){var r="";var n=1;if(typeof e[s]=="object"){n=e[s].length}for(var o=0;o0?r+" OR ":"(")+(s.toUpperCase()+"="+"?");if(o+1==n)r+=")"}t+=r;a++}}else if(typeof e=="string"){t=e}return t==""?"":"WHERE "+t};t.dataBase.prototype.getKeyString=function(e,i){var a="";if(!i)i="";if(t.type.isArray(e)){for(var s=0;s0)a+=","+r.toUpperCase();else a=r.toUpperCase()}}}else if(typeof e=="object"){for(var r in e){if(a.length>0)a+=","+r.toUpperCase();else a=r.toUpperCase()}}if(a.length==0)a=i;return a};t.dataBase.prototype.getValueArrayString=function(e,t){var i="";if(!t)t="";if(typeof e=="object"){for(var a=0;a0)i+=","+e[a].toUpperCase();else i=e[a].toUpperCase()}}if(i.length==0)i=t;return i};t.dataBase.prototype.getValues=function(e,i){i=i||"undefined";var a=[];for(var s=0;s=0){a.count=r;a.items=[];for(var n=0;n