All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.wings.js.yui.storage.storage-min.js Maven / Gradle / Ivy

The newest version!
/*
Copyright (c) 2011, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.com/yui/license.html
version: 2.9.0
*/
(function(){var g=YAHOO,f=g.util,e=g.lang,c,d,b=/^type=(\w+)/i,a=/&value=(.*)/i;if(!f.Storage){c=function(h){g.log("Exception in YAHOO.util.Storage.?? - must be extended by a storage engine".replace("??",h).replace("??",this.getName?this.getName():"Unknown"),"error");};d=function(h,k,j){var i=this;g.env._id_counter+=1;i._cfg=e.isObject(j)?j:{};i._location=h;i._name=k;i.isReady=false;i.createEvent(d.CE_READY,{scope:i,fireOnce:true});i.createEvent(d.CE_CHANGE,{scope:i});i.subscribe(d.CE_READY,function(){i.isReady=true;});};d.CE_READY="YUIStorageReady";d.CE_CHANGE="YUIStorageChange";d.prototype={CE_READY:d.CE_READY,CE_CHANGE:d.CE_CHANGE,_cfg:"",_name:"",_location:"",length:0,isReady:false,clear:function(){this._clear();this.length=0;},getItem:function(h){g.log("Fetching item at  "+h);var i=this._getItem(h);return e.isValue(i)?this._getValue(i):null;},getName:function(){return this._name;},hasKey:function(h){return e.isString(h)&&this._hasKey(h);},key:function(h){g.log("Fetching key at "+h);if(e.isNumber(h)&&-1h){var i=this._key(h);if(i){return i;}}throw ("INDEX_SIZE_ERR - Storage.setItem - The provided index ("+h+") is not available");},removeItem:function(j){g.log("removing "+j);var i=this,h;if(i.hasKey(j)){h=i._getItem(j);if(!h){h=null;}i._removeItem(j);i.fireEvent(d.CE_CHANGE,new f.StorageEvent(i,j,h,null,f.StorageEvent.TYPE_REMOVE_ITEM));}else{}},setItem:function(j,k){g.log("SETTING "+k+" to "+j);if(e.isString(j)){var i=this,h=i._getItem(j);if(!h){h=null;}if(i._setItem(j,i._createValue(k))){i.fireEvent(d.CE_CHANGE,new f.StorageEvent(i,j,h,k,i.hasKey(j)?f.StorageEvent.TYPE_UPDATE_ITEM:f.StorageEvent.TYPE_ADD_ITEM));}else{throw ("QUOTA_EXCEEDED_ERROR - Storage.setItem - The choosen storage method ("+i.getName()+") has exceeded capacity");}}else{}},_clear:function(){c("_clear");return"";},_createValue:function(h){var i=(e.isNull(h)||e.isUndefined(h))?(""+h):typeof h;return"type="+i+"&value="+encodeURIComponent(""+h);},_getItem:function(h){c("_getItem");return"";},_getValue:function(h){var j=h.match(b)[1],i=h.match(a)[1];switch(j){case"boolean":return"true"==i;case"number":return parseFloat(i);case"null":return null;default:return decodeURIComponent(i);}},_key:function(h){c("_key");return"";},_hasKey:function(h){return null!==this._getItem(h);},_removeItem:function(h){c("_removeItem");return"";},_setItem:function(h,i){c("_setItem");return"";}};e.augmentProto(d,f.EventProvider);f.Storage=d;}}());(function(){var h=YAHOO.util,e=YAHOO.lang,d={},g=[],f={},b=function(i){return(i&&i.isAvailable())?i:null;},a=function(i,l,k){var j=d[i+l.ENGINE_NAME];if(!j){j=new l(i,k);d[i+l.ENGINE_NAME]=j;}return j;},c=function(i){switch(i){case h.StorageManager.LOCATION_LOCAL:case h.StorageManager.LOCATION_SESSION:return i;default:return h.StorageManager.LOCATION_SESSION;}};h.StorageManager={LOCATION_SESSION:"sessionStorage",LOCATION_LOCAL:"localStorage",get:function(q,k,p){var n=e.isObject(p)?p:{},o=b(f[q]),m,l;if(!o&&!n.force){if(n.order){l=n.order.length;for(m=0;m\|;,]/g,"")+"-"+c.DATABASE);b.execute("CREATE TABLE IF NOT EXISTS "+g+" (key TEXT, location TEXT, value TEXT)");}k=h.StorageManager.LOCATION_SESSION===n._location;i=h.Cookie.get("sessionKey"+c.ENGINE_NAME);if(!i){b.execute("BEGIN");b.execute("DELETE FROM "+g+' WHERE location="'+f(h.StorageManager.LOCATION_SESSION)+'"');b.execute("COMMIT");}j=b.execute("SELECT key FROM "+g+' WHERE location="'+f(n._location)+'"');p={};try{while(j.isValidRow()){var m=a(j.field(0));if(!p[m]){p[m]=true;n._addKey(m);}j.next();}}finally{j.close();}if(k){h.Cookie.set("sessionKey"+c.ENGINE_NAME,true);}n.fireEvent(h.Storage.CE_READY);};d.extend(c,h.StorageEngineKeyed,{_clear:function(){c.superclass._clear.call(this);b.execute("BEGIN");b.execute("DELETE FROM "+g+' WHERE location="'+f(this._location)+'"');b.execute("COMMIT");},_getItem:function(k){var i=b.execute("SELECT value FROM "+g+' WHERE key="'+f(k)+'" AND location="'+f(this._location)+'"'),j="";try{while(i.isValidRow()){j+=i.field(0);i.next();}}finally{i.close();}return j?a(j):null;},_removeItem:function(i){c.superclass._removeItem.call(this,i);b.execute("BEGIN");b.execute("DELETE FROM "+g+' WHERE key="'+f(i)+'" AND location="'+f(this._location)+'"');b.execute("COMMIT");},_setItem:function(r,k){this._addKey(r);var l=f(r),m=f(this._location),p=f(k),q=[],s=e-(l+m).length,o=0,n;if(sf.getStyle(o,"width").replace(/\D+/g,"")){f.setStyle(o,"width",c+"px");}if(h>f.getStyle(o,"height").replace(/\D+/g,"")){f.setStyle(o,"height",h+"px");}b.log("attempting to show settings. are dimensions adequate? "+e.callSWF("hasAdequateDimensions"));return e.callSWF("displaySettings",[]);}}});l.SWFURL="swfstore.swf";l.ENGINE_NAME="swf";l.isAvailable=function(){return(6<=b.env.ua.flash&&b.widget.SWF);};j.register(l);i.StorageEngineSWF=l;}());YAHOO.register("storage",YAHOO.util.Storage,{version:"2.9.0",build:"2800"});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy