summaryrefslogtreecommitdiffstats
path: root/WebContent
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2013-02-27 14:33:04 +0200
committerVaadin Code Review <review@vaadin.com>2013-04-04 12:46:42 +0000
commit69def694d5d98f518ad08c039195fd2ac8781d2f (patch)
tree8ec221cf013607180bf08b65ea189d44cd9dda49 /WebContent
parent008d51dba378c2feb57bd5d30550561567f3f91a (diff)
downloadvaadin-framework-69def694d5d98f518ad08c039195fd2ac8781d2f.tar.gz
vaadin-framework-69def694d5d98f518ad08c039195fd2ac8781d2f.zip
Server push (#111)
* Asynchronous bidirectional communication * Use Atmosphere as a backend * Use websockets if available, fallback to HTTP streaming * Push mode (disabled, manual, automatic) * Configurable via servlet parameter pushMode * Disabled: The default; regular AJAX communication * Manual: Need explicit UI.push() call * Automatic: push all UIs in session when lock released * UI.push() * Push pending state and RPC to client asynchronously * Must hold session lock when invoking Change-Id: Idb5978ac81f7ff1e66665df4e3f96e29e4c419d4
Diffstat (limited to 'WebContent')
-rw-r--r--WebContent/VAADIN/atmosphere.min.js12
-rw-r--r--WebContent/VAADIN/portal.min.js9
2 files changed, 21 insertions, 0 deletions
diff --git a/WebContent/VAADIN/atmosphere.min.js b/WebContent/VAADIN/atmosphere.min.js
new file mode 100644
index 0000000000..64f6604951
--- /dev/null
+++ b/WebContent/VAADIN/atmosphere.min.js
@@ -0,0 +1,12 @@
+/*
+ * Atmosphere.js
+ * https://github.com/Atmosphere/atmosphere
+ *
+ * Requires Portal 1.0
+ * https://github.com/flowersinthesand/portal
+ *
+ * Copyright 2012-2013, Donghwan Kim
+ * Licensed under the Apache License, Version 2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+(function(){function l(a,b){var c,f,g=b.headers||{};if(b.readResponsesHeaders)for(c in b.lastTimestamp=(a.getResponseHeader("X-Cache-Date")||"").split(" ").pop(),b.uuid=(a.getResponseHeader("X-Atmosphere-tracking-id")||"").split(" ").pop(),g)(f=a.getResponseHeader(c))&&(g[c]=f)}function m(a,b){var c,f,g=b.headers||{};b.dropAtmosphereHeaders||(a.setRequestHeader("X-Atmosphere-Framework",n),a.setRequestHeader("X-Atmosphere-Transport",b.transport),a.setRequestHeader("X-Cache-Date",b.lastTimestamp||0), b.trackMessageLength&&a.setRequestHeader("X-Atmosphere-TrackMessageSize","true"),b.contentType&&a.setRequestHeader("Content-Type",b.contentType),a.setRequestHeader("X-Atmosphere-tracking-id",b.uuid));for(c in g)f=g[c],(f=portal.support.isFunction(f)?f.call(null,a,b):f)&&a.setRequestHeader(c,f)}var n="1.1",k={},p=portal.support.now();k.subscribe=function(a){a=new k.AtmosphereRequest(a);a.open();return a};k.unsubscribe=portal.finalize;k.AtmosphereRequest=function(a){var b,c;a=portal.support.extend({url:"", connectTimeout:-1,reconnectInterval:0,timeout:3E5,method:"GET",fallbackMethod:"GET",headers:{},maxRequest:-1,transport:"long-polling",fallbackTransport:"streaming",dispatchUrl:null,webSocketPathDelimiter:"@@",webSocketBinaryType:null,enableXDR:!1,rewriteURL:!1,attachHeadersAsQueryString:!0,withCredentials:!1,trackMessageLength:!1,messageDelimiter:"|",shared:!1,lastTimestamp:0,readResponsesHeaders:!0,dropAtmosphereHeaders:!0,contentType:"",uuid:0,executeCallbackBeforeReconnect:!1},a);this.open=function(){function f(){g(); j=setTimeout(function(){b.fire("close","idletimeout")},a.timeout)}function g(){clearTimeout(j)}function h(a){return{"long-polling":"longpoll",streaming:"stream",jsonp:"longpolljsonp",sse:"sse",websocket:"ws",session:"session",test:"test"}[a]}var j;b=portal.open(a.url,{atrequest:a,method:a.method,transports:[h(a.transport)],timeout:a.connectTimeout,credentials:a.withCredentials,sharing:a.shared,params:a.headers,longpollTest:!1,urlBuilder:function(b,d){if(!a.attachHeadersAsQueryString)return b;delete d.id; delete d.transport;delete d.heartbeat;delete d.lastEventId;portal.support.extend(d,{"X-Atmosphere-tracking-id":a.uuid,"X-Atmosphere-Framework":n,"X-Atmosphere-Transport":a.transport,"X-Cache-Date":a.lastTimestamp||0});a.trackMessageLength&&(d["X-Atmosphere-TrackMessageSize"]=!0);a.contentType&&(d["Content-Type"]=a.contentType);return b+(/\?/.test(b)?"&":"?")+portal.support.param(d)},reconnect:function(b,d){return-1===a.maxRequest||d<a.maxRequest?a.reconnectInterval:!1},xdrURL:a.enableXDR&&function(e){return(a.rewriteURL|| portal.defaults.xdrURL||function(){}).call(a.rewriteURL?window:b,e)||e},inbound:function(e){var d,c,j=[];0<a.timeout&&f();if(a.trackMessageLength){b.data("data")&&(e=b.data("data")+e);d=0;for(c=e.indexOf(a.messageDelimiter);-1!==c;){d=e.substring(d,c);e=e.substring(c+a.messageDelimiter.length,e.length);if(!e||e.length<d)break;c=e.indexOf(a.messageDelimiter);j.push(e.substring(0,d))}b.data("data",!j.length||-1!==c&&e&&d!==e.length?d+a.messageDelimiter+e:"")}else j.push(e);for(e=0;e<j.length;e++)j[e]= {type:"message",data:j[e]};return j},outbound:function(b){0<a.timeout&&f();return b.data},streamParser:function(a){return[a.replace(/^\s+/g,"")]},initIframe:function(a){var b;b=a.contentDocument||a.contentWindow.document;if(!b.body||!b.body.firstChild||"pre"!==b.body.firstChild.nodeName.toLowerCase())a=b.head||b.getElementsByTagName("head")[0]||b.documentElement||b,b=b.createElement("script"),b.text="document.write('<plaintext>')",a.insertBefore(b,a.firstChild),a.removeChild(b)}});b.on({connecting:function(){b.data("t1", {ws:"websocket",sse:"sse",streamxhr:"streaming",streamxdr:"streaming",streamiframe:"streaming",longpollajax:"long-polling",longpollxdr:"long-polling",longpolljsonp:"jsonp",session:"session",test:"test"}[b.data("transport")])},open:function(){var e={status:200,responseBody:"",headers:[],state:"messageReceived",transport:b.data("t1"),error:null,request:a};0<a.timeout&&(f(),b.one("close",g));if(c){if(e.state="re-opening",a.onReconnect)a.onReconnect(a,e)}else{e.state="opening";if(a.onOpen)a.onOpen(e); c=!0}a.callback&&a.callback(e)},message:function(c){var d={status:200,responseBody:c,headers:[],state:"messageReceived",transport:b.data("t1"),error:null,request:a};b.data("lastData",c);if(a.onMessage)a.onMessage(d);a.callback&&a.callback(d)},close:function(e){var d={status:200,responseBody:"",headers:[],state:"messageReceived",transport:b.data("t1"),error:null,request:a};switch(e){case "aborted":d.status=408;d.state="unsubscribe";break;case "done":case "timeout":d.status=!c?501:200;d.state="closed"; break;case "error":d.status=500;d.state="error";break;case "notransport":if(a.onTransportFailure)a.onTransportFailure(e,a);a.method=a.fallbackMethod;a.transport=a.fallbackTransport;b.option("method",a.method);b.option("transports",[h(a.transport)])}if("error"===e){if(a.onError)a.onError(d)}else if(a.onClose)a.onClose(d);a.callback&&a.callback(d);a.executeCallbackBeforeReconnect&&(b.fire("message",b.data("lastData")),b.option("method",a.method),b.option("transports",[h(a.transport)]))},waiting:function(){a.executeCallbackBeforeReconnect|| b.fire("message",b.data("lastData"))},session:function(c){if(c.from!==b.option("id")&&a.onLocalMessage)a.onLocalMessage(c.message)}})};this.push=function(a,c){var h=b.option("dispatchUrl");b.option("dispatchUrl",c);b.send("message",a);b.option("dispatchUrl",h)};this.pushLocal=function(a){b.broadcast("session",{from:b.option("id"),data:a})}};portal.support.extend(portal.transports,{ws:function(a,b){var c,f,g=window.WebSocket||window.MozWebSocket;if(g)return{feedback:!0,open:function(){var h=portal.support.getAbsoluteURL(a.data("url")).replace(/^http/, "ws");a.data("url",h);c=new g(h);b.atrequest.webSocketBinaryType&&(c.binaryType=b.atrequest.webSocketBinaryType);c.onopen=function(b){a.data("event",b).fire("open")};c.onmessage=function(b){a.data("event",b)._fire(b.data)};c.onerror=function(b){a.data("event",b).fire("close",f?"aborted":"error")};c.onclose=function(b){a.data("event",b).fire("close",f?"aborted":b.wasClean?"done":"error")}},send:function(a){var f=b.atrequest.dispatchUrl,e=b.atrequest.webSocketPathDelimiter;console.log(b.atrequest); c.send((f?e+f+e:"")+a)},close:function(){f=!0;c.close()}}},httpbase:function(a,b){function c(){h.length?f(b.url+(b.dispatchUrl||""),h.shift()):g=!1}var f,g,h=[];f=!b.crossDomain||portal.support.corsable?function(a,e){var d=portal.support.xhr();d.onreadystatechange=function(){4===d.readyState&&(l(d,b.atrequest),c())};d.open("POST",a);m(d,b.atrequest);portal.support.corsable&&(d.withCredentials=b.credentials);d.send(e)}:window.XDomainRequest&&b.xdrURL&&b.xdrURL.call(a,"t")?function(f,e){var d=new window.XDomainRequest; d.onload=d.onerror=c;d.open("POST",b.xdrURL.call(a,f));d.send(e)}:function(a,b){var d=document.createElement("form");d.action=a;d.target="socket-"+ ++p;d.method="POST";d.enctype=d.encoding="text/plain";d.acceptCharset="UTF-8";d.style.display="none";d.innerHTML='<textarea name="data"></textarea><iframe name="'+d.target+'"></iframe>';d.firstChild.value=b;portal.support.on(d.lastChild,"load",function(){document.body.removeChild(d);c()});document.body.appendChild(d);d.submit()};return{send:function(a){h.push(a); g||(g=!0,c())}}},streamxhr:function(a,b){var c;if(!(portal.support.browser.msie&&10>+portal.support.browser.version||b.crossDomain&&!portal.support.corsable))return portal.support.extend(portal.transports.httpbase(a,b),{open:function(){var f;c=portal.support.xhr();c.onreadystatechange=function(){function g(){var b=a.data("index"),f=c.responseText.length;b?f>b&&a._fire(c.responseText.substring(b,f),!0):a.fire("open")._fire(c.responseText,!0);a.data("index",f)}2===c.readyState?l(c,b.atrequest):3=== c.readyState&&200===c.status?portal.support.browser.opera&&!f?f=portal.support.iterate(g):g():4===c.readyState&&(f&&f(),a.fire("close",200===c.status?"done":"error"))};c.open("GET",a.data("url"));portal.support.corsable&&(c.withCredentials=b.credentials);m(c,b.atrequest);c.send(null)},close:function(){c.abort()}})},longpollajax:function(a,b){var c,f,g=0;if(!b.crossDomain||portal.support.corsable)return portal.support.extend(portal.transports.httpbase(a,b),{open:function(){function h(){var j=a.buildURL(!g? "open":"poll",{count:++g});a.data("url",j);c=portal.support.xhr();c.onreadystatechange=function(){var e;!f&&4===c.readyState&&(200===c.status?(l(c,b.atrequest),(e=c.responseText)||1===g?(1===g&&a.fire("open"),e&&a._fire(e),h()):a.fire("close","done")):a.fire("close","error"))};c.open("GET",j);m(c,b.atrequest);portal.support.corsable&&(c.withCredentials=b.credentials);c.send(null)}b.longpollTest?h():setTimeout(function(){a.fire("open");h()},50)},close:function(){f=!0;c.abort()}})}});portal.support.on(window, "keypress",function(a){27===a.which&&a.preventDefault()});window.atmosphere=k})(); \ No newline at end of file
diff --git a/WebContent/VAADIN/portal.min.js b/WebContent/VAADIN/portal.min.js
new file mode 100644
index 0000000000..83228d205c
--- /dev/null
+++ b/WebContent/VAADIN/portal.min.js
@@ -0,0 +1,9 @@
+/*
+ * Portal v1.0
+ * http://github.com/flowersinthesand/portal
+ *
+ * Copyright 2011-2013, Donghwan Kim
+ * Licensed under the Apache License, Version 2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
+ */
+(function(){function z(a){var c=[],b,e,g,d,h,m,l=function(b,n){n=n||[];e=!a||[b,n];g=!0;m=d||0;d=0;for(h=c.length;m<h;m++)c[m].apply(b,n);g=!1};return{add:function(a){var n=c.length;c.push(a);g?h=c.length:!b&&(e&&!0!==e)&&(d=n,l(e[0],e[1]))},remove:function(a){var b;for(b=0;b<c.length;b++)if(a===c[b]||a.guid&&a.guid===c[b].guid)g&&b<=h&&(h--,b<=m&&m--),c.splice(b--,1)},fire:function(c,d){!b&&(!g&&(!a||!e))&&l(c,d)},lock:function(){b=!0},locked:function(){return!!b},unlock:function(){b=e=g=d=h=m=void 0}}} var v,w,e={},q={},B=[],x=Object.prototype.toString,C=Object.prototype.hasOwnProperty,y=Array.prototype.slice;e.support={now:function(){return(new Date).getTime()},isArray:function(a){return"[object Array]"===x.call(a)},isBinary:function(a){a=x.call(a);return"[object Blob]"===a||"[object ArrayBuffer]"===a},isFunction:function(a){return"[object Function]"===x.call(a)},getAbsoluteURL:function(a){var c=document.createElement("div");c.innerHTML='<a href="'+a+'"/>';return encodeURI(decodeURI(c.firstChild.href))}, iterate:function(a){var c;(function f(){c=setTimeout(function(){!1!==a()&&f()},1)})();return function(){clearTimeout(c)}},each:function(a,c){var b;for(b=0;b<a.length;b++)c(b,a[b])},extend:function(a){var c,b,e;for(c=1;c<arguments.length;c++)if(null!=(b=arguments[c]))for(e in b)a[e]=b[e];return a},on:function(a,c,b){a.addEventListener?a.addEventListener(c,b,!1):a.attachEvent&&a.attachEvent("on"+c,b)},off:function(a,c,b){a.removeEventListener?a.removeEventListener(c,b,!1):a.detachEvent&&a.detachEvent("on"+ c,b)},param:function(a){function c(a,b){b=e.support.isFunction(b)?b():null==b?"":b;g.push(encodeURIComponent(a)+"="+encodeURIComponent(b))}function b(a,h){var f;if(e.support.isArray(h))e.support.each(h,function(e,h){/\[\]$/.test(a)?c(a,h):b(a+"["+("object"===typeof h?e:"")+"]",h)});else if("[object Object]"===x.call(h))for(f in h)b(a+"["+f+"]",h[f]);else c(a,h)}var f,g=[];for(f in a)b(f,a[f]);return g.join("&").replace(/%20/g,"+")},xhr:function(){try{return new window.XMLHttpRequest}catch(a){try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(c){}}}, parseJSON:function(a){return!a?null:window.JSON&&window.JSON.parse?window.JSON.parse(a):(new Function("return "+a))()},stringifyJSON:function(a){function c(a){return'"'+a.replace(e,function(a){var b=g[a];return"string"===typeof b?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"'}function b(a){return 10>a?"0"+a:a}var e=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,g={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f", "\r":"\\r",'"':'\\"',"\\":"\\\\"};return window.JSON&&window.JSON.stringify?window.JSON.stringify(a):function h(a,e){var f,n,g,k=e[a];g=typeof k;k&&("object"===typeof k&&"function"===typeof k.toJSON)&&(k=k.toJSON(a),g=typeof k);switch(g){case "string":return c(k);case "number":return isFinite(k)?String(k):"null";case "boolean":return String(k);case "object":if(!k)return"null";switch(x.call(k)){case "[object Date]":return isFinite(k.valueOf())?'"'+k.getUTCFullYear()+"-"+b(k.getUTCMonth()+1)+"-"+b(k.getUTCDate())+ "T"+b(k.getUTCHours())+":"+b(k.getUTCMinutes())+":"+b(k.getUTCSeconds())+'Z"':"null";case "[object Array]":n=k.length;g=[];for(f=0;f<n;f++)g.push(h(f,k)||"null");return"["+g.join(",")+"]";default:g=[];for(f in k)C.call(k,f)&&(n=h(f,k))&&g.push(c(f)+":"+n);return"{"+g.join(",")+"}"}}}("",{"":a})},browser:{},storage:!(!window.localStorage||!window.StorageEvent)};e.support.corsable="withCredentials"in e.support.xhr();v=e.support.now();var t=navigator.userAgent.toLowerCase(),t=/(chrome)[ \/]([\w.]+)/.exec(t)|| /(webkit)[ \/]([\w.]+)/.exec(t)||/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(t)||/(msie) ([\w.]+)/.exec(t)||0>t.indexOf("compatible")&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(t)||[];e.support.browser[t[1]||""]=!0;e.support.browser.version=t[2]||"0";if(e.support.browser.msie||e.support.browser.mozilla&&"1"===e.support.browser.version.split(".")[0])e.support.storage=!1;e.find=function(a){var c;if(!arguments.length){for(c in q)if(q[c])return q[c];return null}return q[e.support.getAbsoluteURL(a)]||null};e.open= function(a,c){var b=a=e.support.getAbsoluteURL(a),f,g=a,d,h,m,l={},A=0,n={},r=[],k,u,s,p={};f=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/.exec(g.toLowerCase());var j={option:function(a,b){if(void 0===b)return d[a];d[a]=b;return this},data:function(a,b){if(void 0===b)return p[a];p[a]=b;return this},state:function(){return m},on:function(a,b){var c;if("object"===typeof a){for(c in a)j.on(c,a[c]);return this}c=l[a];if(!c){if(l.message.locked())return this;c=l[a]=z();c.order=l.message.order}c.add(b); return this},off:function(a,b){var c=l[a];c&&c.remove(b);return this},one:function(a,b){function c(){j.off(a,c);b.apply(j,arguments)}b.guid=b.guid||v++;c.guid=b.guid;return j.on(a,c)},fire:function(a){var b=l[a];b&&b.fire(j,y.call(arguments,1));return this},open:function(){var a,b,c=function(){var a,c;if(!b){b=!0;for(a=p.candidates=y.call(d.transports);!h&&a.length;)c=a.shift(),p.transport=c,p.url=j.buildURL("open"),h=e.transports[c](j,d);s&&s++;h?(j.fire("connecting"),h.open()):j.fire("close","notransport")}}, f=function(){b||(b=!0,j.fire("close","canceled"))};k&&clearTimeout(k);p={};for(a in l)l[a].unlock();h=void 0;m="preparing";d.sharing&&(p.transport="session",h=e.transports.session(j,d));h?c():d.prepare.call(j,c,f,d);return this},send:function(a,b,c,f){var g;if("opened"!==m)return r.push(arguments),this;g={id:++A,socket:d.id,type:a,data:b,reply:!(!c&&!f)};g.reply&&("session"===p.transport?(g.doneCallback=c,g.failCallback=f):n[A]={done:c,fail:f});h.send(e.support.isBinary(b)?b:d.outbound.call(j,g)); return this},close:function(){var a,b;d.reconnect=!1;k&&clearTimeout(k);if(w||!h||!h.feedback)j.fire("close",w?"error":"aborted"),d.notifyAbort&&"session"!==p.transport&&(b=document.head||document.getElementsByTagName("head")[0]||document.documentElement,a=document.createElement("script"),a.async=!1,a.src=j.buildURL("abort"),a.onload=a.onreadystatechange=function(){if(!a.readyState||/loaded|complete/.test(a.readyState))a.onload=a.onreadystatechange=null,a.parentNode&&a.parentNode.removeChild(a)}, b.insertBefore(a,b.firstChild));h&&h.close();return this},broadcast:function(a,b){var c=p.broadcastable;c&&c.broadcast({type:"fire",data:{type:a,data:b}});return this},_fire:function(a,b){var c;if(b){for(a=d.streamParser.call(j,a);a.length;)j._fire(a.shift());return this}e.support.isBinary(a)?c=[{type:"message",data:a}]:(c=d.inbound.call(j,a),c=null==c?[]:!e.support.isArray(c)?[c]:c);p.lastEventIds=[];e.support.each(c,function(a,b){var c,e=[b.type,b.data];d.lastEventId=b.id;p.lastEventIds.push(b.id); b.reply&&e.push(function(a){c||(c=!0,j.send("reply",{id:b.id,data:a}))});j.fire.apply(j,e).fire("_message",e)});return this},buildURL:function(a,b){var c="open"===a?{transport:p.transport,heartbeat:d.heartbeat,lastEventId:d.lastEventId}:"poll"===a?{transport:p.transport,lastEventIds:p.lastEventIds&&p.lastEventIds.join(","),lastEventId:d.lastEventId}:{};e.support.extend(c,{id:d.id,_:v++},d.params&&d.params[a],b);return d.urlBuilder.call(j,g,c,a)}};d=e.support.extend({},e.defaults,c);c&&c.transports&& (d.transports=y.call(c.transports));d.url=g;d.id=d.idGenerator.call(j);d.crossDomain=!(!f||!(f[1]!=location.protocol||f[2]!=location.hostname||(f[3]||("http:"===f[1]?80:443))!=(location.port||("http:"===location.protocol?80:443))));e.support.each(["connecting","open","message","close","waiting"],function(a,b){l[b]=z("message"!==b);l[b].order=a;var c=j[b],d=function(a){return j.on(b,a)};j[b]=!c?d:function(a){return(e.support.isFunction(a)?d:c).apply(this,arguments)}});j.on({connecting:function(){function a(){clearTimeout(b)} m="connecting";var b;0<d.timeout&&(b=setTimeout(function(){h.close();j.fire("close","timeout")},d.timeout),j.one("open",a).one("close",a));if(d.sharing&&"session"!==p.transport){var c=function(a){a=e.support.parseJSON(a);var b=a.data;if(a.target){if("p"===a.target)switch(a.type){case "send":j.send(b.type,b.data,b.doneCallback,b.failCallback);break;case "close":j.close()}}else"fire"===a.type&&j.fire(b.type,b.data)},f=function(a){k.broadcast({target:"c",type:"message",data:a})},n=function(){document.cookie= encodeURIComponent(r)+"="+encodeURIComponent(e.support.stringifyJSON({ts:e.support.now()+1,heir:(k.get("children")||[])[0]}))},l,k,r="socket-"+g,s={storage:function(){if(e.support.storage){var a=window.localStorage;return{init:function(){function b(a){a.key===r&&a.newValue&&c(a.newValue)}e.support.on(window,"storage",b);j.one("close",function(){e.support.off(window,"storage",b);j.one("close",function(){a.removeItem(r);a.removeItem(r+"-opened");a.removeItem(r+"-children")})})},broadcast:function(b){var d= e.support.stringifyJSON(b);a.setItem(r,d);setTimeout(function(){c(d)},50)},get:function(b){return e.support.parseJSON(a.getItem(r+"-"+b))},set:function(b,c){a.setItem(r+"-"+b,e.support.stringifyJSON(c))}}}},windowref:function(){var a=r.replace(/\W/g,""),b=document.getElementById(a),d;b||(b=document.createElement("div"),b.id=a,b.style.display="none",b.innerHTML='<iframe name="'+a+'" />',document.body.appendChild(b));d=b.firstChild.contentWindow;return{init:function(){d.callbacks=[c];d.fire=function(a){var b; for(b=0;b<d.callbacks.length;b++)d.callbacks[b](a)}},broadcast:function(a){!d.closed&&d.fire&&d.fire(e.support.stringifyJSON(a))},get:function(a){return!d.closed?d[a]:null},set:function(a,b){d.closed||(d[a]=b)}}}};k=s.storage()||s.windowref();k.init();p.broadcastable=k;k.set("children",[]);k.set("opened",!1);n();l=setInterval(n,1E3);j.on("_message",f).one("open",function(){k.set("opened",!0);k.broadcast({target:"c",type:"open"})}).one("close",function(a){clearInterval(l);document.cookie=encodeURIComponent(r)+ "=; expires=Thu, 01 Jan 1970 00:00:00 GMT";k.broadcast({target:"c",type:"close",data:{reason:a,heir:!w?d.id:(k.get("children")||[])[0]}});j.off("_message",f)})}},open:function(){function a(){c=setTimeout(function(){j.send("heartbeat").one("heartbeat",function(){b();a()});c=setTimeout(function(){h.close();j.fire("close","error")},d._heartbeat)},d.heartbeat-d._heartbeat)}function b(){clearTimeout(c)}m="opened";var c;d.heartbeat>d._heartbeat&&(a(),j.one("close",b));l.connecting.lock();for(k=u=s=null;r.length;)j.send.apply(j, r.shift())},close:function(){m="closed";var a,b,c=l.close.order;for(a in l)b=l[a],b.order<c&&b.lock();if(d.reconnect)j.one("close",function(){s=s||1;u=d.reconnect.call(j,u,s);!1!==u&&(k=setTimeout(function(){j.open()},u),j.fire("waiting",u,s))})},waiting:function(){m="waiting"},reply:function(a){var b=a.id,c=a.data;a=a.exception;var d=n[b];if(d&&(a=a?d.fail:d.done))e.support.isFunction(a)?a.call(j,c):j.fire(a,c).fire("_message",[a,c]),delete n[b]}});f=j.open();q[b]=f;return e.find(a)};e.defaults= {transports:["ws","sse","stream","longpoll"],timeout:!1,heartbeat:!1,lastEventId:0,sharing:!1,prepare:function(a){a()},reconnect:function(a){return 2*(a||250)},idGenerator:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var c=16*Math.random()|0;return("x"===a?c:c&3|8).toString(16)})},urlBuilder:function(a,c,b){return a+(/\?/.test(a)?"&":"?")+"when="+b+"&"+e.support.param(c)},inbound:e.support.parseJSON,outbound:e.support.stringifyJSON,credentials:!1,notifyAbort:!1, xdrURL:function(a){var c=/(?:^|; )(JSESSIONID|PHPSESSID)=([^;]*)/.exec(document.cookie);switch(c&&c[1]){case "JSESSIONID":return a.replace(/;jsessionid=[^\?]*|(\?)|$/,";jsessionid="+c[2]+"$1");case "PHPSESSID":return a.replace(/\?PHPSESSID=[^&]*&?|\?|$/,"?PHPSESSID="+c[2]+"&").replace(/&$/,"");default:return!1}},streamParser:function(a){var c=/\r\n|[\r\n]/g,b=[],e=this.data("data"),g=[],d=0,h;for(a=a.replace(/^\s+/g,"");h=c.exec(a);)b.push(a.substring(d,h.index)),d=h.index+h[0].length;b.push(a.length=== d?"":a.substring(d));e||(e=[],this.data("data",e));for(d=0;d<b.length;d++)(a=b[d])?/^data:\s/.test(a)?e.push(a.substring(6)):e[e.length-1]+=a:(g.push(e.join("\n")),e=[],this.data("data",e));return g},_heartbeat:5E3,longpollTest:!0};e.transports={session:function(a,c){function b(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 f(b){b=e.support.parseJSON(b);var d=b.data;if(b.target){if("c"===b.target)switch(b.type){case "open":a.fire("open");break;case "close":h|| (h=!0,"aborted"===d.reason?a.close():d.heir===c.id?a.fire("close",d.reason):setTimeout(function(){a.fire("close",d.reason)},100));break;case "message":if("connecting"===a.state())a.one("open",function(){a.fire.apply(a,d)});else a.fire.apply(a,d)}}else"fire"===b.type&&a.fire(d.type,d.data)}function g(){var a=RegExp("(?:^|; )("+encodeURIComponent(l)+")=([^;]*)").exec(document.cookie);if(a)return e.support.parseJSON(decodeURIComponent(a[2]))}var d,h,m,l="socket-"+c.url,q={storage:function(){function d(a){return e.support.parseJSON(h.getItem(l+ "-"+a))}if(e.support.storage){var h=window.localStorage;return{init:function(){function g(a){a.key===l&&a.newValue&&f(a.newValue)}var m=d("children").concat([c.id]);h.setItem(l+"-children",e.support.stringifyJSON(m));e.support.on(window,"storage",g);a.one("close",function(){var a=d("children");e.support.off(window,"storage",g);a&&b(a,c.id)&&h.setItem(l+"-children",e.support.stringifyJSON(a))});return d("opened")},broadcast:function(a){var b=e.support.stringifyJSON(a);h.setItem(l,b);setTimeout(function(){f(b)}, 50)}}}},windowref:function(){var d=window.open("",l.replace(/\W/g,""));if(d&&!d.closed&&d.callbacks)return{init:function(){d.callbacks.push(f);d.children.push(c.id);a.one("close",function(){h||(b(d.callbacks,f),b(d.children,c.id))});return d.opened},broadcast:function(a){!d.closed&&d.fire&&d.fire(e.support.stringifyJSON(a))}}}};if((d=g())&&!(1E3<e.support.now()-d.ts))if(m=q.storage()||q.windowref())return a.data("broadcastable",m),{open:function(){var b,h=c.timeout,l=c.heartbeat,q=c.outbound;c.timeout= c.heartbeat=!1;c.outbound=function(a){return a};b=setInterval(function(){var a=d;d=g();(!d||a.ts===d.ts)&&f(e.support.stringifyJSON({target:"c",type:"close",data:{reason:"error",heir:a.heir}}))},1E3);a.one("close",function(){clearInterval(b);c.timeout=h;c.heartbeat=l;c.outbound=q});m.init()&&setTimeout(function(){a.fire("open")},50)},send:function(a){m.broadcast({target:"p",type:"send",data:a})},close:function(){w||m.broadcast({target:"p",type:"close"})}}},ws:function(a){var c,b,f=window.WebSocket|| window.MozWebSocket;if(f)return{feedback:!0,open:function(){var g=e.support.getAbsoluteURL(a.data("url")).replace(/^http/,"ws");a.data("url",g);c=new f(g);c.onopen=function(b){a.data("event",b).fire("open")};c.onmessage=function(b){a.data("event",b)._fire(b.data)};c.onerror=function(c){a.data("event",c).fire("close",b?"aborted":"error")};c.onclose=function(c){a.data("event",c).fire("close",b?"aborted":c.wasClean?"done":"error")}},send:function(a){c.send(a)},close:function(){b=!0;c.close()}}},httpbase:function(a, c){function b(){d.length?f(c.url,d.shift()):g=!1}var f,g,d=[];f=!c.crossDomain||e.support.corsable?function(a,d){var f=e.support.xhr();f.onreadystatechange=function(){4===f.readyState&&b()};f.open("POST",a);f.setRequestHeader("Content-Type","text/plain; charset=UTF-8");e.support.corsable&&(f.withCredentials=c.credentials);f.send("data="+d)}:window.XDomainRequest&&c.xdrURL&&c.xdrURL.call(a,"t")?function(d,e){var f=new window.XDomainRequest;f.onload=f.onerror=b;f.open("POST",c.xdrURL.call(a,d));f.send("data="+ e)}:function(a,c){var d=document.createElement("form");d.action=a;d.target="socket-"+ ++v;d.method="POST";d.enctype=d.encoding="text/plain";d.acceptCharset="UTF-8";d.style.display="none";d.innerHTML='<textarea name="data"></textarea><iframe name="'+d.target+'"></iframe>';d.firstChild.value=c;e.support.on(d.lastChild,"load",function(){document.body.removeChild(d);b()});document.body.appendChild(d);d.submit()};return{send:function(a){d.push(a);g||(g=!0,b())}}},sse:function(a,c){var b,f=window.EventSource; if(f){if(c.crossDomain)try{if(!e.support.corsable||!("withCredentials"in new f("about:blank")))return}catch(g){return}return e.support.extend(e.transports.httpbase(a,c),{open:function(){var d=a.data("url");b=!c.crossDomain?new f(d):new f(d,{withCredentials:c.credentials});b.onopen=function(b){a.data("event",b).fire("open")};b.onmessage=function(b){a.data("event",b)._fire(b.data)};b.onerror=function(c){b.close();a.data("event",c).fire("close","done")}},close:function(){b.close()}})}},stream:function(a){a.data("candidates").unshift("streamxhr", "streamxdr","streamiframe")},streamxhr:function(a,c){var b;if(!(e.support.browser.msie&&10>+e.support.browser.version||c.crossDomain&&!e.support.corsable))return e.support.extend(e.transports.httpbase(a,c),{open:function(){var f;b=e.support.xhr();b.onreadystatechange=function(){function c(){var d=a.data("index"),e=b.responseText.length;d?e>d&&a._fire(b.responseText.substring(d,e),!0):a.fire("open")._fire(b.responseText,!0);a.data("index",e)}3===b.readyState&&200===b.status?e.support.browser.opera&& !f?f=e.support.iterate(c):c():4===b.readyState&&(f&&f(),a.fire("close",200===b.status?"done":"error"))};b.open(c.method||"GET",a.data("url"));e.support.corsable&&(b.withCredentials=c.credentials);b.send(null)},close:function(){b.abort()}})},streamiframe:function(a,c){var b,f,g=window.ActiveXObject;if(g&&!c.crossDomain){try{new g("htmlfile")}catch(d){return}return e.support.extend(e.transports.httpbase(a,c),{open:function(){var d,m;b=new g("htmlfile");b.open();b.close();d=b.createElement("iframe"); d.src=a.data("url");b.body.appendChild(d);m=d.contentDocument||d.contentWindow.document;f=e.support.iterate(function(){function b(){var a=g.cloneNode(!0);a.appendChild(m.createTextNode("."));a=a.innerText;return a.substring(0,a.length-1)}var g;if(m.firstChild){c.initIframe&&c.initIframe.call(a,d);g=m.body.lastChild;if(!g)return a.fire("close","error"),!1;a.fire("open")._fire(b(),!0);g.innerText="";f=e.support.iterate(function(){var c=b();c&&(g.innerText="",a._fire(c,!0));if("complete"===m.readyState)return a.fire("close", "done"),!1});return!1}})},close:function(){f();b.execCommand("Stop")}})}},streamxdr:function(a,c){var b,f=window.XDomainRequest;if(f&&c.xdrURL&&c.xdrURL.call(a,"t"))return e.support.extend(e.transports.httpbase(a,c),{open:function(){var e=c.xdrURL.call(a,a.data("url"));a.data("url",e);b=new f;b.onprogress=function(){var c=a.data("index"),e=b.responseText.length;c?a._fire(b.responseText.substring(c,e),!0):a.fire("open")._fire(b.responseText,!0);a.data("index",e)};b.onerror=function(){a.fire("close", "error")};b.onload=function(){a.fire("close","done")};b.open(c.method||"GET",e);b.send()},close:function(){b.abort()}})},longpoll:function(a){a.data("candidates").unshift("longpollajax","longpollxdr","longpolljsonp")},longpollajax:function(a,c){var b,f,g=0;if(!c.crossDomain||e.support.corsable)return e.support.extend(e.transports.httpbase(a,c),{open:function(){function d(){var h=a.buildURL(!g?"open":"poll",{count:++g});a.data("url",h);b=e.support.xhr();b.onreadystatechange=function(){var c;!f&&4=== b.readyState&&(200===b.status?(c=b.responseText)||1===g?(1===g&&a.fire("open"),c&&a._fire(c),d()):a.fire("close","done"):a.fire("close","error"))};b.open(c.method||"GET",h);e.support.corsable&&(b.withCredentials=c.credentials);b.send(null)}c.longpollTest?d():setTimeout(function(){a.fire("open");d()},50)},close:function(){f=!0;b.abort()}})},longpollxdr:function(a,c){var b,f=0,g=window.XDomainRequest;if(g&&c.xdrURL&&c.xdrURL.call(a,"t"))return e.support.extend(e.transports.httpbase(a,c),{open:function(){function d(){var e= c.xdrURL.call(a,a.buildURL(!f?"open":"poll",{count:++f}));a.data("url",e);b=new g;b.onload=function(){var c=b.responseText;c||1===f?(1===f&&a.fire("open"),c&&a._fire(c),d()):a.fire("close","done")};b.onerror=function(){a.fire("close","error")};b.open(c.method||"GET",e);b.send()}c.longpollTest?d():setTimeout(function(){a.fire("open");d()},50)},close:function(){b.abort()}})},longpolljsonp:function(a,c){var b,f,g=0,d=B.pop()||"socket_"+ ++v;return e.support.extend(e.transports.httpbase(a,c),{open:function(){function e(){var c= a.buildURL(!g?"open":"poll",{callback:d,count:++g}),l=document.head||document.getElementsByTagName("head")[0]||document.documentElement;a.data("url",c);b=document.createElement("script");b.async=!0;b.src=c;b.clean=function(){b.clean=b.onerror=b.onload=b.onreadystatechange=null;b.parentNode&&b.parentNode.removeChild(b)};b.onload=b.onreadystatechange=function(){if(!b.readyState||/loaded|complete/.test(b.readyState))b.clean(),f?(f=!1,e()):1===g?(a.fire("open"),e()):a.fire("close","done")};b.onerror= function(){b.clean();a.fire("close","error")};l.insertBefore(b,l.firstChild)}window[d]=function(b){f=!0;1===g&&a.fire("open");a._fire(b)};a.one("close",function(){window[d]=function(){};B.push(d)});c.longpollTest?e():setTimeout(function(){a.fire("open");e()},50)},close:function(){b.clean&&b.clean()}})}};e.finalize=function(){var a,c;for(a in q)c=q[a],"closed"!==c.state()&&c.close(),delete q[a]};e.support.on(window,"unload",function(){w=!0;e.finalize()});e.support.on(window,"online",function(){var a, c;for(a in q)c=q[a],"waiting"===c.state()&&c.open()});e.support.on(window,"offline",function(){var a,c;for(a in q)c=q[a],"opened"===c.state()&&c.fire("close","error")});window.portal=e})(); \ No newline at end of file