forked from flowersinthesand/bower-atmosphere
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathatmosphere.min.js
78 lines (78 loc) · 39.1 KB
/
atmosphere.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
(function(e,F){"function"===typeof define&&define.amd?define(F):"undefined"!==typeof exports?module.exports=F():e.atmosphere=F()})(this,function(){var e={},F=!1,p=[],G=[],Y=0,ba=Object.prototype.hasOwnProperty,e={version:"2.3.2-javascript",onError:function(e){},onClose:function(e){},onOpen:function(e){},onReopen:function(e){},onMessage:function(e){},onReconnect:function(e,k){},onMessagePublished:function(e){},onTransportFailure:function(e,k){},onLocalMessage:function(e){},onFailureToReconnect:function(e,
k){},onClientTimeout:function(e){},onOpenAfterResume:function(e){},WebsocketApiAdapter:function(d){var k,g;d.onMessage=function(e){g.onmessage({data:e.responseBody})};d.onMessagePublished=function(e){g.onmessage({data:e.responseBody})};d.onOpen=function(e){g.onopen(e)};g={close:function(){k.close()},send:function(e){k.push(e)},onmessage:function(e){},onopen:function(e){},onclose:function(e){},onerror:function(e){}};k=new e.subscribe(d);return g},AtmosphereRequest:function(d){function k(){ca=!0;H=
!1;v=0;B=L=x=r=null}function g(b){return"debug"==b?"debug"===c.logLevel:"info"==b?"info"===c.logLevel||"debug"===c.logLevel:"warn"==b?"warn"===c.logLevel||"info"===c.logLevel||"debug"===c.logLevel:"error"==b?"error"===c.logLevel||"warn"===c.logLevel||"info"===c.logLevel||"debug"===c.logLevel:!1}function l(b){g("debug")&&e.util.debug(new Date+" Atmosphere: "+b)}function n(b,a){return""===f.partialMessage&&"streaming"===a.transport&&b.responseText.length>a.maxStreamingLength?!0:!1}function da(){if(c.enableProtocol&&
!c.disableDisconnect&&!c.firstMessage){var b="X-Atmosphere-Transport=close&X-Atmosphere-tracking-id="+c.uuid;e.util.each(c.headers,function(a,h){var d=e.util.isFunction(h)?h.call(this,c,c,f):h;null!=d&&(b+="&"+encodeURIComponent(a)+"="+encodeURIComponent(d))});var a=c.url.replace(/([?&])_=[^&]*/,b),a=a+(a===c.url?(/\?/.test(c.url)?"&":"?")+b:""),h=new e.AtmosphereRequest({connected:!1});h.connectTimeout=c.connectTimeout;h.attachHeadersAsQueryString=!1;h.dropHeaders=!0;h.url=a;h.contentType="text/plain";
h.transport="polling";h.method="GET";h.data="";h.heartbeat=null;c.enableXDR&&(h.enableXDR=c.enableXDR);h.async=c.closeAsync;va("",h)}}function t(){l("Closing (AtmosphereRequest._close() called)");H=!0;c.reconnectId&&(clearTimeout(c.reconnectId),delete c.reconnectId);c.heartbeatTimer&&clearTimeout(c.heartbeatTimer);c.reconnect=!1;f.request=c;f.state="unsubscribe";f.responseBody="";f.status=408;f.partialMessage="";y();da();q()}function q(){f.partialMessage="";c.id&&clearTimeout(c.id);c.heartbeatTimer&&
clearTimeout(c.heartbeatTimer);c.reconnectId&&(clearTimeout(c.reconnectId),delete c.reconnectId);null!=B&&(B.close(),B=null);null!=C&&(C.abort(),C=null);null!=L&&(L.abort(),L=null);null!=r&&(r.canSendMessage&&(l("invoking .close() on WebSocket object"),r.close()),r=null);null!=x&&(x.close(),x=null);null!=D&&(clearInterval(Z),document.cookie=ea+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/",D.signal("close",{reason:"",heir:H?(D.get("children")||[])[0]:A}),D.close());null!=w&&w.close()}function p(b){q();
k();c=e.util.extend(c,b);c.mrequest=c.reconnect;c.reconnect||(c.reconnect=!0)}function M(){if(c.shared){w=wa(c);if(null!=w&&(g("debug")&&e.util.debug("Storage service available. All communication will be local"),w.open(c)))return;g("debug")&&e.util.debug("No Storage service available.");w=null}c.firstMessage=0==Y?!0:!1;c.isOpen=!1;c.ctime=e.util.now();0===c.uuid&&(c.uuid=Y);f.closedByClientTimeout=!1;if("websocket"!==c.transport&&"sse"!==c.transport)Q(c);else if("websocket"===c.transport)null!=c.webSocketImpl||
window.WebSocket||window.MozWebSocket?fa(!1):N("Websocket is not supported, using request.fallbackTransport ("+c.fallbackTransport+")");else if("sse"===c.transport){var b=e.util.getAbsoluteURL(c.url.toLowerCase()),b=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/.exec(b),b=!(!b||b[1]==window.location.protocol&&b[2]==window.location.hostname&&(b[3]||("http:"===b[1]?80:443))==(window.location.port||("http:"===window.location.protocol?80:443)));!window.EventSource||b&&e.util.browser.safari&&!(7<=e.util.browser.vmajor)?
N("Server Side Events(SSE) is not supported, using request.fallbackTransport ("+c.fallbackTransport+")"):ga(!1)}}function wa(b){function a(a,b){var c,e=a.length;for(c=0;c<e;c++)a[c]===b&&a.splice(c,1);return e!==a.length}function h(a){a=e.util.parseJSON(a);var h=a.data;if("c"===a.target)switch(a.type){case "open":m("opening","local",c);break;case "close":ha||(ha=!0,"aborted"===h.reason?t():h.heir===A?M():setTimeout(function(){M()},100));break;case "message":O(h,"messageReceived",200,b.transport);
break;case "localMessage":ma(h)}}function d(){var a=(new RegExp("(?:^|; )("+encodeURIComponent(J)+")=([^;]*)")).exec(document.cookie);if(a)return e.util.parseJSON(decodeURIComponent(a[2]))}var f,g,ha,J="atmosphere-"+b.url,k={storage:function(){function c(a){a.key===J&&a.newValue&&h(a.newValue)}if(e.util.storage){var f=window.localStorage,d=function(a){return e.util.parseJSON(f.getItem(J+"-"+a))};return{init:function(){var a=d("children").concat([A]);f.setItem(J+"-children",e.util.stringifyJSON(a));
e.util.on(window,"storage",c);return d("opened")},signal:function(a,b){f.setItem(J,e.util.stringifyJSON({target:"p",type:a,data:b}))},close:function(){var h=d("children");e.util.off(window,"storage",c);h&&a(h,b.id)&&f.setItem(J+"-children",e.util.stringifyJSON(h))}}}},windowref:function(){var b=window.open("",J.replace(/\W/g,""));if(b&&!b.closed&&b.callbacks)return{init:function(){b.callbacks.push(h);b.children.push(A);return b.opened},signal:function(a,c){!b.closed&&b.fire&&b.fire(e.util.stringifyJSON({target:"p",
type:a,data:c}))},close:function(){ha||(a(b.callbacks,h),a(b.children,A))}}}};if((f=d())&&!(1E3<e.util.now()-f.ts)&&(g=k.storage()||k.windowref()))return{open:function(){var a;Z=setInterval(function(){var a=f;(f=d())&&a.ts!==f.ts||h(e.util.stringifyJSON({target:"c",type:"close",data:{reason:"error",heir:a.heir}}))},1E3);(a=g.init())&&setTimeout(function(){m("opening","local",b)},50);return a},send:function(a){g.signal("send",a)},localSend:function(a){g.signal("localSend",e.util.stringifyJSON({id:A,
event:a}))},close:function(){H||(clearInterval(Z),g.signal("close"),g.close())}}}function z(){function b(a){a=e.util.parseJSON(a);var b=a.data;if("p"===a.target)switch(a.type){case "send":R(b);break;case "localSend":ma(b);break;case "close":t()}}function a(){document.cookie=ea+"="+encodeURIComponent(e.util.stringifyJSON({ts:e.util.now()+1,heir:(h.get("children")||[])[0]}))+"; path=/"}var h,f="atmosphere-"+c.url,d={storage:function(){function a(c){c.key===f&&c.newValue&&b(c.newValue)}if(e.util.storage){var c=
window.localStorage;return{init:function(){e.util.on(window,"storage",a)},signal:function(a,b){c.setItem(f,e.util.stringifyJSON({target:"c",type:a,data:b}))},get:function(a){return e.util.parseJSON(c.getItem(f+"-"+a))},set:function(a,b){c.setItem(f+"-"+a,e.util.stringifyJSON(b))},close:function(){e.util.off(window,"storage",a);c.removeItem(f);c.removeItem(f+"-opened");c.removeItem(f+"-children")}}}},windowref:function(){var a=f.replace(/\W/g,""),c=document.getElementById(a),h;c||(c=document.createElement("div"),
c.id=a,c.style.display="none",c.innerHTML='<iframe name="'+a+'" />',document.body.appendChild(c));h=c.firstChild.contentWindow;return{init:function(){h.callbacks=[b];h.fire=function(a){var b;for(b=0;b<h.callbacks.length;b++)h.callbacks[b](a)}},signal:function(a,b){!h.closed&&h.fire&&h.fire(e.util.stringifyJSON({target:"c",type:a,data:b}))},get:function(a){return h.closed?null:h[a]},set:function(a,b){h.closed||(h[a]=b)},close:function(){}}}};S=function(a){h.signal("message",a)};h=d.storage()||d.windowref();
h.init();g("debug")&&e.util.debug("Installed StorageService "+h);h.set("children",[]);null==h.get("opened")||h.get("opened")||h.set("opened",!1);ea=encodeURIComponent(f);a();Z=setInterval(a,1E3);D=h}function m(b,a,h){c.shared&&"local"!==a&&z();null!=D&&D.set("opened",!0);h.close=function(){t()};0<v&&"re-connecting"===b?(h.isReopen=!0,xa(f)):null==f.error&&(f.request=h,h=f.state,f.state=b,b=f.transport,f.transport=a,a=f.responseBody,y(),f.responseBody=a,f.state=h,f.transport=b)}function na(b){b.transport=
"jsonp";var a=c,h;null!=b&&"undefined"!==typeof b&&(a=b);C={open:function(){function d(){a.lastIndex=0;a.openId&&clearTimeout(a.openId);a.heartbeatTimer&&clearTimeout(a.heartbeatTimer);a.reconnect&&v++<a.maxReconnectOnClose?(m("re-connecting",a.transport,a),K(C,a,b.reconnectInterval),a.openId=setTimeout(function(){T(a)},a.reconnectInterval+1E3)):u(0,"maxReconnectOnClose reached")}function ta(){var c=a.url;null!=a.dispatchUrl&&(c+=a.dispatchUrl);var e=a.data;a.attachHeadersAsQueryString&&(c=P(a),""!==
e&&(c+="&X-Atmosphere-Post-Body="+encodeURIComponent(e)),e="");e=document.head||document.getElementsByTagName("head")[0]||document.documentElement;h=document.createElement("script");h.src=c+"&jsonpTransport="+g;h.clean=function(){h.clean=h.onerror=h.onload=h.onreadystatechange=null;h.parentNode&&h.parentNode.removeChild(h);2===++b.scriptCount&&(b.scriptCount=1,d())};h.onload=h.onreadystatechange=function(){l("jsonp.onload");h.readyState&&!/loaded|complete/.test(h.readyState)||h.clean()};h.onerror=
function(){l("jsonp.onerror");b.scriptCount=1;h.clean()};e.insertBefore(h,e.firstChild)}var g="atmosphere"+ ++A;window[g]=function(h){l("jsonp.window");b.scriptCount=0;if(a.reconnect&&-1===a.maxRequest||a.requestCount++<a.maxRequest){a.executeCallbackBeforeReconnect||K(C,a,a.pollingInterval);if(null!=h&&"string"!==typeof h)try{h=h.message}catch(d){}I(h,a,f)||O(f.responseBody,"messageReceived",200,a.transport);a.executeCallbackBeforeReconnect&&K(C,a,a.pollingInterval);E(a)}else e.util.log(c.logLevel,
["JSONP reconnect maximum try reached "+c.requestCount]),u(0,"maxRequest reached")};setTimeout(function(){ta()},50)},abort:function(){h&&h.clean&&h.clean()}};C.open()}function ba(b){return null!=c.webSocketImpl?c.webSocketImpl:window.WebSocket?new WebSocket(b):new MozWebSocket(b)}function ga(b){f.transport="sse";var a=P(c);g("debug")&&(e.util.debug("Invoking executeSSE"),e.util.debug("Using URL: "+a));if(b&&!c.reconnect)null!=x&&q();else{try{x=new EventSource(a,{withCredentials:c.withCredentials})}catch(h){u(0,
h);N("SSE failed. Downgrading to fallback transport and resending");return}0<c.connectTimeout&&(c.id=setTimeout(function(){b||q()},c.connectTimeout));x.onopen=function(a){l("sse.onopen");E(c);g("debug")&&e.util.debug("SSE successfully opened");c.enableProtocol?c.isReopen&&(c.isReopen=!1,m("re-opening",c.transport,c)):b?m("re-opening","sse",c):m("opening","sse",c);b=!0;"POST"===c.method&&(f.state="messageReceived",x.send(c.data))};x.onmessage=function(a){l("sse.onmessage");E(c);!c.enableXDR&&window.location.host&&
a.origin&&a.origin!==window.location.protocol+"//"+window.location.host?e.util.log(c.logLevel,["Origin was not "+window.location.protocol+"//"+window.location.host]):(f.state="messageReceived",f.status=200,a=a.data,I(a,c,f)||(y(),f.responseBody="",f.messages=[]))};x.onerror=function(a){l("sse.onerror");clearTimeout(c.id);c.heartbeatTimer&&clearTimeout(c.heartbeatTimer);f.closedByClientTimeout||((U(b),q(),H)?e.util.log(c.logLevel,["SSE closed normally"]):b?c.reconnect&&"sse"===f.transport&&(v++<c.maxReconnectOnClose?
(m("re-connecting",c.transport,c),0<c.reconnectInterval?c.reconnectId=setTimeout(function(){ga(!0)},c.reconnectInterval):ga(!0),f.responseBody="",f.messages=[]):(e.util.log(c.logLevel,["SSE reconnect maximum try reached "+v]),u(0,"maxReconnectOnClose reached"))):N("SSE failed. Downgrading to fallback transport and resending"))}}}function fa(b){f.transport="websocket";var a=P(c,e.util.getAbsoluteURL(c.webSocketUrl||c.url)).replace(/^http/,"ws");g("debug")&&e.util.debug("Invoking executeWebSocket, using URL: "+
a);if(b&&!c.reconnect)null!=r&&q();else if(r=ba(a),null!=c.webSocketBinaryType&&(r.binaryType=c.webSocketBinaryType),0<c.connectTimeout&&(c.id=setTimeout(function(){if(!b){r.onclose({code:1002,reason:"",wasClean:!1});try{q()}catch(a){}}},c.connectTimeout)),r.onopen=function(a){l("websocket.onopen");E(c);F=!1;g("debug")&&e.util.debug("Websocket successfully opened");a=b;null!=r&&(r.canSendMessage=!0);c.enableProtocol||(b=!0,a?m("re-opening","websocket",c):m("opening","websocket",c));null!=r&&"POST"===
c.method&&(f.state="messageReceived",r.send(c.data))},r.onmessage=function(a){l("websocket.onmessage");E(c);c.enableProtocol&&(b=!0);f.state="messageReceived";f.status=200;a=a.data;"string"===typeof a?I(a,c,f)||(y(),f.responseBody="",f.messages=[]):(a=oa(c,a),""!==a&&(f.responseBody=a,y(),f.responseBody=null))},r.onerror=function(a){l("websocket.onerror");clearTimeout(c.id);c.heartbeatTimer&&clearTimeout(c.heartbeatTimer)},r.onclose=function(a){l("websocket.onclose");clearTimeout(c.id);if("closed"!==
f.state){var d=a.reason;if(""===d)switch(a.code){case 1E3:d="Normal closure; the connection successfully completed whatever purpose for which it was created.";break;case 1001:d="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:d="The endpoint is terminating the connection due to a protocol error.";break;case 1003:d="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:d="The endpoint is terminating the connection because a data frame was received that is too large.";break;case 1005:d="Unknown: no status code was provided even though one was expected.";break;case 1006:d="Connection was closed abnormally (that is, with no close frame being sent)."}g("warn")&&e.util.warn("Websocket closed, reason: "+d+" - wasClean: "+a.wasClean);f.closedByClientTimeout||c.handleOnlineOffline&&F?c.reconnectId&&(clearTimeout(c.reconnectId),delete c.reconnectId):(U(b),
f.state="closed",H)?e.util.log(c.logLevel,["Websocket closed normally"]):b?c.reconnect&&"websocket"===f.transport&&(q(),v++<c.maxReconnectOnClose?(m("re-connecting",c.transport,c),0<c.reconnectInterval?c.reconnectId=setTimeout(function(){f.responseBody="";f.messages=[];fa(!0)},c.reconnectInterval):(f.responseBody="",f.messages=[],fa(!0))):(e.util.log(c.logLevel,["Websocket reconnect maximum try reached "+v]),g("warn")&&e.util.warn("Websocket error, reason: "+a.reason),u(0,"maxReconnectOnClose reached"))):
N("Websocket failed on first connection attempt. Downgrading to "+c.fallbackTransport+" and resending")}},-1<navigator.userAgent.toLowerCase().indexOf("android")&&void 0===r.url)r.onclose({reason:"Android 4.1 does not support websockets.",wasClean:!1})}function oa(b,a){var h=a;if("polling"===b.transport)return h;if(b.enableProtocol&&b.firstMessage&&0!==e.util.trim(a).length){var d=b.trackMessageLength?1:0,f=a.split(b.messageDelimiter);if(f.length<=d+1)return h;b.firstMessage=!1;b.uuid=e.util.trim(f[d]);
f.length<=d+2&&e.util.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."]);V=parseInt(e.util.trim(f[d+1]),10);ia=f[d+2];"long-polling"!==b.transport&&T(b);Y=b.uuid;h="";d=b.trackMessageLength?4:3;if(f.length>d+1)for(;d<f.length;d++)h+=f[d],d+1!==f.length&&(h+=b.messageDelimiter);0!==b.ackInterval&&setTimeout(function(){R("...ACK...")},b.ackInterval)}else b.enableProtocol&&
b.firstMessage&&e.util.browser.msie&&10>+e.util.browser.version.split(".")[0]?e.util.log(c.logLevel,["Receiving unexpected data from IE"]):T(b);return h}function E(b){clearTimeout(b.id);0<b.timeout&&"polling"!==b.transport&&(b.id=setTimeout(function(){f.closedByClientTimeout=!0;f.state="closedByClient";f.responseBody="";f.status=408;f.messages=[];y();da();q()},b.timeout))}function u(b,a){q();clearTimeout(c.id);f.state="error";f.reasonPhrase=a;f.responseBody="";f.status=b;f.messages=[];y()}function I(b,
a,c){b=oa(a,b);if(0===b.length)return!0;c.responseBody=b;if(a.trackMessageLength){b=c.partialMessage+b;var e=[],d=b.indexOf(a.messageDelimiter);if(-1!=d){for(;-1!==d;){var f=b.substring(0,d),g=+f;if(isNaN(g))throw Error('message length "'+f+'" is not a number');d+=a.messageDelimiter.length;d+g>b.length?d=-1:(e.push(b.substring(d,d+g)),b=b.substring(d+g,b.length),d=b.indexOf(a.messageDelimiter))}c.partialMessage=b;if(0!==e.length)return c.responseBody=e.join(a.messageDelimiter),c.messages=e,!1;c.responseBody=
"";c.messages=[];return!0}}c.responseBody=b;c.messages=[b];return!1}function N(b){e.util.log(c.logLevel,[b]);if("undefined"!==typeof c.onTransportFailure)c.onTransportFailure(b,c);else if("undefined"!==typeof e.util.onTransportFailure)e.util.onTransportFailure(b,c);c.transport=c.fallbackTransport;b=-1===c.connectTimeout?0:c.connectTimeout;c.reconnect&&"none"!==c.transport||null==c.transport?(c.method=c.fallbackMethod,f.transport=c.fallbackTransport,c.fallbackTransport="none",0<b?c.reconnectId=setTimeout(function(){M()},
b):M()):u(500,"Unable to reconnect with fallback transport")}function P(b,a){var d=c;null!=b&&"undefined"!==typeof b&&(d=b);null==a&&(a=d.url);if(!d.attachHeadersAsQueryString||-1!==a.indexOf("X-Atmosphere-Framework"))return a;a+=-1!==a.indexOf("?")?"&":"?";a+="X-Atmosphere-tracking-id="+d.uuid;a+="&X-Atmosphere-Framework="+e.version;a+="&X-Atmosphere-Transport="+d.transport;d.trackMessageLength&&(a+="&X-Atmosphere-TrackMessageSize=true");null!==d.heartbeat&&null!==d.heartbeat.server&&(a+="&X-Heartbeat-Server="+
d.heartbeat.server);""!==d.contentType&&(a+="&Content-Type="+("websocket"===d.transport?d.contentType:encodeURIComponent(d.contentType)));d.enableProtocol&&(a+="&X-atmo-protocol=true");e.util.each(d.headers,function(c,g){var k=e.util.isFunction(g)?g.call(this,d,b,f):g;null!=k&&(a+="&"+encodeURIComponent(c)+"="+encodeURIComponent(k))});return a}function T(b){if(b.isOpen)if(b.isReopen)b.isReopen=!1,m("re-opening",b.transport,b);else{if("messageReceived"!==f.state||"jsonp"!==b.transport&&"long-polling"!==
b.transport)return;var a=f;a.state="openAfterResume";ja(a);a.state="messageReceived"}else b.isOpen=!0,m("opening",b.transport,b);ya(b)}function ya(b){null!=b.heartbeatTimer&&clearTimeout(b.heartbeatTimer);if(!isNaN(V)&&0<V){var a=function(){g("debug")&&e.util.debug("Sending heartbeat");R(ia);b.heartbeatTimer=setTimeout(a,V)};b.heartbeatTimer=setTimeout(a,V)}}function Q(b){var a=c;if(null!=b||"undefined"!==typeof b)a=b;a.lastIndex=0;a.readyState=0;if("jsonp"===a.transport||a.enableXDR&&e.util.checkCORSSupport())na(a);
else{if(e.util.browser.msie&&10>+e.util.browser.version.split(".")[0]){if("streaming"===a.transport){a.enableXDR&&window.XDomainRequest?W(a):X(a);return}if(a.enableXDR&&window.XDomainRequest){W(a);return}}var d=function(c){a.lastIndex=0;v++;c||a.reconnect&&v<=a.maxReconnectOnClose?(c=c?0:b.reconnectInterval,f.ffTryingReconnect=!0,m("re-connecting",b.transport,b),K(k,a,c)):u(0,"maxReconnectOnClose reached")},g=function(a){e._beforeUnloadState?(e.util.debug(new Date+" Atmosphere: reconnectF: execution delayed due to _beforeUnloadState flag"),
setTimeout(function(){d(a)},5E3)):d(a)};if(a.force||a.reconnect&&(-1===a.maxRequest||a.requestCount++<a.maxRequest)){a.force=!1;var k=e.util.xhr();k.hasData=!1;za(k,a,!0);a.suspend&&(L=k);"polling"!==a.transport&&(f.transport=a.transport,k.onabort=function(){l("ajaxrequest.onabort");U(!0)},k.onerror=function(){l("ajaxrequest.onerror");f.error=!0;f.ffTryingReconnect=!0;try{f.status=XMLHttpRequest.status}catch(a){f.status=500}f.status||(f.status=500);f.errorHandled||(q(),g(!1))});k.onreadystatechange=
function(){l("ajaxRequest.onreadystatechange, new state: "+k.readyState);if(H)l("onreadystatechange has been ignored due to _abortingConnection flag");else{f.error=null;var d=!1,h=!1;if("streaming"===a.transport&&2<a.readyState&&4===k.readyState)q(),g(!1);else{a.readyState=k.readyState;"streaming"===a.transport&&3<=k.readyState?h=!0:"long-polling"===a.transport&&4===k.readyState&&(h=!0);E(c);if("polling"!==a.transport){var m=200;4===k.readyState&&(m=1E3<k.status?0:k.status);if(!a.reconnectOnServerError&&
300<=m&&600>m){u(m,k.statusText);return}if(300<=m||0===m){f.errorHandled=!0;q();g(!1);return}a.enableProtocol&&b.firstMessage||2!==k.readyState||(e.util.browser.mozilla&&f.ffTryingReconnect?(f.ffTryingReconnect=!1,setTimeout(function(){f.ffTryingReconnect||T(a)},500)):T(a))}else 4===k.readyState&&(h=!0);if(h)if(h=k.responseText,f.errorHandled=!1,"long-polling"===a.transport&&0===e.util.trim(h).length)k.hasData?k.hasData=!1:g(!0);else{k.hasData=!0;ka(k,c);if("streaming"===a.transport)if(e.util.browser.opera)e.util.iterate(function(){if(500!==
f.status&&k.responseText.length>a.lastIndex){try{f.status=k.status,f.headers=e.util.parseHeaders(k.getAllResponseHeaders()),ka(k,c)}catch(b){f.status=404}E(c);f.state="messageReceived";var h=k.responseText.substring(a.lastIndex);a.lastIndex=k.responseText.length;(d=I(h,a,f))||y();n(k,a)&&pa(k,a)}else if(400<f.status)return a.lastIndex=k.responseText.length,!1},0);else{if(m=h.substring(a.lastIndex,h.length),d=I(m,a,f),a.lastIndex=h.length,d)return}else d=I(h,a,f);h=n(k,a);try{f.status=k.status,f.headers=
e.util.parseHeaders(k.getAllResponseHeaders()),ka(k,a)}catch(t){f.status=404}f.state=a.suspend?0===f.status?"closed":"messageReceived":"messagePublished";(m=!h&&"streaming"!==b.transport&&"polling"!==b.transport)&&!a.executeCallbackBeforeReconnect&&K(k,a,a.pollingInterval);0===f.responseBody.length||d||y();m&&a.executeCallbackBeforeReconnect&&K(k,a,a.pollingInterval);h&&pa(k,a)}}}};try{k.send(a.data),ca=!0}catch(ua){e.util.log(a.logLevel,["Unable to connect to "+a.url]),u(0,ua)}}else"debug"===a.logLevel&&
e.util.log(a.logLevel,["Max re-connection reached."]),u(0,"maxRequest reached")}}function pa(b,a){f.messages=[];a.isReopen=!0;t();H=!1;K(b,a,500)}function za(b,a,d){var k=a.url;null!=a.dispatchUrl&&"POST"===a.method&&(k+=a.dispatchUrl);k=P(a,k);k=e.util.prepareURL(k);d&&(b.open(a.method,k,a.async),0<a.connectTimeout&&(a.id=setTimeout(function(){0===a.requestCount&&(q(),O("Connect timeout","closed",200,a.transport))},a.connectTimeout)));c.withCredentials&&"websocket"!==c.transport&&"withCredentials"in
b&&(b.withCredentials=!0);c.dropHeaders||(b.setRequestHeader("X-Atmosphere-Framework",e.version),b.setRequestHeader("X-Atmosphere-Transport",a.transport),null!==a.heartbeat&&null!==a.heartbeat.server&&b.setRequestHeader("X-Heartbeat-Server",b.heartbeat.server),a.trackMessageLength&&b.setRequestHeader("X-Atmosphere-TrackMessageSize","true"),b.setRequestHeader("X-Atmosphere-tracking-id",a.uuid),e.util.each(a.headers,function(c,k){var g=e.util.isFunction(k)?k.call(this,b,a,d,f):k;null!=g&&b.setRequestHeader(c,
g)}));""!==a.contentType&&b.setRequestHeader("Content-Type",a.contentType)}function K(b,a,d){if(!f.closedByClientTimeout&&(a.reconnect||a.suspend&&ca)){var e=0;b&&1<b.readyState&&(e=1E3<b.status?0:b.status);f.status=0===e?204:e;f.reason=0===e?"Server resumed the connection or down.":"OK";clearTimeout(a.id);a.reconnectId&&(clearTimeout(a.reconnectId),delete a.reconnectId);0<d?c.reconnectId=setTimeout(function(){Q(a)},d):Q(a)}}function xa(b){b.state="re-connecting";ja(b)}function W(b){"polling"!==b.transport?
(B=qa(b),B.open()):qa(b).open()}function qa(b){var a=c;null!=b&&"undefined"!==typeof b&&(a=b);var d=a.transport,k=0,g=new window.XDomainRequest,l=function(){"long-polling"===a.transport&&a.reconnect&&(-1===a.maxRequest||a.requestCount++<a.maxRequest)&&(g.status=200,W(a))},t=a.rewriteURL||function(a){var b=/(?:^|;\s*)(JSESSIONID|PHPSESSID)=([^;]*)/.exec(document.cookie);switch(b&&b[1]){case "JSESSIONID":return a.replace(/;jsessionid=[^\?]*|(\?)|$/,";jsessionid="+b[2]+"$1");case "PHPSESSID":return a.replace(/\?PHPSESSID=[^&]*&?|\?|$/,
"?PHPSESSID="+b[2]+"&").replace(/&$/,"")}return a};g.onprogress=function(){clearTimeout(a.id);var b=g.responseText,b=b.substring(k);k+=b.length;if("polling"!==d){E(a);var c=I(b,a,f);if("long-polling"!==d||0!==e.util.trim(b).length)a.executeCallbackBeforeReconnect&&l(),c||O(f.responseBody,"messageReceived",200,d),a.executeCallbackBeforeReconnect||l()}};g.onerror=function(){"polling"!==a.transport&&(q(),v++<a.maxReconnectOnClose?0<a.reconnectInterval?a.reconnectId=setTimeout(function(){m("re-connecting",
b.transport,b);W(a)},a.reconnectInterval):(m("re-connecting",b.transport,b),W(a)):u(0,"maxReconnectOnClose reached"))};g.onload=function(){};return{open:function(){var b=a.url;null!=a.dispatchUrl&&(b+=a.dispatchUrl);b=P(a,b);g.open(a.method,t(b));"GET"===a.method?g.send():g.send(a.data);0<a.connectTimeout&&(a.id=setTimeout(function(){0===a.requestCount&&(q(),O("Connect timeout","closed",200,a.transport))},a.connectTimeout))},close:function(){g.abort()}}}function X(b){B=Aa(b);B.open()}function Aa(b){var a=
c;null!=b&&"undefined"!==typeof b&&(a=b);var d,k=new window.ActiveXObject("htmlfile");k.open();k.close();var g=a.url;null!=a.dispatchUrl&&(g+=a.dispatchUrl);"polling"!==a.transport&&(f.transport=a.transport);return{open:function(){var b=k.createElement("iframe");g=P(a);""!==a.data&&(g+="&X-Atmosphere-Post-Body="+encodeURIComponent(a.data));g=e.util.prepareURL(g);b.src=g;k.body.appendChild(b);var l=b.contentDocument||b.contentWindow.document;d=e.util.iterate(function(){try{if(l.firstChild){var b=l.body?
l.body.lastChild:l,g=function(){var a=b.cloneNode(!0);a.appendChild(l.createTextNode("."));a=a.innerText;return a=a.substring(0,a.length-1)};if(!l.body||!l.body.firstChild||"pre"!==l.body.firstChild.nodeName.toLowerCase()){var t=l.head||l.getElementsByTagName("head")[0]||l.documentElement||l,q=l.createElement("script");q.text="document.write('<plaintext>')";t.insertBefore(q,t.firstChild);t.removeChild(q);b=l.body.lastChild}a.closed&&(a.isReopen=!0);d=e.util.iterate(function(){var d=g();if(d.length>
a.lastIndex){E(c);f.status=200;f.error=null;b.innerText="";if(I(d,a,f))return"";O(f.responseBody,"messageReceived",200,a.transport)}a.lastIndex=0;if("complete"===l.readyState)return U(!0),m("re-connecting",a.transport,a),0<a.reconnectInterval?a.reconnectId=setTimeout(function(){X(a)},a.reconnectInterval):X(a),!1},null);return!1}}catch(n){return f.error=!0,m("re-connecting",a.transport,a),v++<a.maxReconnectOnClose?0<a.reconnectInterval?a.reconnectId=setTimeout(function(){X(a)},a.reconnectInterval):
X(a):u(0,"maxReconnectOnClose reached"),k.execCommand("Stop"),k.close(),!1}})},close:function(){d&&d();k.execCommand("Stop");U(!0)}}}function R(b){null!=w?w.send(b):null!=L||null!=x?aa(b):null!=B?c.enableXDR&&e.util.checkCORSSupport()?(b=la(b),b.reconnect=!1,na(b)):aa(b):null!=C?aa(b):null!=r?Ba(b):(u(0,"No suspended connection available"),e.util.error("No suspended connection available. Make sure atmosphere.subscribe has been called and request.onOpen invoked before trying to push data"))}function va(b,
a){a||(a=la(b));a.transport="polling";a.method="GET";a.withCredentials=!1;a.reconnect=!1;a.force=!0;a.suspend=!1;a.timeout=1E3;Q(a)}function aa(b){b=la(b);Q(b)}function ra(b){var a=b;"object"===typeof a&&(a=b.data);return a}function la(b){var a=ra(b),a={connected:!1,timeout:6E4,method:"POST",url:c.url,contentType:c.contentType,headers:c.headers,reconnect:!0,callback:null,data:a,suspend:!1,maxRequest:-1,logLevel:"info",requestCount:0,withCredentials:c.withCredentials,async:c.async,transport:"polling",
isOpen:!0,attachHeadersAsQueryString:!0,enableXDR:c.enableXDR,uuid:c.uuid,dispatchUrl:c.dispatchUrl,enableProtocol:!1,messageDelimiter:"|",trackMessageLength:c.trackMessageLength,maxReconnectOnClose:c.maxReconnectOnClose,heartbeatTimer:c.heartbeatTimer,heartbeat:c.heartbeat};"object"===typeof b&&(a=e.util.extend(a,b));return a}function Ba(b){var a=e.util.isBinary(b)?b:ra(b),d;try{d=null!=c.dispatchUrl?c.webSocketPathDelimiter+c.dispatchUrl+c.webSocketPathDelimiter+a:a,r.canSendMessage?r.send(d):e.util.error("WebSocket not connected.")}catch(f){r.onclose=
function(a){},q(),N("Websocket failed. Downgrading to "+c.fallbackTransport+" and resending "+b),aa(b)}}function ma(b){b=e.util.parseJSON(b);if(b.id!==A)if("undefined"!==typeof c.onLocalMessage)c.onLocalMessage(b.event);else if("undefined"!==typeof e.util.onLocalMessage)e.util.onLocalMessage(b.event)}function O(b,a,c,d){f.responseBody=b;f.transport=d;f.status=c;f.state=a;y()}function ka(b,a){if(a.readResponsesHeaders)try{var c=b.getResponseHeader("X-Atmosphere-tracking-id");c&&null!=c&&(a.uuid=c.split(" ").pop())}catch(d){}else a.enableProtocol||
(a.uuid=A)}function ja(b){sa(b,c);sa(b,e.util)}function sa(b,a){switch(b.state){case "messageReceived":l("Firing onMessage");v=0;if("undefined"!==typeof a.onMessage)a.onMessage(b);if("undefined"!==typeof a.onmessage)a.onmessage(b);break;case "error":l("Firing onError, reasonPhrase: "+("undefined"!=typeof b.reasonPhrase?b.reasonPhrase:"n/a"));if("undefined"!==typeof a.onError)a.onError(b);if("undefined"!==typeof a.onerror)a.onerror(b);break;case "opening":delete c.closed;l("Firing onOpen");if("undefined"!==
typeof a.onOpen)a.onOpen(b);if("undefined"!==typeof a.onopen)a.onopen(b);break;case "messagePublished":l("Firing messagePublished");if("undefined"!==typeof a.onMessagePublished)a.onMessagePublished(b);break;case "re-connecting":l("Firing onReconnect");if("undefined"!==typeof a.onReconnect)a.onReconnect(c,b);break;case "closedByClient":l("Firing closedByClient");if("undefined"!==typeof a.onClientTimeout)a.onClientTimeout(c);break;case "re-opening":delete c.closed;l("Firing onReopen");if("undefined"!==
typeof a.onReopen)a.onReopen(c,b);break;case "fail-to-reconnect":l("Firing onFailureToReconnect");if("undefined"!==typeof a.onFailureToReconnect)a.onFailureToReconnect(c,b);break;case "unsubscribe":case "closed":if("undefined"!==typeof c.closed&&c.closed)l("Request already closed, not firing onClose ("+b.state+" case)");else{l("Firing onClose ("+b.state+" case)");if("undefined"!==typeof a.onClose)a.onClose(b);if("undefined"!==typeof a.onclose)a.onclose(b)}c.closed=!0;break;case "openAfterResume":if("undefined"!==
typeof a.onOpenAfterResume)a.onOpenAfterResume(c)}}function U(b){"closed"!==f.state&&(f.state="closed",f.responseBody="",f.messages=[],f.status=b?200:501,y())}function y(){var b=function(a,b){b(f)};null==w&&null!=S&&S(f.responseBody);c.reconnect=c.mrequest;for(var a="string"===typeof f.responseBody,d=a&&c.trackMessageLength?0<f.messages.length?f.messages:[""]:Array(f.responseBody),k=0;k<d.length;k++)if(!(1<d.length&&0===d[k].length||(f.responseBody=a?e.util.trim(d[k]):d[k],null==w&&null!=S&&S(f.responseBody),
(0===f.responseBody.length||a&&ia===f.responseBody)&&"messageReceived"===f.state))){ja(f);if(0<G.length){g("debug")&&e.util.debug("Invoking "+G.length+" global callbacks: "+f.state);try{e.util.each(G,b)}catch(l){e.util.log(c.logLevel,["Callback exception"+l])}}if("function"===typeof c.callback){g("debug")&&e.util.debug("Invoking request callbacks");try{c.callback(f)}catch(l){e.util.log(c.logLevel,["Callback exception"+l])}}}}var c={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,async:!0,shared:!1,readResponsesHeaders:!1,maxReconnectOnClose:5,enableProtocol:!0,disableDisconnect:!1,pollingInterval:0,heartbeat:{client:null,server:null},ackInterval:0,closeAsync:!1,reconnectOnServerError:!0,handleOnlineOffline:!0,onError:function(b){},onClose:function(b){},onOpen:function(b){},onMessage:function(b){},onReopen:function(b,a){},onReconnect:function(b,a){},onMessagePublished:function(b){},onTransportFailure:function(b,a){},onLocalMessage:function(b){},onFailureToReconnect:function(b,
a){},onClientTimeout:function(b){},onOpenAfterResume:function(b){}},f={status:200,reasonPhrase:"OK",responseBody:"",messages:[],headers:[],state:"messageReceived",transport:"polling",error:null,request:null,partialMessage:"",errorHandled:!1,closedByClientTimeout:!1,ffTryingReconnect:!1},r=null,x=null,L=null,B=null,C=null,ca=!0,v=0,V=0,ia="X",H=!1,S=null,D,w=null,A=e.util.now(),Z,ea;p(d);this.subscribe=function(b){p(b);M()};this.execute=function(){M()};this.close=function(){t()};this.disconnect=function(){da()};
this.getUrl=function(){return c.url};this.push=function(b,a){if(null!=a){var d=c.dispatchUrl;c.dispatchUrl=a;R(b);c.dispatchUrl=d}else R(b)};this.getUUID=function(){return c.uuid};this.pushLocal=function(b){if(0!==b.length)try{w?w.localSend(b):D&&D.signal("localMessage",e.util.stringifyJSON({id:A,event:b}))}catch(a){e.util.error(a)}};this.enableProtocol=function(b){return c.enableProtocol};this.init=function(){k()};this.request=c;this.response=f},subscribe:function(d,k,g){"function"===typeof k&&e.addCallback(k);
"string"!==typeof d?g=d:g.url=d;Y="undefined"!==typeof g&&"undefined"!==typeof g.uuid?g.uuid:0;d=new e.AtmosphereRequest(g);d.execute();return p[p.length]=d},unsubscribe:function(){if(0<p.length)for(var d=[].concat(p),e=0;e<d.length;e++){var g=d[e];g.close();clearTimeout(g.response.request.id);g.heartbeatTimer&&clearTimeout(g.heartbeatTimer)}p=[];G=[]},unsubscribeUrl:function(d){var e=-1;if(0<p.length)for(var g=0;g<p.length;g++){var l=p[g];if(l.getUrl()===d){l.close();clearTimeout(l.response.request.id);
l.heartbeatTimer&&clearTimeout(l.heartbeatTimer);e=g;break}}0<=e&&p.splice(e,1)},addCallback:function(d){-1===e.util.inArray(d,G)&&G.push(d)},removeCallback:function(d){d=e.util.inArray(d,G);-1!==d&&G.splice(d,1)},util:{browser:{},parseHeaders:function(d){for(var e,g=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,l={};e=g.exec(d);)l[e[1]]=e[2];return l},now:function(){return(new Date).getTime()},isArray:function(d){return"[object Array]"===Object.prototype.toString.call(d)},inArray:function(d,e){if(!Array.prototype.indexOf){for(var g=
e.length,l=0;l<g;++l)if(e[l]===d)return l;return-1}return e.indexOf(d)},isBinary:function(d){return/^\[object\s(?:Blob|ArrayBuffer|.+Array)\]$/.test(Object.prototype.toString.call(d))},isFunction:function(d){return"[object Function]"===Object.prototype.toString.call(d)},getAbsoluteURL:function(d){if("undefined"===typeof document.createElement)return d;var e=document.createElement("div");e.innerHTML='<a href="'+d+'"/>';return encodeURI(decodeURI(e.firstChild.href))},prepareURL:function(d){var k=e.util.now(),
g=d.replace(/([?&])_=[^&]*/,"$1_="+k);return g+(g===d?(/\?/.test(d)?"&":"?")+"_="+k:"")},trim:function(d){return String.prototype.trim?d.toString().trim():d.toString().replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,"").replace(/\s+/g," ")},param:function(d){function k(d,g){g=e.util.isFunction(g)?g():null==g?"":g;n.push(encodeURIComponent(d)+"="+encodeURIComponent(g))}function g(d,l){var q;if(e.util.isArray(l))e.util.each(l,function(e,l){/\[\]$/.test(d)?k(d,l):g(d+"["+("object"===typeof l?e:"")+"]",l)});else if("[object Object]"===
Object.prototype.toString.call(l))for(q in l)g(d+"["+q+"]",l[q]);else k(d,l)}var l,n=[];for(l in d)g(l,d[l]);return n.join("&").replace(/%20/g,"+")},storage:function(){try{return!(!window.localStorage||!window.StorageEvent)}catch(d){return!1}},iterate:function(d,e){var g;e=e||0;(function n(){g=setTimeout(function(){!1!==d()&&n()},e)})();return function(){clearTimeout(g)}},each:function(d,k,g){if(d){var l,n=0,p=d.length;l=e.util.isArray(d);if(g)if(l)for(;n<p&&(l=k.apply(d[n],g),!1!==l);n++);else for(n in d){if(l=
k.apply(d[n],g),!1===l)break}else if(l)for(;n<p&&(l=k.call(d[n],n,d[n]),!1!==l);n++);else for(n in d)if(l=k.call(d[n],n,d[n]),!1===l)break;return d}},extend:function(d){var e,g,l;for(e=1;e<arguments.length;e++)if(null!=(g=arguments[e]))for(l in g)d[l]=g[l];return d},on:function(d,e,g){d.addEventListener?d.addEventListener(e,g,!1):d.attachEvent&&d.attachEvent("on"+e,g)},off:function(d,e,g){d.removeEventListener?d.removeEventListener(e,g,!1):d.detachEvent&&d.detachEvent("on"+e,g)},log:function(d,e){if(window.console){var g=
window.console[d];"function"===typeof g&&g.apply(window.console,e)}},warn:function(){e.util.log("warn",arguments)},info:function(){e.util.log("info",arguments)},debug:function(){e.util.log("debug",arguments)},error:function(){e.util.log("error",arguments)},xhr:function(){try{return new window.XMLHttpRequest}catch(d){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}},parseJSON:function(d){return d?window.JSON&&window.JSON.parse?window.JSON.parse(d):(new Function("return "+d))():
null},stringifyJSON:function(d){function e(d){return'"'+d.replace(l,function(d){var e=n[d];return"string"===typeof e?e:"\\u"+("0000"+d.charCodeAt(0).toString(16)).slice(-4)})+'"'}function g(d){return 10>d?"0"+d:d}var l=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};return window.JSON&&window.JSON.stringify?window.JSON.stringify(d):function t(d,
l){var n,p,z,m=l[d];z=typeof m;m&&"object"===typeof m&&"function"===typeof m.toJSON&&(m=m.toJSON(d),z=typeof m);switch(z){case "string":return e(m);case "number":return isFinite(m)?String(m):"null";case "boolean":return String(m);case "object":if(!m)return"null";switch(Object.prototype.toString.call(m)){case "[object Date]":return isFinite(m.valueOf())?'"'+m.getUTCFullYear()+"-"+g(m.getUTCMonth()+1)+"-"+g(m.getUTCDate())+"T"+g(m.getUTCHours())+":"+g(m.getUTCMinutes())+":"+g(m.getUTCSeconds())+'Z"':
"null";case "[object Array]":p=m.length;z=[];for(n=0;n<p;n++)z.push(t(n,m)||"null");return"["+z.join(",")+"]";default:z=[];for(n in m)ba.call(m,n)&&(p=t(n,m))&&z.push(e(n)+":"+p);return"{"+z.join(",")+"}"}}}("",{"":d})},checkCORSSupport:function(){if(e.util.browser.msie&&!window.XDomainRequest&&11>+e.util.browser.version.split(".")[0]||e.util.browser.opera&&12>+e.util.browser.version.split(".")||"KreaTVWebKit/531"===e.util.trim(navigator.userAgent).slice(0,16)||"kreatel"===e.util.trim(navigator.userAgent).slice(-7).toLowerCase())return!0;
var d=navigator.userAgent.toLowerCase().match(/.+android ([0-9]{1,2})/i),d=parseInt(d&&d[0]||-1,10);return!isNaN(d)&&-1<d&&3>d?!0:!1}}};e.util.now();(function(){var d=navigator.userAgent.toLowerCase(),d=/(chrome)[ \/]([\w.]+)/.exec(d)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(d)||/(msie) ([\w.]+)/.exec(d)||/(trident)(?:.*? rv:([\w.]+)|)/.exec(d)||0>d.indexOf("android")&&/version\/(.+) (safari)/.exec(d)||0>d.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(d)||[];"safari"===d[2]&&(d[2]=
d[1],d[1]="safari");e.util.browser[d[1]||""]=!0;e.util.browser.version=d[2]||"0";e.util.browser.vmajor=e.util.browser.version.split(".")[0];e.util.browser.trident&&(e.util.browser.msie=!0);if(e.util.browser.msie||e.util.browser.mozilla&&1===+e.util.browser.version.split(".")[0])e.util.storage=!1})();e.util.on(window,"unload",function(d){e.util.debug(new Date+" Atmosphere: unload event");e.unsubscribe()});e.util.on(window,"beforeunload",function(d){e.util.debug(new Date+" Atmosphere: beforeunload event");
e._beforeUnloadState=!0;setTimeout(function(){e.util.debug(new Date+" Atmosphere: beforeunload event timeout reached. Reset _beforeUnloadState flag");e._beforeUnloadState=!1},5E3)});e.util.on(window,"keypress",function(d){(27===d.charCode||27===d.keyCode)&&d.preventDefault&&d.preventDefault()});e.util.on(window,"offline",function(){e.util.debug(new Date+" Atmosphere: offline event");F=!0;if(0<p.length)for(var d=[].concat(p),k=0;k<d.length;k++){var g=d[k];g.request.handleOnlineOffline&&(g.close(),
clearTimeout(g.response.request.id),g.heartbeatTimer&&clearTimeout(g.heartbeatTimer))}});e.util.on(window,"online",function(){e.util.debug(new Date+" Atmosphere: online event");if(0<p.length)for(var d=0;d<p.length;d++)p[d].request.handleOnlineOffline&&(p[d].init(),p[d].execute());F=!1});return e});