crossbrowdy
Version:
A Multimedia JavaScript framework to create real cross-platform and hybrid game engines, games, emulators, multimedia libraries and apps.
2 lines • 8.24 kB
JavaScript
/* localStorage - Version 2.0.1 - 25-09-2014 */
!function(a,b,c,d,e,f,g){"use strict";function h(){}var i,j=f,k=b.domain,l=c.protocol||b.protocol,m=b.body||b.getElementsByTagName("body")[0],n=Object.prototype,o="name",p="object",q="local",r="host",s="domain",t="onunload",u="script",v="body",w="html",x="title",y="head",z="div",A="type",B="none",C="param",D="value",E="String",F="Function",G="Number",H="UserData",I="Flash",J="Cookie",K="Storage",L="QuotaExceeded",M=" is out of memory",N="localStorage",O="application/x-shockwave-flash",P="ShockwaveFlash.ShockwaveFlash",Q="Shockwave Flash",R=function(a){return a===e},S=function(){var a=f;return a=new Function("return/*@cc_on!@*/!1")()||bb(b.documentMode)&&b.documentMode<=10},T=function(a){var b=new RegExp("[!\"#$%&'()*+,/\\\\:;<=>?@[\\]^`{|}~]","g");return a.replace(/^d/,"___$&").replace(b,"___")},U=function(a,b){for(var c=a.length;c;)c-=1,R(a.key)?b.call(this,a[c],c):b.call(this,a.key(c),c)},V=function(a,b){var c=null;for(c in a)a.hasOwnProperty(c)&&b.call(this,a[c],c)},W=function(a,c,d){var e;a.setAttribute?a.setAttribute(c,d):a.attributes?a.attributes[c]=d:a.createAttribute?(e=b.createAttribute(c),e.value=d,a.setAttributeNode(e)):a[c]=d},X=function(a){return b.createElement(a)},Y=function(a){return parseInt(a,10)},Z=function(){var a,b;try{return a=new ActiveXObject(P),a&&(b=a.GetVariable("$version"),b&&Y(b.split(" ")[1].split(",")[0])>=9)?g:f}catch(c){return $(d.plugins[Q])&&!R(d.mimeTypes)&&!R(d.mimeTypes[O])&&(b=d.plugins[Q].description,d.mimeTypes[O].enabledPlugin&&!R(b)&&(b=b.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),Y(b.replace(/^(.*)\..*$/,"$1"))>=9))?g:f}},$=function(a){return a===Object(a)},_=function(a){return typeof a===E.toLowerCase()||n.toString.call(a)==="["+p+" "+E+"]"},ab=function(a){return typeof a===F.toLowerCase()||n.toString.call(a)==="["+p+" "+F+"]"},bb=function(a){return typeof a===G.toLowerCase()||n.toString.call(a)==="["+p+" "+G+"]"},cb=function(a,b){a.insertBefore(b,a.lastChild?a.lastChild.nextSibling:a.lastChild)},db=function(){var a=b.scripts||b.getElementsByTagName("script"),c=a[a.length-1].src.split("?"),d=null;return c[1]&&U(c[1].split("&"),function(a){var b=a.split("=");return"swfURL"===b[0]?d=decodeURIComponent(b[1].replace(/\+/g," ")):void 0}),d}();h.extend=function(a){function b(){var a=this;return a instanceof b?void(arguments[0]!==h&&a.init&&a.init.apply(a,arguments)):new b(arguments[0])}var c=this,d=c.prototype,e=new c(h),f=function(){return function(a,b){return function(){var c,e=this.$super;return this.$super=d[a],c=b.apply(this,arguments),this.$super=e,c}}(arguments[0],arguments[1])};return V(a,function(a,b){e[b]=ab(a)&&ab(d[b])?f.call(c,b,a):a}),b.prototype=e,b.prototype.constructor=b,b.extend=c.extend,b};var eb=h.extend({init:function(){var b=this;b.__storage__=c.hostname===q+r?a.globalStorage[q+r+"."+q+s]:a.globalStorage[c.hostname],b.length=b.__storage__.length},key:function(a){var b=this;return a+1>b.length||0>a?null:b.__storage__.key(a)},getItem:function(a){var b=this,c=b.__storage__.getItem(a);return $(c)?c.value:c},setItem:function(a,b){var c=this;c.__storage__.setItem(a,b),c.length=c.__storage__.length},removeItem:function(a){var b=this;b.__storage__.removeItem(a),b.length=b.__storage__.length},clear:function(){var a=this;U(a.__storage__,function(b){a.removeItem(b)})},isLoaded:function(){return g}});eb.prototype.constructor=eb,a.GlobalStorage=eb;var fb=h.extend({init:function(){var b,c,d=this,e=function(){a.detachEvent(t,e),b=c=d.__storage__=null,ab(CollectGarbage)&&CollectGarbage()};try{b=new ActiveXObject("htmlfile"),b.open(),b.write("<"+w+"><"+y+"><"+x+">"+N+"</"+x+"><"+u+" "+A+'="text/javascript">document.'+s+" = '"+l+"//"+k+"';</"+u+"></"+y+"><"+v+"></"+v+"></"+w+">"),b.close(),c=b.body,d.__storage__=b.createElement(z),a.attachEvent(t,e)}catch(f){c=m,d.__storage__=X(z)}cb(c,d.__storage__),d.__storage__.style.display=B,d.__storage__.addBehavior("#default#userData"),d.__storage__.load(N+"_"+k),d.__attributes__=d.__storage__.XMLDocument.documentElement.attributes,d.length=d.__attributes__.length},key:function(a){var b=this,c=null;try{c=a>=b.length?null:b.__attributes__[a].name}catch(d){}return c},getItem:function(a){var b=this;return b.__storage__.getAttribute(T(a))},setItem:function(a,b){var c=this;try{c.__storage__.setAttribute(T(a),b),c.__storage__.save(N+"_"+k),c.length=c.__attributes__.length}catch(d){throw{name:H+L,message:H+K+M}}},removeItem:function(a){var b=this;b.__storage__.removeAttribute(T(a)),b.__storage__.save(N+"_"+k),b.length=b.__attributes__.length},clear:function(){var a=this;U(a.__attributes__,function(b){a.removeItem(b.name)})},isLoaded:function(){return g}});fb.prototype.constructor=fb,a.UserDataStorage=fb;var gb=h.extend({init:function(c){var d,e=this,f=db||N+".swf",h=2e3,i="",k={id:N,name:N,width:1,height:1},l={allowScriptAccess:"always",wmode:"transparent",flashvars:"readyFn=window._swfReady"},q=function(a,b,c){var d=null,f=null,g=function(){clearInterval(d),clearTimeout(f),f=d=null};d=setInterval(function(){(n.hasOwnProperty.call(a,"PercentLoaded")&&100===a.PercentLoaded()||j)&&(g.call(e),b.call(e))},10),f=setTimeout(function(){g.call(e),ab(c)&&c.call(e)},h)},r=function(){var b=null;a.detachEvent(t,r),d.style.display=B,b=setInterval(function(){4===d.readyState&&(clearInterval(b),U(d,function(a){ab(a)&&(a=null)}),d.parentNode.removeChild(d))},10)};a._swfReady=function(a){j=a};try{k.classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000",l.movie=f,V(k,function(a,b){i+=b+'="'+a+'" '}),d=X("<"+p+" "+i+">"),V(l,function(a,b){var c=X("<"+C+" "+o+"='"+b+"' "+D+"='"+a+"'>");cb(d,c)}),a.attachEvent(t,r)}catch(s){S()||(delete k.classid,delete l.movie),d=X(p),V(l,function(a,b){var c=X(C);W(c,o,b),W(c,D,a),cb(d,c)}),S()||(W(d,A,O),W(d,"data",f)),V(k,function(a,b){W(d,b,a)})}cb(m,d),q.call(e,d,function(){e.__storage__=b[N]||b.getElementById(N)||b.embeds[N],e.length=e.__storage__.length(),e.key=function(a){return e.__storage__.key(a)},e.getItem=function(a){return e.__storage__.getItem(a)},e.setItem=function(a,b){if(!e.__storage__.setItem(a,b))throw{name:I+L,message:I+K+M};e.length=e.__storage__.length()},e.removeItem=function(a){e.__storage__.removeItem(a),e.length=e.__storage__.length()},e.clear=function(){e.__storage__.clear(),e.length=e.__storage__.length()},e.isLoaded=function(){return g}},c)},isLoaded:function(){return f}});gb.prototype.constructor=gb,a.FlashStorage=gb;var hb=h.extend({length:function(){var a=b.cookie.match(/\=/g);return a&&a.length||0}(),key:function(c){var d=a.unescape(b.cookie.replace(/\s*\=(?:.(?!;))*$/,"").split(/\s*\=(?:[^;](?!;))*[^;]?;\s*/).sort()[c]);return""===d?null:d},getItem:function(c){var d=-1===b.cookie.indexOf(c+"=")?"":a.unescape(b.cookie.replace(new RegExp("(?:^|.*;\\s*)"+a.escape(c).replace(/[\-\.\+\*]/g,"\\$&")+"\\s*\\=\\s*((?:[^;](?!;))*[^;]?).*"),"$1"));return""===d?null:d},setItem:function(c,d){var e=this,f=0,g=a.escape(c)+"="+a.escape(d)+"; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/";if(g.length>4093)throw{name:J+L,message:J+K+M};b.cookie=g,f=b.cookie.match(/\=/g),e.length=f&&f.length||0},removeItem:function(c){var d=this,e=0;b.cookie=a.escape(c)+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/",e=b.cookie.match(/\=/g),d.length=e&&e.length||0},clear:function(){var a=this;U(a,function(b){a.removeItem(b)})},isLoaded:function(){return g}});hb.prototype.constructor=hb,a.CookieStorage=hb;try{a.localStorage.setItem(N,N),a.localStorage.removeItem(N)}catch(ib){a.globalStorage?i=eb:b.documentElement&&b.documentElement.addBehavior?i=fb:Z()?i=gb:d.cookieEnabled&&(i=hb);var jb=i.extend({key:function(a){var b=this;return bb(a)&&a<b.length&&a>=0?b.$super(a):null},getItem:function(a){var b=this;return _(a)?b.$super(a):null},setItem:function(a,b){var c=this,d=_(b)?b:null!==b&&!R(b)&&n.hasOwnProperty.call(b,"toString")?b.toString():n.toString.call(b);_(a)&&c.$super(a,d)},removeItem:function(a){var b=this;_(a)&&b.$super(a)},isLoaded:function(a){var b=this,c=null;if(ab(a))return b.$super()?a.call(b):void(c=setInterval(function(){b.$super()&&(clearInterval(c),c=null,a.call(b))},10))}});jb.prototype.constructor=jb,a.Storage=jb,a.localStorage=new jb(function(){a.localStorage=new hb})}}(window,window.document,window.location,window.navigator,void 0,!1,!0);