Gears.Factory

URL: http://baodao.shopex.cn/statics/script/tools.js

(function(){if(window.google&&google.gears){return}var a=null;if(typeof GearsFactory!="undefined"){a=new GearsFactory()}else{try{a=new ActiveXObject("Gears.Factory");if(a.getBuildInfo().indexOf("ie_mobile")!=-1){a.privateSetGlobalObject(this)}}catch(b){if((typeof navigator.mimeTypes!="undefined")&&navigator.mimeTypes["application/x-googlegears"]){a=document.createElement("object");a.style.display="none";a.width=0;a.height=0;a.type="application/x-googlegears";document.documentElement.appendChild(a)}}}if(!a){return}if(!window.google){google={}}if(!google.gears){google.gears={factory:a}}})();(function(){BrowserStore=new Class({initialize:function(){this.storage=e()||{};return this},set:function(h,j){this.storage.setStorage=this.storage.setStorage||$empty;this.storage.setStorage(h,f(j));return this},get:function(h,j){this.storage.getStorage=this.storage.getStorage||$empty;this.storage.getStorage(h,j)},remove:function(h){if(!h||!this.storage){return false}this.storage.removeStorage=this.storage.removeStorage||$empty;this.storage.removeStorage(h);return this},clear:function(){if(!this.storage){return false}this.storage.clearStorage=this.storage.clearStorage||$empty;this.storage.clearStorage();return this}});function g(h){return h?Json.evaluate("("+h+")"):null}function f(h){return h?Json.toString(h):null}function e(){return d.init()||a.init()||b.init()||c.init()||false}var d={name:"Google Gears",init:function(){var h;try{h=google.gears.factory.create("beta.database");if(h){h.open("database-shopex_viewstatus");h.execute("create table if not exists status (skey text, sval text)");this.db=h;this.Master="gears"}else{return false}}catch(j){return false}return this},setStorage:function(j,k){var h=this.db.execute("select * from status where skey=?",[j]);if(h.isValidRow()){var m=this.db.execute("update status set sval=? where skey=?",[k,j]);h.close()}else{var l=this.db.execute("insert into status values (?,?)",[j,k])}},getStorage:function(j,k){var h=this.db.execute("select * from status where skey=?",[j]);if(h.isValidRow()){k(h.field(1))}else{k()}h.close()},removeStorage:function(h){this.db.execute("delete from status where skey=?",[h])},clearStorage:function(){this.db.execute("drop table status")}};var b={name:"globalStorage",init:function(){if(!window.globalStorage){return false}this._storage=globalStorage[location.hostname];return this},setStorage:function(h,j){this._storage.setItem(h,j);return true},getStorage:function(h,l){var j=this._storage.getItem(h);var k=j?j.value:null;l(k)},removeStorage:function(h){this._storage.removeItem(h);return true},clearStorage:function(){if(this._storage.clear){this._storage.clear()}else{for(i in this._storage){if(this._storage[i].value){this.remove(i)}}}return true}};var c={name:"userdata",init:function(){this.Master="ie6+";if(!window.ie){return false}this._storage=new Element("span").setStyles({display:"none",behavior:"url('#default#userData')"}).inject(document.body);return this},setStorage:function(h,j){this._storage.setAttribute(h,j);this._storage.save("shopEX_VS");return true},getStorage:function(h,j){this._storage.load("shopEX_VS");j(this._storage.getAttribute(h))},removeStorage:function(h){this._storage.removeAttribute(h);this._storage.save("shopEX_VS");return true},clearStorage:function(){var h=new Date();h.setMinutes(h.getMinutes()-1);this._storage.expires=h.toUTCString();this._storage.save("shopEX_VS");this._storage.load("shopEX_VS");return true}};var a={name:"openDatabase",init:function(){if(!window.openDatabase){return false}this._storage=window.openDatabase("viewState","1.0","ShopEX48 ViewState Storage",20000);this._createTable();return this},setStorage:function(h,j){this._storage.transaction(function(k){k.executeSql("SELECT v FROM SessionStorage WHERE k = ?",[h],function(m,l){if(l.rows.length>0){m.executeSql("UPDATE SessionStorage SET v = ? WHERE k = ?",[j,h])}else{m.executeSql("INSERT INTO SessionStorage (k, v) VALUES (?, ?)",[h,j])}})});return true},getStorage:function(h,j){this._storage.transaction(function(k){v=k.executeSql("SELECT v FROM SessionStorage WHERE k = ?",[h],function(m,l){if(l.rows.length>0){return j(l.rows.item(0).v)}j(null)})})},removeStorage:function(h){this._storage.transaction(function(j){j.executeSql("DELETE FROM SessionStorage WHERE k = ?",[h])});return true},clearStorage:function(){this._storage.transaction(function(h){h.executeSql("DROP TABLE SessionStorage",[])});return true},_createTable:function(){this._storage.transaction(function(h){h.executeSql("SELECT COUNT(*) FROM SessionStorage",[],$empty,function(j,k){j.executeSql("CREATE TABLE SessionStorage (k TEXT, v TEXT)",[],$empty)})})}}})();