forked from flowersinthesand/bower-jquery-atmosphere
-
Notifications
You must be signed in to change notification settings - Fork 3
/
jquery.atmosphere.min.js
2 lines (2 loc) · 38.4 KB
/
jquery.atmosphere.min.js
1
2
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):e(jQuery)}(function(e){e(window).bind("unload.atmosphere",function(){e.atmosphere.debug(new Date+" Atmosphere: unload event"),e.atmosphere.unsubscribe()}),e(window).bind("beforeunload.atmosphere",function(){e.atmosphere.debug(new Date+" Atmosphere: beforeunload event"),e.atmosphere._beforeUnloadState=!0,setTimeout(function(){e.atmosphere.debug(new Date+" Atmosphere: beforeunload event timeout reached. Reset _beforeUnloadState flag"),e.atmosphere._beforeUnloadState=!1},5e3)}),e(window).bind("offline",function(){e.atmosphere.offline=!0;for(var n=[].concat(e.atmosphere.requests),t=0;t<n.length;t++){var o=n[t];o.close(),clearTimeout(o.response.request.id),o.heartbeatTimer&&clearTimeout(o.heartbeatTimer)}}),e(window).bind("online",function(){if(e.atmosphere.offline=!1,e.atmosphere.requests.length>0)for(var n=0;n<e.atmosphere.requests.length;n++)e.atmosphere.requests[n].init(),e.atmosphere.requests[n].execute()}),e(window).keypress(function(e){27===e.keyCode&&e.preventDefault()});var n=function(e){for(var n,t=/^(.*?):[ \t]*([^\r\n]*)\r?$/gm,o={};n=t.exec(e);)o[n[1]]=n[2];return o};e.atmosphere={version:"2.2.12-jquery",uuid:0,offline:!1,requests:[],callbacks:[],onError:function(){},onClose:function(){},onOpen:function(){},onMessage:function(){},onReconnect:function(){},onMessagePublished:function(){},onTransportFailure:function(){},onLocalMessage:function(){},onClientTimeout:function(){},onFailureToReconnect:function(){},WebsocketApiAdapter:function(e){var n,t;return e.onMessage=function(e){t.onmessage({data:e.responseBody})},e.onMessagePublished=function(e){t.onmessage({data:e.responseBody})},e.onOpen=function(e){t.onopen(e)},t={close:function(){n.close()},send:function(e){n.push(e)},onmessage:function(){},onopen:function(){},onclose:function(){},onerror:function(){}},n=new $.atmosphere.subscribe(e),t},AtmosphereRequest:function(t){function o(){vn=!0,Sn=!1,wn=0,fn=null,mn=null,gn=null,hn=null}function r(){an(),o()}function a(e){return"debug"==e?"debug"===dn.logLevel:"info"==e?"info"===dn.logLevel||"debug"===dn.logLevel:"warn"==e?"warn"===dn.logLevel||"info"===dn.logLevel||"debug"===dn.logLevel:"error"==e?"error"===dn.logLevel||"warn"===dn.logLevel||"info"===dn.logLevel||"debug"===dn.logLevel:!1}function s(n){a("debug")&&e.atmosphere.debug(new Date+" Atmosphere: "+n)}function i(n){r(),dn=e.extend(dn,n),dn.mrequest=dn.reconnect,dn.reconnect||(dn.reconnect=!0)}function c(){return null!=dn.webSocketImpl||window.WebSocket||window.MozWebSocket}function l(){function n(e){var n=document.createElement("div");return n.innerHTML='<a href="'+e+'"/>',encodeURI(decodeURI(n.firstChild.href))}var t=n(dn.url.toLowerCase()),o=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/.exec(t),r=!(!o||o[1]==window.location.protocol&&o[2]==window.location.hostname&&(o[3]||("http:"===o[1]?80:443))==(window.location.port||("http:"===window.location.protocol?80:443)));return window.EventSource&&(!r||!e.browser.safari||e.browser.vmajor>=7)}function u(){if(dn.shared){if(Rn=d(dn),null!=Rn&&(a("debug")&&e.atmosphere.debug("Storage service available. All communication will be local"),Rn.open(dn)))return;a("debug")&&e.atmosphere.debug("No Storage service available."),Rn=null}dn.firstMessage=0==e.atmosphere.uuid?!0:!1,dn.isOpen=!1,dn.ctime=e.now(),0===dn.uuid&&(dn.uuid=e.atmosphere.uuid),dn.closedByClientTimeout=!1,"websocket"!==dn.transport&&"sse"!==dn.transport?U(dn):"websocket"===dn.transport?c()?T(!1):I("Websocket is not supported, using request.fallbackTransport ("+dn.fallbackTransport+")"):"sse"===dn.transport&&(l()?y(!1):I("Server Side Events(SSE) is not supported, using request.fallbackTransport ("+dn.fallbackTransport+")"))}function d(n){function t(t){var o=e.parseJSON(t),r=o.data;if("c"===o.target)switch(o.type){case"open":f("opening","local",dn);break;case"close":s||(s=!0,"aborted"===r.reason?rn():r.heir===Cn?u():setTimeout(function(){u()},100));break;case"message":V(r,"messageReceived",200,n.transport);break;case"localMessage":K(r)}}function o(){var n=new RegExp("(?:^|; )("+encodeURIComponent(i)+")=([^;]*)").exec(document.cookie);return n?e.parseJSON(decodeURIComponent(n[2])):void 0}var r,a,s,i="atmosphere-"+n.url,c={storage:function(){if(e.atmosphere.supportStorage()){var o=window.localStorage,r=function(n){return e.parseJSON(o.getItem(i+"-"+n))},a=function(n,t){o.setItem(i+"-"+n,e.stringifyJSON(t))};return{init:function(){return a("children",r("children").concat([Cn])),e(window).on("storage.socket",function(e){e=e.originalEvent,e.key===i&&e.newValue&&t(e.newValue)}),r("opened")},signal:function(n,t){o.setItem(i,e.stringifyJSON({target:"p",type:n,data:t}))},close:function(){var t,o=r("children");e(window).off("storage.socket"),o&&(t=e.inArray(n.id,o),t>-1&&(o.splice(t,1),a("children",o)))}}}},windowref:function(){var n=window.open("",i.replace(/\W/g,""));if(n&&!n.closed&&n.callbacks)return{init:function(){return n.callbacks.push(t),n.children.push(Cn),n.opened},signal:function(t,o){!n.closed&&n.fire&&n.fire(e.stringifyJSON({target:"p",type:t,data:o}))},close:function(){function o(n,t){var o=e.inArray(t,n);o>-1&&n.splice(o,1)}s||(o(n.callbacks,t),o(n.children,Cn))}}}};return r=o(),!r||e.now()-r.ts>1e3||!(a=c.storage()||c.windowref())?void 0:{open:function(){var s;return ln=setInterval(function(){var n=r;r=o(),r&&n.ts!==r.ts||t(e.stringifyJSON({target:"c",type:"close",data:{reason:"error",heir:n.heir}}))},1e3),s=a.init(),s&&setTimeout(function(){f("opening","local",n)},50),s},send:function(e){a.signal("send",e)},localSend:function(n){a.signal("localSend",e.stringifyJSON({id:Cn,event:n}))},close:function(){Sn||(clearInterval(ln),a.signal("close"),a.close())}}}function p(){function n(n){var t=e.parseJSON(n),o=t.data;if("p"===t.target)switch(t.type){case"send":j(o);break;case"localSend":K(o);break;case"close":rn()}}function t(){document.cookie=un+"="+encodeURIComponent(e.stringifyJSON({ts:e.now()+1,heir:(o.get("children")||[])[0]}))+"; path=/"}var o,r="atmosphere-"+dn.url,s={storage:function(){if(e.atmosphere.supportStorage()){var t=window.localStorage;return{init:function(){e(window).on("storage.socket",function(e){e=e.originalEvent,e.key===r&&e.newValue&&n(e.newValue)})},signal:function(n,o){t.setItem(r,e.stringifyJSON({target:"c",type:n,data:o}))},get:function(n){return e.parseJSON(t.getItem(r+"-"+n))},set:function(n,o){t.setItem(r+"-"+n,e.stringifyJSON(o))},close:function(){e(window).off("storage.socket"),t.removeItem(r),t.removeItem(r+"-opened"),t.removeItem(r+"-children")}}}},windowref:function(){var t=r.replace(/\W/g,""),o=(e('iframe[name="'+t+'"]')[0]||e('<iframe name="'+t+'" />').hide().appendTo("body")[0]).contentWindow;return{init:function(){o.callbacks=[n],o.fire=function(e){var n;for(n=0;n<o.callbacks.length;n++)o.callbacks[n](e)}},signal:function(n,t){!o.closed&&o.fire&&o.fire(e.stringifyJSON({target:"c",type:n,data:t}))},get:function(e){return o.closed?null:o[e]},set:function(e,n){o.closed||(o[e]=n)},close:function(){}}}};kn=function(e){o.signal("message",e)},o=s.storage()||s.windowref(),o.init(),a("debug")&&e.atmosphere.debug("Installed StorageService "+o),o.set("children",[]),null==o.get("opened")||o.get("opened")||o.set("opened",!1),un=encodeURIComponent(r),t(),ln=setInterval(t,1e3),cn=o}function f(e,n,t){if(dn.shared&&"local"!==n&&p(),null!=cn&&cn.set("opened",!0),t.close=function(){rn()},wn>0&&"re-connecting"===e)t.isReopen=!0,D(pn);else if(null==pn.error){pn.request=t;var o=pn.state;pn.state=e;var r=pn.transport;pn.transport=n;var a=pn.responseBody;nn(),pn.responseBody=a,pn.state=o,pn.transport=r}}function m(n){n.transport="jsonp";var t=dn;null!=n&&"undefined"!=typeof n&&(t=n);var o=t.url;null!=t.dispatchUrl&&(o+=t.dispatchUrl);var r=t.data;t.attachHeadersAsQueryString&&(o=O(t),""!==r&&(o+="&X-Atmosphere-Post-Body="+encodeURIComponent(r)),r=""),bn=e.ajax({url:o,type:t.method,dataType:"jsonp",error:function(e,n,o){pn.error=!0,t.openId&&clearTimeout(t.openId),t.heartbeatTimer&&clearTimeout(t.heartbeatTimer),t.reconnect&&wn++<t.maxReconnectOnClose?(f("re-connecting",t.transport,t),A(bn,t,t.reconnectInterval),t.openId=setTimeout(function(){q(t)},t.reconnectInterval+1e3)):C(e.status,o)},jsonp:"jsonpTransport",success:function(n){if(t.reconnect)if(-1===t.maxRequest||t.requestCount++<t.maxRequest){G(bn,t);var o=n.message;if(null!=o&&"string"!=typeof o)try{o=e.stringifyJSON(o)}catch(r){}var a=x(o,t,pn);t.executeCallbackBeforeReconnect||A(bn,t,t.pollingInterval),a||V(pn.responseBody,"messageReceived",200,t.transport),t.executeCallbackBeforeReconnect&&A(bn,t,t.pollingInterval),k(t)}else e.atmosphere.log(dn.logLevel,["JSONP reconnect maximum try reached "+dn.requestCount]),C(0,"maxRequest reached")},data:t.data,beforeSend:function(e){L(e,t,!1)}})}function g(n){var t=dn;null!=n&&"undefined"!=typeof n&&(t=n);var o=t.url;null!=t.dispatchUrl&&(o+=t.dispatchUrl);var r=t.data;t.attachHeadersAsQueryString&&(o=O(t),""!==r&&(o+="&X-Atmosphere-Post-Body="+encodeURIComponent(r)),r="");var a="undefined"!=typeof t.async?t.async:!0;bn=e.ajax({url:o,type:t.method,error:function(e,n,o){pn.error=!0,e.status<300?A(bn,t):C(e.status,o)},success:function(n){if(t.reconnect)if(-1===t.maxRequest||t.requestCount++<t.maxRequest){t.executeCallbackBeforeReconnect||A(bn,t,t.pollingInterval);var o=x(n,t,pn);o||V(pn.responseBody,"messageReceived",200,t.transport),t.executeCallbackBeforeReconnect&&A(bn,t,t.pollingInterval)}else e.atmosphere.log(dn.logLevel,["AJAX reconnect maximum try reached "+dn.requestCount]),C(0,"maxRequest reached")},beforeSend:function(e){L(e,t,!1)},crossDomain:t.enableXDR,async:a})}function h(e){return null!=dn.webSocketImpl?dn.webSocketImpl:window.WebSocket?new WebSocket(e):new MozWebSocket(e)}function v(){var n=O(dn);return decodeURI(e('<a href="'+n+'"/>')[0].href.replace(/^http/,"ws"))}function w(){var e=O(dn);return e}function y(n){pn.transport="sse";var t=w(dn.url);if(a("debug")&&(e.atmosphere.debug("Invoking executeSSE"),e.atmosphere.debug("Using URL: "+t)),n&&!dn.reconnect)return void(null!=mn&&an());try{mn=new EventSource(t,{withCredentials:dn.withCredentials})}catch(o){return C(0,o),void I("SSE failed. Downgrading to fallback transport and resending")}dn.connectTimeout>0&&(dn.id=setTimeout(function(){n||an()},dn.connectTimeout)),mn.onopen=function(){s("websocket.onopen"),k(dn),a("debug")&&e.atmosphere.debug("SSE successfully opened"),dn.enableProtocol?dn.isReopen&&(dn.isReopen=!1,f("re-opening",dn.transport,dn)):n?f("re-opening","sse",dn):f("opening","sse",dn),n=!0,"POST"===dn.method&&(pn.state="messageReceived",mn.send(dn.data))},mn.onmessage=function(n){if(s("websocket.onmessage"),k(dn),!dn.enableXDR&&n.origin!==window.location.protocol+"//"+window.location.host)return void e.atmosphere.log(dn.logLevel,["Origin was not "+window.location.protocol+"//"+window.location.host]);pn.state="messageReceived",pn.status=200,n=n.data;var t=x(n,dn,pn);t||(nn(),pn.responseBody="",pn.messages=[])},mn.onerror=function(){s("websocket.onerror"),clearTimeout(dn.id),dn.heartbeatTimer&&clearTimeout(dn.heartbeatTimer),pn.closedByClientTimeout||(en(n),an(),Sn?e.atmosphere.log(dn.logLevel,["SSE closed normally"]):n?dn.reconnect&&"sse"===pn.transport&&(wn++<dn.maxReconnectOnClose?(f("re-connecting",dn.transport,dn),dn.reconnectInterval>0?dn.reconnectId=setTimeout(function(){y(!0)},dn.reconnectInterval):y(!0),pn.responseBody="",pn.messages=[]):(e.atmosphere.log(dn.logLevel,["SSE reconnect maximum try reached "+wn]),C(0,"maxReconnectOnClose reached"))):I("SSE failed. Downgrading to fallback transport and resending"))}}function T(n){pn.transport="websocket";var t=v(dn.url);if(a("debug")&&(e.atmosphere.debug("Invoking executeWebSocket"),e.atmosphere.debug("Using URL: "+t)),n&&!dn.reconnect)return void(null!=fn&&an());fn=h(t),null!=dn.webSocketBinaryType&&(fn.binaryType=dn.webSocketBinaryType),dn.connectTimeout>0&&(dn.id=setTimeout(function(){if(n);else{var e={code:1002,reason:"",wasClean:!1};fn.onclose(e);try{an()}catch(t){}}},dn.connectTimeout)),fn.onopen=function(){s("websocket.onopen"),k(dn),a("debug")&&e.atmosphere.debug("Websocket successfully opened"),e.atmosphere.offline=!1;var t=n;null!=fn&&(fn.canSendMessage=!0),dn.enableProtocol||(n=!0,t?f("re-opening","websocket",dn):f("opening","websocket",dn)),null!=fn&&"POST"===dn.method&&(pn.state="messageReceived",fn.send(dn.data))},fn.onmessage=function(e){s("websocket.onmessage: "+e),k(dn),dn.enableProtocol&&(n=!0),pn.state="messageReceived",pn.status=200,e=e.data;var t="string"==typeof e;if(t){var o=x(e,dn,pn);o||(nn(),pn.responseBody="",pn.messages=[])}else{if(e=S(dn,e),""===e)return;pn.responseBody=e,nn(),pn.responseBody=null}},fn.onerror=function(){s("websocket.onerror"),clearTimeout(dn.id),dn.heartbeatTimer&&clearTimeout(dn.heartbeatTimer)},fn.onclose=function(t){if(s("websocket.onclose"),"closed"!==pn.state){clearTimeout(dn.id);var o=t.reason;if(""===o)switch(t.code){case 1e3:o="Normal closure; the connection successfully completed whatever purpose for which it was created.";break;case 1001:o="The endpoint is going away, either because of a server failure or because the browser is navigating away from the page that opened the connection.";break;case 1002:o="The endpoint is terminating the connection due to a protocol error.";break;case 1003:o="The connection is being terminated because the endpoint received data of a type it cannot accept (for example, a text-only endpoint received binary data).";break;case 1004:o="The endpoint is terminating the connection because a data frame was received that is too large.";break;case 1005:o="Unknown: no status code was provided even though one was expected.";break;case 1006:o="Connection was closed abnormally (that is, with no close frame being sent)."}if(a("warn")&&(e.atmosphere.warn("Websocket closed, reason: "+o),e.atmosphere.warn("Websocket closed, wasClean: "+t.wasClean)),pn.closedByClientTimeout||e.atmosphere.offline)return void(dn.reconnectId&&(clearTimeout(dn.reconnectId),delete dn.reconnectId));en(n),pn.state="closed",Sn?e.atmosphere.log(dn.logLevel,["Websocket closed normally"]):n?dn.reconnect&&"websocket"===pn.transport&&(an(),wn++<dn.maxReconnectOnClose?(f("re-connecting",dn.transport,dn),dn.reconnectInterval>0?dn.reconnectId=setTimeout(function(){pn.responseBody="",pn.messages=[],T(!0)},dn.reconnectInterval):(pn.responseBody="",pn.messages=[],T(!0))):(e.atmosphere.log(dn.logLevel,["Websocket reconnect maximum try reached "+dn.requestCount]),a("warn")&&e.atmosphere.warn("Websocket error, reason: "+t.reason),C(0,"maxReconnectOnClose reached"))):I("Websocket failed. Downgrading to Comet and resending")}};var o=navigator.userAgent.toLowerCase(),r=o.indexOf("android")>-1;r&&void 0===fn.url&&fn.onclose({reason:"Android 4.1 does not support websockets.",wasClean:!1})}function S(n,t){var o=t;if("polling"===n.transport)return o;if(n.enableProtocol&&n.firstMessage&&0!==e.trim(t).length){var r=n.trackMessageLength?1:0,a=t.split(n.messageDelimiter);if(a.length<=r+1)return o;if(n.firstMessage=!1,n.uuid=e.trim(a[r]),a.length<=r+2&&e.atmosphere.log("error",["Protocol data not sent by the server. If you enable protocol on client side, be sure to install JavascriptProtocol interceptor on server side.Also note that atmosphere-runtime 2.2+ should be used."]),yn=parseInt(e.trim(a[r+1]),10),Tn=a[r+2],b=!1,"long-polling"!==n.transport&&q(n),e.atmosphere.uuid=n.uuid,o="",r=n.trackMessageLength?4:3,a.length>r+1)for(var s=r;s<a.length;s++)o+=a[s],s+1!==a.length&&(o+=n.messageDelimiter);0!==n.ackInterval&&setTimeout(function(){j("...ACK...")},n.ackInterval)}else n.enableProtocol&&n.firstMessage&&e.browser.msie&&+e.browser.version.split(".")[0]<10?e.atmosphere.log(dn.logLevel,["Receiving unexpected data from IE"]):q(n);return o}function k(e){clearTimeout(e.id),e.timeout>0&&"polling"!==e.transport&&(e.id=setTimeout(function(){R(e),on(),an()},e.timeout))}function R(){pn.closedByClientTimeout=!0,pn.state="closedByClient",pn.responseBody="",pn.status=408,pn.messages=[],nn()}function C(e,n){an(),clearTimeout(dn.id),pn.state="error",pn.reasonPhrase=n,pn.responseBody="",pn.status=e,pn.messages=[],nn()}function x(e,n,t){if(e=S(n,e),0===e.length)return!0;if(t.responseBody=e,n.trackMessageLength){e=t.partialMessage+e;var o=[],r=e.indexOf(n.messageDelimiter);if(-1!=r){for(;-1!==r;){var a=e.substring(0,r),s=parseInt(a,10);if(isNaN(s))throw'message length "'+a+'" is not a number';r+=n.messageDelimiter.length,r+s>e.length?r=-1:(o.push(e.substring(r,r+s)),e=e.substring(r+s,e.length),r=e.indexOf(n.messageDelimiter))}return t.partialMessage=e,0!==o.length?(t.responseBody=o.join(n.messageDelimiter),t.messages=o,!1):(t.responseBody="",t.messages=[],!0)}}return t.responseBody=e,t.messages=[e],!1}function I(n){e.atmosphere.log(dn.logLevel,[n]),"undefined"!=typeof dn.onTransportFailure?dn.onTransportFailure(n,dn):"undefined"!=typeof e.atmosphere.onTransportFailure&&e.atmosphere.onTransportFailure(n,dn),dn.transport=dn.fallbackTransport;var t=-1===dn.connectTimeout?0:dn.connectTimeout;dn.reconnect&&"none"!==dn.transport||null==dn.transport?(dn.method=dn.fallbackMethod,pn.transport=dn.fallbackTransport,dn.fallbackTransport="none",t>0?dn.reconnectId=setTimeout(function(){u()},t):u()):C(500,"Unable to reconnect with fallback transport")}function O(n,t){var o=dn;return null!=n&&"undefined"!=typeof n&&(o=n),null==t&&(t=o.url),o.attachHeadersAsQueryString?-1!==t.indexOf("X-Atmosphere-Framework")?t:(t+=-1!==t.indexOf("?")?"&":"?",t+="X-Atmosphere-tracking-id="+o.uuid,t+="&X-Atmosphere-Framework="+e.atmosphere.version,t+="&X-Atmosphere-Transport="+o.transport,o.trackMessageLength&&(t+="&X-Atmosphere-TrackMessageSize=true"),null!==o.heartbeat&&null!==o.heartbeat.server&&(t+="&X-Heartbeat-Server="+o.heartbeat.server),""!==o.contentType&&(t+="&Content-Type="+("websocket"===o.transport?o.contentType:encodeURIComponent(o.contentType))),o.enableProtocol&&(t+="&X-atmo-protocol=true"),e.each(o.headers,function(r,a){var s=e.isFunction(a)?a.call(this,o,n,pn):a;null!=s&&(t+="&"+encodeURIComponent(r)+"="+encodeURIComponent(s))}),t):t}function q(e){if(e.isOpen){if(!e.isReopen)return;e.isReopen=!1,f("re-opening",e.transport,e)}else e.isOpen=!0,f("opening",e.transport,e);B(e)}function B(n){if(null!=n.heartbeatTimer&&clearTimeout(n.heartbeatTimer),!isNaN(yn)&&yn>0){var t=function(){a("debug")&&e.atmosphere.debug("Sending heartbeat"),j(Tn),n.heartbeatTimer=setTimeout(t,yn)};n.heartbeatTimer=setTimeout(t,yn)}}function U(t){var o=dn;if((null!=t||"undefined"!=typeof t)&&(o=t),o.lastIndex=0,o.readyState=0,"jsonp"===o.transport||o.enableXDR&&e.atmosphere.checkCORSSupport())return void m(o);if("ajax"===o.transport)return void g(t);if(e.browser.msie&&+e.browser.version.split(".")[0]<10){if("streaming"===o.transport)return void(o.enableXDR&&window.XDomainRequest?P(o):X(o));if(o.enableXDR&&window.XDomainRequest)return void P(o)}var r=function(e){o.lastIndex=0,e||o.reconnect&&wn++<o.maxReconnectOnClose?(pn.ffTryingReconnect=!0,f("re-connecting",t.transport,t),A(c,o,t.reconnectInterval)):C(0,"maxReconnectOnClose reached")},a=function(n){e.atmosphere._beforeUnloadState?(e.atmosphere.debug(new Date+" Atmosphere: reconnectF: execution delayed due to _beforeUnloadState flag"),setTimeout(function(){r(n)},5e3)):r(n)},i=function(){pn.errorHandled=!0,an(),a(!1)};if(o.reconnect&&(-1===o.maxRequest||o.requestCount++<o.maxRequest)){var c=e.ajaxSettings.xhr();c.hasData=!1,L(c,o,!0),o.suspend&&(gn=c),"polling"!==o.transport&&(pn.transport=o.transport,c.onabort=function(){s("ajaxrequest.onabort"),en(!0)},c.onerror=function(){s("ajaxrequest.onerror"),pn.error=!0,pn.ffTryingReconnect=!0;try{pn.status=XMLHttpRequest.status}catch(e){pn.status=500}pn.status||(pn.status=500),pn.errorHandled||(an(),a(!1))}),c.onreadystatechange=function(){if(s("ajaxRequest.onreadystatechange, new state: "+c.readyState),!Sn){pn.error=null;var r=!1,l=!1;if("streaming"===o.transport&&o.readyState>2&&4===c.readyState)return an(),void a(!1);if(o.readyState=c.readyState,"streaming"===o.transport&&c.readyState>=3?l=!0:"long-polling"===o.transport&&4===c.readyState&&(l=!0),k(dn),"polling"!==o.transport){var u=200;if(4===c.readyState&&(u=c.status>1e3?0:c.status),!o.reconnectOnServerError&&u>=300&&600>u)return void C(u,c.statusText);if(u>=300||0===u)return void i();o.enableProtocol&&t.firstMessage||2!==c.readyState||(e.browser.mozilla&&pn.ffTryingReconnect?(pn.ffTryingReconnect=!1,setTimeout(function(){pn.ffTryingReconnect||q(o)},500)):q(o))}else 4===c.readyState&&(l=!0);if(l){var d=c.responseText;if("long-polling"===o.transport&&0===e.trim(d).length)return void(c.hasData?c.hasData=!1:a(!0));if(c.hasData=!0,G(c,dn),"streaming"===o.transport)if(e.browser.opera)e.atmosphere.iterate(function(){if(500!==pn.status&&c.responseText.length>o.lastIndex){try{pn.status=c.status,pn.headers=n(c.getAllResponseHeaders()),G(c,dn)}catch(e){pn.status=404}k(dn),pn.state="messageReceived";var t=c.responseText.substring(o.lastIndex);if(o.lastIndex=c.responseText.length,r=x(t,o,pn),r||nn(),tn(c,o))return void M(c,o)}else if(pn.status>400)return o.lastIndex=c.responseText.length,!1},0);else{var p=d.substring(o.lastIndex,d.length);if(r=x(p,o,pn),o.lastIndex=d.length,r)return}else r=x(d,o,pn);var f=tn(c,o);try{pn.status=c.status,pn.headers=n(c.getAllResponseHeaders()),G(c,o)}catch(m){pn.status=404}pn.state=o.suspend?0===pn.status?"closed":"messageReceived":"messagePublished";var g=!f&&"streaming"!==t.transport&&"polling"!==t.transport;g&&!o.executeCallbackBeforeReconnect&&A(c,o,o.pollingInterval),0===pn.responseBody.length||r||nn(),g&&o.executeCallbackBeforeReconnect&&A(c,o,o.pollingInterval),f&&M(c,o)}}},c.send(o.data),vn=!0}else"debug"===o.logLevel&&e.atmosphere.log(o.logLevel,["Max re-connection reached."]),C(0,"maxRequest reached")}function M(e,n){pn.messages=[],n.isReopen=!0,rn(),Sn=!1,A(e,n,500)}function L(n,t,o){var r=t.url;null!=t.dispatchUrl&&"POST"===t.method&&(r+=t.dispatchUrl),r=O(t,r),r=e.atmosphere.prepareURL(r),o&&(n.open(t.method,r,!0),t.connectTimeout>0&&(t.id=setTimeout(function(){0===t.requestCount&&(an(),V("Connect timeout","closed",200,t.transport))},t.connectTimeout))),dn.withCredentials&&"websocket"!==dn.transport&&"withCredentials"in n&&(n.withCredentials=!0),dn.dropHeaders||(n.setRequestHeader("X-Atmosphere-Framework",e.atmosphere.version),n.setRequestHeader("X-Atmosphere-Transport",t.transport),null!==t.heartbeat&&null!==t.heartbeat.server&&n.setRequestHeader("X-Heartbeat-Server",n.heartbeat.server),t.trackMessageLength&&n.setRequestHeader("X-Atmosphere-TrackMessageSize","true"),n.setRequestHeader("X-Atmosphere-tracking-id",t.uuid),e.each(t.headers,function(r,a){var s=e.isFunction(a)?a.call(this,n,t,o,pn):a;null!=s&&n.setRequestHeader(r,s)})),""!==t.contentType&&n.setRequestHeader("Content-Type",t.contentType)}function A(e,n,t){if(!pn.closedByClientTimeout&&(n.reconnect||n.suspend&&vn)){var o=0;e.readyState>1&&(o=e.status>1e3?0:e.status),pn.status=0===o?204:o,pn.reason=0===o?"Server resumed the connection or down.":"OK",clearTimeout(n.id),n.reconnectId&&(clearTimeout(n.reconnectId),delete n.reconnectId),t>0?setTimeout(function(){dn.reconnectId=U(n)},t):U(n)}}function D(e){e.state="re-connecting",Y(e)}function P(e){"polling"!==e.transport?(hn=N(e),hn.open()):N(e).open()}function N(n){var t=dn;null!=n&&"undefined"!=typeof n&&(t=n);var o=t.transport,r=0,a=new window.XDomainRequest,s=function(){"long-polling"===t.transport&&t.reconnect&&(-1===t.maxRequest||t.requestCount++<t.maxRequest)&&(a.status=200,f("re-connecting",n.transport,n),P(t))},i=t.rewriteURL||function(e){var n=/(?:^|;\s*)(JSESSIONID|PHPSESSID)=([^;]*)/.exec(document.cookie);switch(n&&n[1]){case"JSESSIONID":return e.replace(/;jsessionid=[^\?]*|(\?)|$/,";jsessionid="+n[2]+"$1");case"PHPSESSID":return e.replace(/\?PHPSESSID=[^&]*&?|\?|$/,"?PHPSESSID="+n[2]+"&").replace(/&$/,"")}return e};a.onprogress=function(){c(a)},a.onerror=function(){"polling"!==t.transport&&(an(),wn++<t.maxReconnectOnClose?t.reconnectInterval>0?t.reconnectId=setTimeout(function(){f("re-connecting",n.transport,n),P(t)},t.reconnectInterval):(f("re-connecting",n.transport,n),P(t)):C(0,"maxReconnectOnClose reached"))},a.onload=function(){};var c=function(n){clearTimeout(t.id);var a=n.responseText;if(a=a.substring(r),r+=a.length,"polling"!==o){k(t);var i=x(a,t,pn);if("long-polling"===o&&0===e.trim(a).length)return;t.executeCallbackBeforeReconnect&&s(),i||V(pn.responseBody,"messageReceived",200,o),t.executeCallbackBeforeReconnect||s()}};return{open:function(){var e=t.url;null!=t.dispatchUrl&&(e+=t.dispatchUrl),e=O(t,e),a.open(t.method,i(e)),"GET"===t.method?a.send():a.send(t.data),t.connectTimeout>0&&(t.id=setTimeout(function(){0===t.requestCount&&(an(),V("Connect timeout","closed",200,t.transport))},t.connectTimeout))},close:function(){a.abort()}}}function X(e){hn=E(e),hn.open()}function E(n){var t=dn;null!=n&&"undefined"!=typeof n&&(t=n);var o,r=new window.ActiveXObject("htmlfile");r.open(),r.close();var a=t.url;return null!=t.dispatchUrl&&(a+=t.dispatchUrl),"polling"!==t.transport&&(pn.transport=t.transport),{open:function(){var n=r.createElement("iframe");a=O(t),""!==t.data&&(a+="&X-Atmosphere-Post-Body="+encodeURIComponent(t.data)),a=e.atmosphere.prepareURL(a),n.src=a,r.body.appendChild(n);var s=n.contentDocument||n.contentWindow.document;o=e.atmosphere.iterate(function(){try{if(!s.firstChild)return;if("complete"===s.readyState)try{e.noop(s.fileSize)}catch(n){return V("Connection Failure","error",500,t.transport),!1}var a=s.body?s.body.lastChild:s,i=function(){var e=a.cloneNode(!0);e.appendChild(s.createTextNode("."));var n=e.innerText;return n=n.substring(0,n.length-1)};if(!e.nodeName(a,"pre")){var c=s.head||s.getElementsByTagName("head")[0]||s.documentElement||s,l=s.createElement("script");l.text="document.write('<plaintext>')",c.insertBefore(l,c.firstChild),c.removeChild(l),a=s.body.lastChild}return t.closed&&(t.isReopen=!0),o=e.atmosphere.iterate(function(){var e=i();if(e.length>t.lastIndex){k(dn),pn.status=200,pn.error=null,a.innerText="";var n=x(e,t,pn);if(n)return"";V(pn.responseBody,"messageReceived",200,t.transport)}return t.lastIndex=0,"complete"===s.readyState?(en(!0),f("re-connecting",t.transport,t),t.reconnectInterval>0?t.reconnectId=setTimeout(function(){X(t)},t.reconnectInterval):X(t),!1):void 0},null),!1}catch(u){return pn.error=!0,f("re-connecting",t.transport,t),wn++<t.maxReconnectOnClose?t.reconnectInterval>0?t.reconnectId=setTimeout(function(){X(t)},t.reconnectInterval):X(t):C(0,"maxReconnectOnClose reached"),r.execCommand("Stop"),r.close(),!1}})},close:function(){o&&o(),r.execCommand("Stop"),en(!0)}}}function j(n){null!=Rn?F(n):null!=gn||null!=mn?J(n):null!=hn?W(n):null!=bn?_(n):null!=fn?Q(n):(C(0,"No suspended connection available"),e.atmosphere.error("No suspended connection available. Make sure atmosphere.subscribe has been called and request.onOpen invoked before invoking trying to push data"))}function F(e){Rn.send(e)}function H(n){if(0!==n.length)try{Rn?Rn.localSend(n):cn&&cn.signal("localMessage",e.stringifyJSON({id:Cn,event:n}))}catch(t){e.atmosphere.error(t)}}function J(e){var n=$(e);U(n)}function W(n){if(dn.enableXDR&&e.atmosphere.checkCORSSupport()){var t=$(n);t.reconnect=!1,m(t)}else J(n)}function _(e){J(e)}function z(e){var n=e;return"object"==typeof n&&(n=e.data),n}function $(n){var t=z(n),o={connected:!1,timeout:6e4,method:"POST",url:dn.url,contentType:dn.contentType,headers:dn.headers,reconnect:!0,callback:null,data:t,suspend:!1,maxRequest:-1,logLevel:"info",requestCount:0,withCredentials:dn.withCredentials,transport:"polling",isOpen:!0,attachHeadersAsQueryString:!0,enableXDR:dn.enableXDR,uuid:dn.uuid,dispatchUrl:dn.dispatchUrl,enableProtocol:!1,messageDelimiter:"|",trackMessageLength:dn.trackMessageLength,maxReconnectOnClose:dn.maxReconnectOnClose,heartbeatTimer:dn.heartbeatTimer,heartbeat:dn.heartbeat};return"object"==typeof n&&(o=e.extend(o,n)),o}function Q(n){var t,o=e.atmosphere.isBinary(n)?n:z(n);try{if(t=null!=dn.dispatchUrl?dn.webSocketPathDelimiter+dn.dispatchUrl+dn.webSocketPathDelimiter+o:o,!fn.canSendMessage)return void e.atmosphere.error("WebSocket not connected.");fn.send(t)}catch(r){fn.onclose=function(){},an(),I("Websocket failed. Downgrading to Comet and resending "+n),J(n)}}function K(n){var t=e.parseJSON(n);t.id!==Cn&&("undefined"!=typeof dn.onLocalMessage?dn.onLocalMessage(t.event):"undefined"!=typeof e.atmosphere.onLocalMessage&&e.atmosphere.onLocalMessage(t.event))}function V(e,n,t,o){pn.responseBody=e,pn.transport=o,pn.status=t,pn.state=n,nn()}function G(n,t){if(t.readResponsesHeaders)try{var o=n.getResponseHeader("X-Atmosphere-tracking-id");o&&null!=o&&(t.uuid=o.split(" ").pop())}catch(r){}else t.enableProtocol||(t.uuid=e.atmosphere.guid())}function Y(n){Z(n,dn),Z(n,e.atmosphere)}function Z(e,n){switch(e.state){case"messageReceived":s("Firing onMessage"),wn=0,"undefined"!=typeof n.onMessage&&n.onMessage(e);break;case"error":s("Firing onError"),"undefined"!=typeof n.onError&&n.onError(e);break;case"opening":s("Firing onOpen"),delete dn.closed,"undefined"!=typeof n.onOpen&&n.onOpen(e);break;case"messagePublished":s("Firing onMessagePublished"),"undefined"!=typeof n.onMessagePublished&&n.onMessagePublished(e);break;case"re-connecting":s("Firing onReconnect"),"undefined"!=typeof n.onReconnect&&n.onReconnect(dn,e);break;case"closedByClient":s("Firing onClientTimeout"),"undefined"!=typeof n.onClientTimeout&&n.onClientTimeout(dn);break;case"re-opening":s("Firing onReopen"),delete dn.closed,"undefined"!=typeof n.onReopen&&n.onReopen(dn,e);break;case"fail-to-reconnect":s("Firing onFailureToReconnect"),"undefined"!=typeof n.onFailureToReconnect&&n.onFailureToReconnect(dn,e);break;case"unsubscribe":case"closed":var t="undefined"!=typeof dn.closed?dn.closed:!1;t?s("Closed but not firing onClose"):(s("Firing onClose"),"undefined"!=typeof n.onClose&&n.onClose(e)),dn.closed=!0}}function en(e){"closed"!==pn.state&&(pn.state="closed",pn.responseBody="",pn.messages=[],pn.status=e?200:501,nn())}function nn(){var n=function(e,n){n(pn)};null==Rn&&null!=kn&&kn(pn.responseBody),dn.reconnect=dn.mrequest;for(var t="string"==typeof pn.responseBody,o=t&&dn.trackMessageLength?pn.messages.length>0?pn.messages:[""]:new Array(pn.responseBody),r=0;r<o.length;r++)if(!(o.length>1&&0===o[r].length||(pn.responseBody=t?e.trim(o[r]):o[r],null==Rn&&null!=kn&&kn(pn.responseBody),(0===pn.responseBody.length||t&&Tn===pn.responseBody)&&"messageReceived"===pn.state))){if(Y(pn),e.atmosphere.callbacks.length>0){a("debug")&&e.atmosphere.debug("Invoking "+e.atmosphere.callbacks.length+" global callbacks: "+pn.state);try{e.each(e.atmosphere.callbacks,n)}catch(s){e.atmosphere.log(dn.logLevel,["Callback exception"+s])}}if("function"==typeof dn.callback){a("debug")&&e.atmosphere.debug("Invoking request callbacks");try{dn.callback(pn)}catch(s){e.atmosphere.log(dn.logLevel,["Callback exception"+s])}}}}function tn(e,n){return""===pn.partialMessage&&"streaming"===n.transport&&e.responseText.length>n.maxStreamingLength?!0:!1}function on(){if(dn.enableProtocol&&!dn.firstMessage){var n="X-Atmosphere-Transport=close&X-Atmosphere-tracking-id="+dn.uuid;e.each(dn.headers,function(t,o){var r=e.isFunction(o)?o.call(this,dn,dn,pn):o;null!=r&&(n+="&"+encodeURIComponent(t)+"="+encodeURIComponent(r))});var t=dn.url.replace(/([?&])_=[^&]*/,n);t+=t===dn.url?(/\?/.test(dn.url)?"&":"?")+n:"",e.ajax(dn.connectTimeout>0?{url:t,async:dn.closeAsync,timeout:dn.connectTimeout,cache:!1,crossDomain:dn.enableXDR}:{url:t,async:dn.closeAsync,cache:!1,crossDomain:dn.enableXDR})}}function rn(){dn.reconnectId&&(clearTimeout(dn.reconnectId),delete dn.reconnectId),dn.heartbeatTimer&&clearTimeout(dn.heartbeatTimer),dn.reconnect=!1,Sn=!0,pn.request=dn,pn.state="unsubscribe",pn.responseBody="",pn.status=408,nn(),on(),an()}function an(){pn.partialMessage="",dn.id&&clearTimeout(dn.id),dn.heartbeatTimer&&clearTimeout(dn.heartbeatTimer),dn.reconnectId&&(clearTimeout(dn.reconnectId),delete dn.reconnectId),null!=hn&&(hn.close(),hn=null),null!=bn&&(bn.abort(),bn=null),null!=gn&&(gn.abort(),gn=null),null!=fn&&(fn.canSendMessage&&fn.close(),fn=null),null!=mn&&(mn.close(),mn=null),sn()
}function sn(){null!=cn&&(clearInterval(ln),document.cookie=un+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/",cn.signal("close",{reason:"",heir:Sn?(cn.get("children")||[])[0]:Cn}),cn.close()),null!=Rn&&Rn.close()}var cn,ln,un,dn={timeout:3e5,method:"GET",headers:{},contentType:"",callback:null,url:"",data:"",suspend:!0,maxRequest:-1,reconnect:!0,maxStreamingLength:1e7,lastIndex:0,logLevel:"info",requestCount:0,fallbackMethod:"GET",fallbackTransport:"streaming",transport:"long-polling",webSocketImpl:null,webSocketBinaryType:null,dispatchUrl:null,webSocketPathDelimiter:"@@",enableXDR:!1,rewriteURL:!1,attachHeadersAsQueryString:!0,executeCallbackBeforeReconnect:!1,readyState:0,withCredentials:!1,trackMessageLength:!1,messageDelimiter:"|",connectTimeout:-1,reconnectInterval:0,dropHeaders:!0,uuid:0,shared:!1,readResponsesHeaders:!1,maxReconnectOnClose:5,enableProtocol:!0,pollingInterval:0,heartbeat:{client:null,server:null},ackInterval:0,closeAsync:!1,reconnectOnServerError:!0,onError:function(){},onClose:function(){},onOpen:function(){},onMessage:function(){},onReopen:function(){},onReconnect:function(){},onMessagePublished:function(){},onTransportFailure:function(){},onLocalMessage:function(){},onFailureToReconnect:function(){},onClientTimeout:function(){}},pn={status:200,reasonPhrase:"OK",responseBody:"",messages:[],headers:[],state:"messageReceived",transport:"polling",error:null,request:null,partialMessage:"",errorHandled:!1,closedByClientTimeout:!1,ffTryingReconnect:!1},fn=null,mn=null,gn=null,hn=null,bn=null,vn=!0,wn=0,yn=0,Tn="X",Sn=!1,kn=null,Rn=null,Cn=e.now();i(t),this.subscribe=function(e){i(e),u()},this.execute=function(){u()},this.invokeCallback=function(){nn()},this.close=function(){rn()},this.disconnect=function(){on()},this.getUrl=function(){return dn.url},this.push=function(e,n){if(null!=n){var t=dn.dispatchUrl;dn.dispatchUrl=n,j(e),dn.dispatchUrl=t}else j(e)},this.getUUID=function(){return dn.uuid},this.pushLocal=function(e){H(e)},this.enableProtocol=function(){return dn.enableProtocol},this.init=function(){o()},this.request=dn,this.response=pn},subscribe:function(n,t,o){"function"==typeof t&&e.atmosphere.addCallback(t),"string"!=typeof n?o=n:o.url=n,e.atmosphere.uuid="undefined"!=typeof o&&"undefined"!=typeof o.uuid?o.uuid:0;var r=new e.atmosphere.AtmosphereRequest(o);return r.execute(),e.atmosphere.requests[e.atmosphere.requests.length]=r,r},addCallback:function(n){-1===e.inArray(n,e.atmosphere.callbacks)&&e.atmosphere.callbacks.push(n)},removeCallback:function(n){var t=e.inArray(n,e.atmosphere.callbacks);-1!==t&&e.atmosphere.callbacks.splice(t,1)},unsubscribe:function(){if(e.atmosphere.requests.length>0)for(var n=[].concat(e.atmosphere.requests),t=0;t<n.length;t++){var o=n[t];o.close(),clearTimeout(o.response.request.id),o.heartbeatTimer&&clearTimeout(o.heartbeatTimer)}e.atmosphere.requests=[],e.atmosphere.callbacks=[]},unsubscribeUrl:function(n){var t=-1;if(e.atmosphere.requests.length>0)for(var o=0;o<e.atmosphere.requests.length;o++){var r=e.atmosphere.requests[o];if(r.getUrl()===n){r.close(),clearTimeout(r.response.request.id),r.heartbeatTimer&&clearTimeout(r.heartbeatTimer),t=o;break}}t>=0&&e.atmosphere.requests.splice(t,1)},publish:function(n){"function"==typeof n.callback&&e.atmosphere.addCallback(n.callback),n.transport="polling";var t=new e.atmosphere.AtmosphereRequest(n);return e.atmosphere.requests[e.atmosphere.requests.length]=t,t},checkCORSSupport:function(){if(e.browser.msie&&!window.XDomainRequest&&+e.browser.version.split(".")[0]<11)return!0;if(e.browser.opera&&+e.browser.version.split(".")[0]<12)return!0;if("KreaTVWebKit/531"===e.trim(navigator.userAgent).slice(0,16))return!0;if("kreatel"===e.trim(navigator.userAgent).slice(-7).toLowerCase())return!0;var n=navigator.userAgent.toLowerCase(),t=n.indexOf("android")>-1;return t?!0:!1},S4:function(){return(65536*(1+Math.random())|0).toString(16).substring(1)},guid:function(){return e.atmosphere.S4()+e.atmosphere.S4()+"-"+e.atmosphere.S4()+"-"+e.atmosphere.S4()+"-"+e.atmosphere.S4()+"-"+e.atmosphere.S4()+e.atmosphere.S4()+e.atmosphere.S4()},prepareURL:function(n){var t=e.now(),o=n.replace(/([?&])_=[^&]*/,"$1_="+t);return o+(o===n?(/\?/.test(n)?"&":"?")+"_="+t:"")},param:function(n){return e.param(n,e.ajaxSettings.traditional)},supportStorage:function(){var n=window.localStorage;if(n)try{return n.setItem("t","t"),n.removeItem("t"),window.StorageEvent&&!e.browser.msie&&!(e.browser.mozilla&&"1"===e.browser.version.split(".")[0])}catch(t){}return!1},iterate:function(e,n){var t;return n=n||0,function o(){t=setTimeout(function(){e()!==!1&&o()},n)}(),function(){clearTimeout(t)}},log:function(e,n){if(window.console){var t=window.console[e];"function"==typeof t&&t.apply(window.console,n)}},warn:function(){e.atmosphere.log("warn",arguments)},info:function(){e.atmosphere.log("info",arguments)},debug:function(){e.atmosphere.log("debug",arguments)},error:function(){e.atmosphere.log("error",arguments)},isBinary:function(e){return/^\[object\s(?:Blob|ArrayBuffer|.+Array)\]$/.test(Object.prototype.toString.call(e))}},function(){var n,t;e.uaMatch=function(e){e=e.toLowerCase();var n=/(chrome)[ \/]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||/(trident)(?:.*? rv:([\w.]+)|)/.exec(e)||e.indexOf("android")<0&&/version\/(.+) (safari)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return"safari"===n[2]&&(n[2]=n[1],n[1]="safari"),{browser:n[1]||"",version:n[2]||"0"}},n=e.uaMatch(navigator.userAgent),t={},n.browser&&(t[n.browser]=!0,t.version=n.version,t.vmajor=t.version.split(".")[0]),t.trident&&(t.msie=!0),e.browser=t,e.sub=function(){function n(e,t){return new n.fn.init(e,t)}e.extend(!0,n,this),n.superclass=this,n.fn=n.prototype=this(),n.fn.constructor=n,n.sub=this.sub,n.fn.init=function(o,r){return r&&r instanceof e&&!(r instanceof n)&&(r=n(r)),e.fn.init.call(this,o,r,t)},n.fn.init.prototype=n.fn;var t=n(document);return n}}(),function(e){function n(e){return'"'+e.replace(r,function(e){var n=a[e];return"string"==typeof n?n:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"'}function t(e){return 10>e?"0"+e:e}function o(e,r){var a,s,i,c,l=r[e],u=typeof l;switch(l&&"object"==typeof l&&"function"==typeof l.toJSON&&(l=l.toJSON(e),u=typeof l),u){case"string":return n(l);case"number":return isFinite(l)?String(l):"null";case"boolean":return String(l);case"object":if(!l)return"null";switch(Object.prototype.toString.call(l)){case"[object Date]":return isFinite(l.valueOf())?'"'+l.getUTCFullYear()+"-"+t(l.getUTCMonth()+1)+"-"+t(l.getUTCDate())+"T"+t(l.getUTCHours())+":"+t(l.getUTCMinutes())+":"+t(l.getUTCSeconds())+'Z"':"null";case"[object Array]":for(i=l.length,c=[],a=0;i>a;a++)c.push(o(a,l)||"null");return"["+c.join(",")+"]";default:c=[];for(a in l)Object.prototype.hasOwnProperty.call(l,a)&&(s=o(a,l),s&&c.push(n(a)+":"+s));return"{"+c.join(",")+"}"}}}var r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};e.stringifyJSON=function(e){return window.JSON&&window.JSON.stringify?window.JSON.stringify(e):o("",{"":e})}}(e)});