diff --git a/store+json2.min.js b/store+json2.min.js new file mode 100644 index 00000000..f8349664 --- /dev/null +++ b/store+json2.min.js @@ -0,0 +1,11 @@ +/* Copyright (c) 2010-2011 Marcus Westin */ +var store=function(){var b={},g=window,m=g.document,f;b.disabled=false;b.set=function(){};b.get=function(){};b.remove=function(){};b.clear=function(){};b.transact=function(a,c){var d=b.get(a);if(typeof d=="undefined")d={};c(d);b.set(a,d)};b.serialize=function(a){return JSON.stringify(a)};b.deserialize=function(a){if(typeof a=="string")return JSON.parse(a)};var p;try{p="localStorage"in g&&g.localStorage}catch(i){p=false}if(p){f=g.localStorage;b.set=function(a,c){f.setItem(a,b.serialize(c))};b.get= +function(a){return b.deserialize(f.getItem(a))};b.remove=function(a){f.removeItem(a)};b.clear=function(){f.clear()}}else{var n;try{n="globalStorage"in g&&g.globalStorage&&g.globalStorage[g.location.hostname]}catch(r){n=false}if(n){f=g.globalStorage[g.location.hostname];b.set=function(a,c){f[a]=b.serialize(c)};b.get=function(a){return b.deserialize(f[a]&&f[a].value)};b.remove=function(a){delete f[a]};b.clear=function(){for(var a in f)delete f[a]}}else if(m.documentElement.addBehavior){f=m.createElement("div"); +g=function(a){return function(){var c=Array.prototype.slice.call(arguments,0);c.unshift(f);m.body.appendChild(f);f.addBehavior("#default#userData");f.load("localStorage");c=a.apply(b,c);m.body.removeChild(f);return c}};b.set=g(function(a,c,d){a.setAttribute(c,b.serialize(d));a.save("localStorage")});b.get=g(function(a,c){return b.deserialize(a.getAttribute(c))});b.remove=g(function(a,c){a.removeAttribute(c);a.save("localStorage")});b.clear=g(function(a){var c=a.XMLDocument.documentElement.attributes; +a.load("localStorage");for(var d=0,h;h=c[d];d++)a.removeAttribute(h.name);a.save("localStorage")})}}try{b.set("__storejs__","__storejs__");if(b.get("__storejs__")!="__storejs__")b.disabled=true;b.remove("__storejs__")}catch(o){b.disabled=true}return b}();if(!this.JSON)this.JSON={}; +(function(){function b(a){return a<10?"0"+a:a}function g(a){p.lastIndex=0;return p.test(a)?'"'+a.replace(p,function(c){var d=r[c];return typeof d==="string"?d:"\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function m(a,c){var d,h,k,q,l=i,j,e=c[a];if(e&&typeof e==="object"&&typeof e.toJSON==="function")e=e.toJSON(a);if(typeof o==="function")e=o.call(c,a,e);switch(typeof e){case "string":return g(e);case "number":return isFinite(e)?String(e):"null";case "boolean":case "null":return String(e); +case "object":if(!e)return"null";i+=n;j=[];if(Object.prototype.toString.apply(e)==="[object Array]"){q=e.length;for(d=0;d