minicart.js 21 KB

1234567891011
  1. /*!
  2. * MiniCart
  3. *
  4. * Improve your PayPal integration by creating an overlay which appears as a user adds products to their cart.
  5. *
  6. * @version 2.5.0 - 2012-12-08, 2:59:35 PM
  7. * @author Jeff Harrell <https://github.com/jeffharrell/>
  8. * @url http://www.minicartjs.com/
  9. * @license <eBay Open Source License Agreement <https://github.com/jeffharrell/MiniCart/blob/master/LICENSE>>
  10. */
  11. if(typeof PAYPAL=="undefined"||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";var e={parent:document.body,displayEdge:"right",edgeDistance:"50px",formTarget:null,cookiePath:"/",cartDuration:30,strings:{button:"",subtotal:"",discount:"",shipping:"",processing:""},name:"PPMiniCart",peekEnabled:!0,paypalURL:"https://www.paypal.com/cgi-bin/webscr",assetURL:"http://www.minicartjs.com/build/",events:{onRender:null,afterRender:null,onHide:null,afterHide:null,onShow:null,afterShow:null,onAddToCart:null,afterAddToCart:null,onRemoveFromCart:null,afterRemoveFromCart:null,onCheckout:null,onReset:null,afterReset:null}};PAYPAL.apps.MiniCart=function(){var r={},i=!1,s=!1,o={_cart:!0,_xclick:!0},u="MiniCart_AddToCart_WPS_US",a=/^(?:business|currency_code|lc|paymentaction|no_shipping|cn|no_note|invoice|handling_cart|weight_cart|weight_unit|tax_cart|page_style|image_url|cpp_|cs|cbt|return|cancel_return|notify_url|rm|custom|charset)/,f=function(){var t=e.name,n=[],r,i;n.push("#"+t+" form { position:absolute; float:none; left: 50px; top:-250px; "+e.displayEdge+":"+e.edgeDistance+"; width:265px; margin:0; padding:10px 10px 0; min-height:170px; background:#fff; border:1px solid #999; border-top:0; font:13px/normal arial, helvetica; color:#333; text-align:left; -moz-border-radius:0 0 8px 8px; -webkit-border-radius:0 0 8px 8px; border-radius:0 0 8px 8px; -moz-box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1); -webkit-box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1); box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1); } "),n.push("#"+t+" ul { position:relative; overflow-x:hidden; overflow-y:auto; height:130px; margin:0 0 7px; padding:0; list-style-type:none; border-top:1px solid #ccc; border-bottom:1px solid #ccc; } "),n.push("#"+t+" li { position:relative; margin:-1px 0 0; padding:6px 5px 6px 0; border-top:1px solid #f2f2f2; } "),n.push("#"+t+" li a { display: block; width: 155px; color:#333; text-decoration:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } "),n.push("#"+t+" li a span { color:#999; font-size:10px; } "),n.push("#"+t+" li .quantity { position:absolute; top:.5em; right:78px; width:22px; padding:1px; border:1px solid #83a8cc; text-align:right; } "),n.push("#"+t+" li .price { position:absolute; top:.5em; right:4px; } "),n.push("#"+t+" li .remove { position:absolute; top:9px; right:60px; width:14px; height:14px; border:0; cursor:pointer; } "),n.push("#"+t+" p { margin:0; padding:0 0 0 20px; font-size:13px; font-weight:bold; } "),n.push("#"+t+" p:hover { cursor:pointer; } "),n.push("#"+t+" p input { float:right; margin:4px 0 0; padding:1px 4px; text-decoration:none; font-weight:normal; color:#333; border:1px solid #d5bd98; border-right-color:#935e0d; border-bottom-color:#935e0d; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; } "),n.push("#"+t+" p .shipping { display:block; font-size:10px; font-weight:normal; color:#999; } "),r=document.createElement("style"),r.type="text/css",r.styleSheet?r.styleSheet.cssText=n.join(""):r.appendChild(document.createTextNode(n.join(""))),i=document.getElementsByTagName("head")[0],i.appendChild(r)},l=function(){var t=r.UI,n,i,s,o,a;t.wrapper=document.createElement("div"),t.wrapper.id=e.name,n=document.createElement("input"),n.type="hidden",n.name="cmd",n.value="_cart",i=n.cloneNode(!1),i.name="upload",i.value="1",s=n.cloneNode(!1),s.name="bn",s.value=u,t.cart=document.createElement("form"),t.cart.method="post",t.cart.action=e.paypalURL,e.formTarget&&(t.cart.target=e.formTarget),t.cart.appendChild(n),t.cart.appendChild(i),t.cart.appendChild(s),t.wrapper.appendChild(t.cart),t.itemList=document.createElement("ul"),t.cart.appendChild(t.itemList),t.summary=document.createElement("p"),t.cart.appendChild(t.summary),t.button=document.createElement("input"),t.button.type="submit",t.button.value=e.strings.button||"Checkout",t.summary.appendChild(t.button),t.subtotal=document.createElement("span"),t.subtotal.innerHTML=e.strings.subtotal||"Subtotal: ",t.subtotalAmount=document.createElement("span"),t.subtotalAmount.innerHTML="0.00",t.subtotal.appendChild(t.subtotalAmount),t.summary.appendChild(t.subtotal),t.shipping=document.createElement("span"),t.shipping.className="shipping",t.shipping.innerHTML=e.strings.shipping||"does not include shipping &amp; tax",t.summary.appendChild(t.shipping);if(window.attachEvent&&!window.opera){a=navigator.userAgent.match(/MSIE\s([^;]*)/);if(a){a=parseFloat(a[1]);if(a<7||a>=7&&document.compatMode==="BackCompat")t.cart.style.position="absolute",t.wrapper.style[e.displayEdge]="0",t.wrapper.style.setExpression("top","x = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop")}}o=typeof e.parent=="string"?document.getElementById(e.parent):e.parent,o.appendChild(t.wrapper)},c=function(){var t=r.UI,s,u,a;s=document.getElementsByTagName("form");for(a=0;a<s.length;a++)u=s[a],u.cmd&&o[u.cmd.value]&&r.bindForm(u);n.event.add(document,"click",function(e){if(i){var n=e.target,s=t.cart;if(!/input|button|select|option/i.test(n.tagName)){while(n.nodeType===1){if(n===s)return;n=n.parentNode}r.hide(null)}}}),n.event.add(t.cart,"submit",function(e){b(e)}),n.event.add(t.summary,"click",function(e){var n=e.target;n!==t.button&&r.toggle(e)}),window.attachEvent&&!window.opera?n.event.add(document,"storage",function(e){setTimeout(m,100)}):n.event.add(window,"storage",function(t){(t.key&&t.key===e.name||!t.key)&&m()})},h=function(t){var n;for(n in t)typeof e[n]!==undefined&&(e[n]=t[n])},p=function(){var e,t,r;if(e=n.storage.load()){t=e.length;for(r=0;r<t;r++)g(e[r])&&(i=!0)}},d=function(e){var t=e.elements,r={},i,s,o,u;for(o=0,u=t.length;o<u;o++){i=t[o];if(s=n.util.getInputValue(i))r[i.name]=s}return r},v=function(t){var n={},i={},s,o,u,f,l,c,h;for(u in t)a.test(u)?i[u]=t[u]:n[u]=t[u];for(c=0,f=r.products.length;c<f;c++){s=r.products[c].product;if(n.item_name===s.item_name&&n.item_number===s.item_number){l=!0,h=0;while(s["os"+h]){if(n["os"+h]!==s["os"+h]){l=!1;break}h++}if(l){n.offset=s.offset;break}}}n.href=n.href||window.location.href,n.quantity=n.quantity||1,n.amount=n.amount||0,i["return"]&&i["return"].indexOf("#")===-1&&(i["return"]+="#"+e.name+"=reset"),o=n.option_index?n.option_index:0;while(n["os"+o]){c=0;while(typeof n["option_select"+c]!="undefined"){if(n["option_select"+c]===n["os"+o]){n.amount=n.amount+parseFloat(n["option_amount"+c]);break}c++}o++}return{product:n,settings:i}},m=function(e){r.products=[],r.UI.itemList.innerHTML="",r.UI.subtotalAmount.innerHTML="",p(),r.updateSubtotal(e)},g=function(e){var i=r.UI,s=i.cart,o=new t(e,r.UI.itemList.children.length+1),u=e.product.offset,a,f,l;r.products[u]=o;for(l in e.settings)s.elements[l]?s.elements[l].value?s.elements[l].value=e.settings[l]:s.elements[l]=e.settings[l]:(f=document.createElement("input"),f.type="hidden",f.name=l,f.value=e.settings[l],s.appendChild(f));if(o.isPlaceholder)return!1;n.event.add(o.removeInput,"click",function(){y(o,u)});var c=o.quantityInput.value;return n.event.add(o.quantityInput,"keyup",function(){var e=this;a=setTimeout(function(){var t=parseInt(e.value,10);!isNaN(t)&&t!==c&&(c=t,o.setQuantity(t),o.getQuantity()||y(o,u),r.updateSubtotal(),n.storage.save(r.products))},250)}),i.itemList.insertBefore(o.liNode,i.itemList.firstChild),n.util.animate(o.liNode,"opacity",{from:0,to:1}),!0},y=function(t,i){var s=e.events,o=s.onRemoveFromCart,u=s.afterRemoveFromCart;if(typeof o=="function"&&o.call(r,t)===!1)return;t.setQuantity(0),t.quantityInput.style.display="none",n.util.animate(t.liNode,"opacity",{from:1,to:0},function(){n.util.animate(t.liNode,"height",{from:18,to:0},function(){try{t.liNode.parentNode.removeChild(t.liNode)}catch(e){}var n=r.UI.cart.getElementsByTagName("li"),i=n.length,s,o,a,f,l,c,h=1;for(l=0;l<i;l++){s=n[l].getElementsByTagName("input"),o=s.length;for(c=0;c<o;c++)a=s[c],f=/(.+)_[0-9]+$/.exec(a.name),f&&f[1]&&(a.name=f[1]+"_"+h);h++}typeof u=="function"&&u.call(r,t)})}),r.products[i].product.item_name="",r.products[i].product.item_number="",r.updateSubtotal(),n.storage.save(r.products,e.cartDuration)},b=function(t){var n=e.events.onCheckout;if(typeof n=="function"&&n.call(r,t)===!1){t.preventDefault();return}r.UI.button.value=e.strings.processing||"Processing..."};return r.products=[],r.UI={},r.render=function(t){var o,u,a,p,d;h(t),o=e.events,u=o.onRender,a=o.afterRender;if(typeof u=="function"&&u.call(r)===!1)return;s||(f(),l(),c(),p=location.hash.substring(1),p.indexOf(e.name+"=")===0&&(d=p.split("=")[1],d==="reset"&&(r.reset(),location.hash=""))),m(!0),s||(i?setTimeout(function(){r.hide(null)},500):n.storage.remove()),s=!0,typeof a=="function"&&a.call(r)},r.bindForm=function(e){if(e.add)n.event.add(e,"submit",function(e){e.preventDefault(e);var t=d(e.target);r.addToCart(t)});else{if(!e.display)return!1;n.event.add(e,"submit",function(e){e.preventDefault(),r.show(e)})}return!0},r.addToCart=function(t){var i=e.events,s=i.onAddToCart,o=i.afterAddToCart,u=!1,a,f;t=v(t),f=t.product.offset;if(typeof s=="function"&&s.call(r,t.product)===!1)return;return(a=this.getProductAtOffset(f))?(a.product.quantity+=parseInt(t.product.quantity||1,10),a.setPrice(t.product.amount*a.product.quantity),a.setQuantity(a.product.quantity),u=!0):(t.product.offset=r.products.length,u=g(t)),r.updateSubtotal(),r.show(null),n.storage.save(r.products,e.cartDuration),typeof o=="function"&&o.call(r,t),u},r.getProductAtOffset=function(e){return typeof e!="undefined"&&this.products[e]},r.calculateSubtotal=function(){var e=0,t=r.products,n,i,s,o,u,a;for(a=0,u=t.length;a<u;a++)i=t[a],(n=i.product)&&n.quantity&&n.amount&&(s=n.amount,o=i.getDiscount(),e+=parseFloat(s*n.quantity-o));return e.toFixed(2)},r.updateSubtotal=function(e){var t=r.UI,i=t.cart.elements,s=t.subtotalAmount,o=r.calculateSubtotal(),u=1,a,f,l,c,h;a="",f="";if(i.currency_code)a=i.currency_code.value||i.currency_code;else for(h=0,c=i.length;h<c;h++)if(i[h].name==="currency_code"){a=i[h].value||i[h];break}s.innerHTML=n.util.formatCurrency(o,a),e||function p(){l=u.toString(16),u++,s.style.backgroundColor="#ff"+l;if(u>=15){s.style.backgroundColor="transparent",o==="0.00"&&r.reset();return}setTimeout(p,30)}()},r.show=function(t){var s=parseInt(r.UI.cart.offsetTop,10),o=0,u=e.events,a=u.onShow,f=u.afterShow;t&&t.preventDefault&&t.preventDefault();if(typeof a=="function"&&a.call(r,t)===!1)return;n.util.animate(r.UI.cart,"top",{from:s,to:o},function(){typeof f=="function"&&f.call(r,t)}),r.UI.summary.style.backgroundPosition="-195px 2px",i=!0},r.hide=function(t,s){var o=r.UI,u=o.cart,a=o.summary,f=u.offsetHeight?u.offsetHeight:document.defaultView.getComputedStyle(u,"").getPropertyValue("height"),l=a.offsetHeight?a.offsetHeight:document.defaultView.getComputedStyle(a,"").getPropertyValue("height"),c=parseInt(u.offsetTop,10),h=e.events,p=h.onHide,d=h.afterHide,v;s||r.products.length===0||!e.peekEnabled?v=f*-1:v=(f-l-8)*-1,t&&t.preventDefault&&t.preventDefault();if(typeof p=="function"&&p.call(r,t)===!1)return;n.util.animate(u,"top",{from:c,to:v},function(){typeof d=="function"&&d.call(r,t)}),a.style.backgroundPosition="-195px -32px",i=!1},r.toggle=function(e){i?r.hide(e):r.show(e)},r.reset=function(){var t=r.UI,s=e.events,o=s.onReset,u=s.afterReset;if(typeof o=="function"&&o.call(r)===!1)return;r.products=[],i&&(t.itemList.innerHTML="",t.subtotalAmount.innerHTML="",r.hide(null,!0)),n.storage.remove(),typeof u=="function"&&u.call(r)},r}();var t=function(e,t){this._view(e,t)};t.prototype={_view:function(e,t){var n,r,i,s,o,u,a;this.product=e.product,this.settings=e.settings,this.liNode=document.createElement("li"),this.nameNode=document.createElement("a"),this.metaNode=document.createElement("span"),this.discountNode=document.createElement("span"),this.discountInput=document.createElement("input"),this.priceNode=document.createElement("span"),this.quantityInput=document.createElement("input"),this.removeInput=document.createElement("input");if(!this.product||!this.product.item_name&&!this.product.item_number){this.isPlaceholder=!0;return}this.product.item_name&&(n=this.product.item_name),this.nameNode.innerHTML=n,this.nameNode.title=n,this.nameNode.href=this.product.href,this.nameNode.appendChild(this.metaNode),this.product.item_number&&(this.metaNode.innerHTML="<br />#"+this.product.item_number),o=this.getOptions();for(a in o)this.metaNode.innerHTML+="<br />"+a+": "+o[a];s=this.getDiscount(),this.discountInput.type="hidden",this.discountInput.name="discount_amount_"+t,this.discountInput.value=s,this.metaNode.appendChild(this.discountNode),r=this.getPrice(),this.priceNode.className="price",i=this.getQuantity(),this.quantityInput.name="quantity_"+t,this.quantityInput.className="quantity",this.quantityInput.setAttribute("autocomplete","off"),this.setQuantity(i),this.removeInput.type="button",this.removeInput.className="remove",this.liNode.appendChild(this.nameNode),this.liNode.appendChild(this.quantityInput),this.liNode.appendChild(this.discountInput),this.liNode.appendChild(this.removeInput),this.liNode.appendChild(this.priceNode);for(a in this.product)a!=="quantity"&&a.indexOf("discount_")===-1&&(u=document.createElement("input"),u.type="hidden",u.name=a+"_"+t,u.value=this.product[a],this.liNode.appendChild(u))},getDiscount:function(){var e=0,t=this.product.discount_num||-1,n;return this.product.discount_amount?(e=parseFloat(this.product.discount_amount),this.product.discount_amount2&&(n=this.getQuantity(),n>1&&(e+=Math.max(n-1,t)*parseFloat(this.product.discount_amount2)))):this.product.discount_rate&&(e=this.product.amount*parseFloat(this.product.discount_rate)/100,this.product.discount_rate2&&(n=this.getQuantity(),n>1&&(e+=Math.max(n-1,t)*this.product.amount*parseFloat(this.product.discount_amount2)/100))),e&&e.toFixed(2)},getOptions:function(){var e={},t=0;while(typeof this.product["on"+t]!="undefined")e[this.product["on"+t]]=this.product["os"+t],t++;return e},setQuantity:function(t){var r;t=parseInt(t,10),this.product.quantity=t;if(this.quantityInput.value!==t){this.quantityInput.value=t;if(r=this.getDiscount())this.discountInput.value=r,this.discountNode.innerHTML="<br />",this.discountNode.innerHTML+=e.strings.discount||"Discount: ",this.discountNode.innerHTML+=n.util.formatCurrency(r,this.settings.currency_code)}this.setPrice(this.product.amount*t)},getQuantity:function(){return typeof this.product.quantity!==undefined?this.product.quantity:1},setPrice:function(e){e=parseFloat(e,10),this.priceNode.innerHTML=n.util.formatCurrency(e.toFixed(2),this.settings.currency_code)},getPrice:function(){return(this.product.amount*this.getQuantity()).toFixed(2)}};var n={};n.storage=function(){var t=e.name;return window.localStorage?{load:function(){var e=localStorage.getItem(t),r,i;e&&(e=JSON.parse(decodeURIComponent(e)));if(e&&e.expires){r=new Date,i=new Date(e.expires);if(r>i){n.storage.remove();return}}return e&&e.value?e.value:e},save:function(e,n){var r=new Date,i=[],s,o,u,a;if(e){for(a=0,u=e.length;a<u;a++)o=e[a],i.push({product:o.product,settings:o.settings});r.setTime(r.getTime()+n*24*60*60*1e3),s={value:i,expires:r.toGMTString()},localStorage.setItem(t,encodeURIComponent(JSON.stringify(s)))}},remove:function(){localStorage.removeItem(t)}}:{load:function(){var e=t+"=",n,r,i,s,o;try{r=document.cookie.split(";");for(o=0;o<r.length;o++){i=r[o];while(i.charAt(0)===" ")i=i.substring(1,i.length);i.indexOf(e)===0&&(s=i.substring(e.length,i.length),n=JSON.parse(decodeURIComponent(s)))}}catch(u){}return n},save:function(t,n){var r=new Date,i=[],s,o,u;if(t){for(u=0,o=t.length;u<o;u++)s=t[u],i.push({product:s.product,settings:s.settings});r.setTime(r.getTime()+n*24*60*60*1e3),document.cookie=e.name+"="+encodeURIComponent(JSON.stringify(i))+"; expires="+r.toGMTString()+"; path="+e.cookiePath}},remove:function(){this.save(null,-1)}}}(),n.event=function(){var e=[];if(document.addEventListener)return{add:function(t,n,r,i){i=i||t;var s=function(e){r.call(i,e)};t.addEventListener(n,s,!1),e.push([t,n,r,s])},remove:function(t,n,r){var i,s,o=e.length,u;for(u=0;u<o;u++)s=e[u],s[0]===t&&s[1]===n&&s[2]===r&&(i=s[3],i&&(t.removeEventListener(n,i,!1),delete e[u]))}};if(document.attachEvent)return{add:function(t,n,r,i){i=i||t;var s=function(){var e=window.event;e.target=e.target||e.srcElement,e.preventDefault=function(){e.returnValue=!1},r.call(i,e)};t.attachEvent("on"+n,s),e.push([t,n,r,s])},remove:function(t,n,r){var i,s,o=e.length,u;for(u=0;u<o;u++)s=e[u],s[0]===t&&s[1]===n&&s[2]===r&&(i=s[3],i&&(t.detachEvent("on"+n,i),delete e[u]))}}}(),n.util={animate:function(e,t,n,r){n=n||{},n.from=n.from||0,n.to=n.to||0,n.duration=n.duration||10,n.unit=/top|bottom|left|right|width|height/.test(t)?"px":"";var i=(n.to-n.from)/20,s=n.from;(function o(){e.style[t]=s+n.unit,s+=i;if(i>0&&s>n.to||i<0&&s<n.to||i===0){e.style[t]=n.to+n.unit,typeof r=="function"&&r();return}setTimeout(o,n.duration)})()},getInputValue:function(e){var t=e.tagName.toLowerCase();return t==="select"?e.options[e.selectedIndex].value:t==="textarea"?e.innerHTML:e.type==="radio"?e.checked?e.value:null:e.type==="checkbox"?e.checked?e.value:null:e.value},formatCurrency:function(e,t){var n={AED:{before:"ج"},ANG:{before:"ƒ"},ARS:{before:"$"},AUD:{before:"$"},AWG:{before:"ƒ"},BBD:{before:"$"},BGN:{before:"лв"},BMD:{before:"$"},BND:{before:"$"},BRL:{before:"R$"},BSD:{before:"$"},CAD:{before:"$"},CHF:{before:""},CLP:{before:"$"},CNY:{before:"¥"},COP:{before:"$"},CRC:{before:"₡"},CZK:{before:"Kc"},DKK:{before:"kr"},DOP:{before:"$"},EEK:{before:"kr"},EUR:{before:"€"},GBP:{before:"£"},GTQ:{before:"Q"},HKD:{before:"$"},HRK:{before:"kn"},HUF:{before:"Ft"},IDR:{before:"Rp"},ILS:{before:"₪"},INR:{before:"Rs."},ISK:{before:"kr"},JMD:{before:"J$"},JPY:{before:"¥"},KRW:{before:"₩"},KYD:{before:"$"},LTL:{before:"Lt"},LVL:{before:"Ls"},MXN:{before:"$"},MYR:{before:"RM"},NOK:{before:"kr"},NZD:{before:"$"},PEN:{before:"S/"},PHP:{before:"Php"},PLN:{before:"z"},QAR:{before:"﷼"},RON:{before:"lei"},RUB:{before:"руб"},SAR:{before:"﷼"},SEK:{before:"kr"},SGD:{before:"$"},THB:{before:"฿"},TRY:{before:"TL"},TTD:{before:"TT$"},TWD:{before:"NT$"},UAH:{before:"₴"},USD:{before:"$"},UYU:{before:"$U"},VEF:{before:"Bs"},VND:{before:"₫"},XCD:{before:"$"},ZAR:{before:"R"}},r=n[t]||{},i=r.before||"",s=r.after||"";return i+e+s}}}(),typeof JSON!="object"&&(JSON={}),function(){"use strict";function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a=="object"&&typeof a.toJSON=="function"&&(a=a.toJSON(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||"null";return i=u.length===0?"[]":gap?"[\n"+gap+u.join(",\n"+gap)+"\n"+o+"]":"["+u.join(",")+"]",gap=o,i}if(rep&&typeof rep=="object"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]=="string"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i));return i=u.length===0?"{}":gap?"{\n"+gap+u.join(",\n"+gap)+"\n"+o+"}":"{"+u.join(",")+"}",gap=o,i}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(e){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(e){return this.valueOf()});var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(e,t,n){var r;gap="",indent="";if(typeof n=="number")for(r=0;r<n;r+=1)indent+=" ";else typeof n=="string"&&(indent=n);rep=t;if(!t||typeof t=="function"||typeof t=="object"&&typeof t.length=="number")return str("",{"":e});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i=="object")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}();