-
Notifications
You must be signed in to change notification settings - Fork 1
/
storage.min.js
18 lines (18 loc) · 2.79 KB
/
storage.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
* localStorage for Internet Explorer 6,7 - v0.2.0
*
* Copyright 2012, Dmitriy Pakhtinov ( spb.piksel@gmail.com )
*
* http://spb-piksel.ru/
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
* Update: 12-07-2012
*/
(function(e,l){var f=e.document,m=Object.prototype.toString;if(!e.localStorage)if("#localStorageDataStoredPage"==e.location.hash)f.write('<link id="StorageElement" style="behavior:url(#default#userData)" /><script type="text/javascript">var r=[],_S=document.getElementById("StorageElement");for(var k in window){if(k!="r"&&k!="_S"){r[r.length]=k;}}window.onerror=function(){return true;};window.onload=function(){_S.document.body.innerHTML="";}<\/script><script type="text/javascript">eval("var "+r.join("=null,")+"=null,prompt=null,alert=null,r=null;")<\/script><body><noscript><noscript><noscript><noscript><plaintext><![CDATA[');
else{var g=f.createElement("iframe");g.src="/"+location.pathname.split("/").pop()+"?"+Math.random()+"#localStorageDataStoredPage";g=f.documentElement.firstChild.appendChild(g).contentWindow;f.attachEvent("onreadystatechange",g.onload=function(){var b=g._S,d={},j;if(!e.localStorage&&b){b.load("localStorage");e.localStorage={length:0,setItem:function(a,c){try{a!==l&&b.setAttribute(a,null===c?"null":c.toString?c.toString():m.call(c)),b.save("localStorage"),b.load("localStorageURL"),b.setAttribute("docURL",
f.location.href),b.save("localStorageURL"),b.load("localStorage")}catch(d){if(-2147024857==d.b){throw{number:22,message:"Quota exceed error",description:"QUOTA_EXCEEDED_ERR"};throw d;}}this.length=b.XMLDocument.documentElement.attributes.length;j(!0)},getItem:function(a){b.load("localStorage");return b.getAttribute(a)},removeItem:function(a){b.removeAttribute(a);delete d[a];this.setItem()},key:function(a){try{return b.XMLDocument.documentElement.attributes[a].name}catch(c){return null}},clear:function(){for(var a=
b.XMLDocument.documentElement.attributes,c=a.length-1;0<=c;c--)delete d[a[c].name],b.removeAttribute(a[c].name);this.setItem()}};var k=setInterval((j=function(a){b.load("localStorage");var c,f,i=[],h=b.XMLDocument.documentElement,g=e.localStorage.length=h.attributes.length;if(!0!==a){for(a=0;a<g;a++){c=h.attributes[a].name;f=h.attributes[a].value;if(!(c in d)||d[c]!==f)i[i.length]={key:c,oldValue:c in d?d[c]:null,newValue:f,url:"",storageArea:e.localStorage};delete d[c]}for(a in d)d.hasOwnProperty(a)&&
(i[i.length]={key:a,oldValue:d[a],newValue:null,url:"",storageArea:e.localStorage},delete d[a])}for(a=0;a<g;a++)d[h.attributes[a].name]=h.attributes[a].value;if(e.a&&i.length){clearInterval(k);b.load("localStorageURL");h=b.getAttribute("docURL");for(b.load("localStorage");a=i.shift();)a.url=h,e.a.call(e,a);k=setInterval(j,300)}return j})(!0),300)}})}})(window);