Skip to content
Browse files

Added socket.io wrapper class and rewrote use of socket in controller

  • Loading branch information...
1 parent be4eb0b commit 2b17b473f029db23a8d44bf7c6200077f93902a8 Nils Dehl committed
Showing with 147 additions and 46 deletions.
  1. +7 −0 .rockstarapps
  2. +106 −22 js/build/app.all.js
  3. +1 −1 js/build/app.all.js.min.js
  4. +1 −1 js/build/app.all.js.ycomp.js
  5. +32 −22 js/conrollers/Controller.Chat.js
View
7 .rockstarapps
@@ -11,6 +11,12 @@
+
+
+
+
+
+
<file name="js/build/app.all.js">
<min>true</min>
<comp>true</comp>
@@ -27,6 +33,7 @@
<file>js/lib/ext.util.md5.js</file>
<file>js/lib/socket.io.js</file>
<file>js/index.js</file>
+ <file>js/lib/App.util.Socketio.js</file>
<file>js/conrollers/Controller.Viewport.js</file>
<file>js/conrollers/Controller.Chat.js</file>
<file>js/conrollers/Controller.Config.js</file>
View
128 js/build/app.all.js
@@ -2109,6 +2109,80 @@ Ext.regApplication('App', {
*/
/*
+ * START OF FILE - /ST-Websocket-Mobile-Chat/js/lib/App.util.Socketio.js
+ */
+Ext.ns('App.util');
+/**
+ * Socket.io wrapper class
+ * @class App.util.Socketio
+ * @extends Ext.util.Observable
+ */
+App.util.Socketio = Ext.extend(Ext.util.Observable, {
+
+ constructor: function(host, options){
+
+ options = options || {};
+
+
+ App.util.Socketio.superclass.constructor.call(
+ this
+ );
+
+ this.socket = new io.Socket(host, options);
+ var that = this;
+
+ this.socket.on('connect', function(){
+ that.onConnect();
+ });
+ this.socket.on('message', function(data){
+ that.onMessage(data);
+ });
+ this.socket.on('close', function(){
+ that.onClose();
+ });
+ this.socket.on('disconnect', function(){
+ that.onDisconnect();
+ });
+
+ },
+
+ /**
+ * connect
+ */
+ connect: function() {
+ this.socket.connect();
+ },
+
+ disconnect: function(){
+ this.socket.disconnect();
+ },
+
+ send: function(message) {
+ this.socket.send(message);
+ },
+
+ onConnect: function() {
+ this.fireEvent('connect');
+ },
+
+ onDisconnect: function() {
+ this.fireEvent('disconnect');
+ },
+
+ onClose: function() {
+ this.fireEvent('close');
+ },
+
+ onMessage: function(message) {
+ this.fireEvent('message', message);
+ }
+});
+Ext.reg('App.util.Socketio', App.util.Socketio);
+/*
+ * END OF FILE - /ST-Websocket-Mobile-Chat/js/lib/App.util.Socketio.js
+ */
+
+/*
* START OF FILE - /ST-Websocket-Mobile-Chat/js/conrollers/Controller.Viewport.js
*/
/**
@@ -2205,40 +2279,50 @@ Ext.regController('Chat', {
*
*/
initSocketConnection: function() {
- var chatStore = new App.Store.Chat();
- var configStore = Ext.StoreMgr.get('ConfigStore');
- var settings = configStore.getAt(0);
- var user = {
- nickname: settings.get('nickname'),
- gravatar: settings.get('gravatar')
- };
+ this.chatStore = new App.Store.Chat();
+ this.configStore = Ext.StoreMgr.get('ConfigStore');
+ var settings = this.configStore.getAt(0);
- var socket = new io.Socket(settings.get('server'), {port: 4000});
- this.socket = socket;
+ this.socket = new App.util.Socketio(settings.get('server'), {port: 4000});
+ this.socket.connect();
- socket.connect();
-
- socket.on('connect',
- function() {
- socket.send(user);
- },
+ // Event Listener
+ this.socket.on(
+ 'connect',
+ this.registerUser,
this
);
-
- socket.on('message', function(message) {
- chatStore.add(message);
- });
+ this.socket.on(
+ 'message',
+ this.addMessageToChatStore,
+ this
+ );
App.on(
'newMsg',
- function(msg){
- this.socket.send(msg);
- },
+ this.sendMessageToServer,
this
);
},
+ sendMessageToServer: function(msg){
+ this.socket.send(msg);
+ },
+
+ addMessageToChatStore: function(message) {
+ this.chatStore.add(message);
+ },
+
+ registerUser: function() {
+ var settings = this.configStore.getAt(0);
+ var user = {
+ nickname: settings.get('nickname'),
+ gravatar: settings.get('gravatar')
+ };
+ this.socket.send(user);
+ },
+
/**
* Show chat view
*/
View
2 js/build/app.all.js.min.js
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
2 js/build/app.all.js.ycomp.js
@@ -1 +1 @@
-Ext.util.MD5=function(O,M,L,I){M=M||false;L=L||false;I=I||8;function G(P,S){var R=(P&65535)+(S&65535);var Q=(P>>16)+(S>>16)+(R>>16);return(Q<<16)|(R&65535)}function K(P,Q){return(P<<Q)|(P>>>(32-Q))}function C(U,R,Q,P,T,S){return G(K(G(G(R,U),G(P,S)),T),Q)}function H(R,Q,V,U,P,T,S){return C((Q&V)|((~Q)&U),R,Q,P,T,S)}function B(R,Q,V,U,P,T,S){return C((Q&U)|(V&(~U)),R,Q,P,T,S)}function J(R,Q,V,U,P,T,S){return C(Q^V^U,R,Q,P,T,S)}function F(R,Q,V,U,P,T,S){return C(V^(Q|(~U)),R,Q,P,T,S)}function E(Z,U){Z[U>>5]|=128<<((U)%32);Z[(((U+64)>>>9)<<4)+14]=U;var Y=1732584193;var X=-271733879;var W=-1732584194;var V=271733878;for(var R=0;R<Z.length;R+=16){var T=Y;var S=X;var Q=W;var P=V;Y=H(Y,X,W,V,Z[R+0],7,-680876936);V=H(V,Y,X,W,Z[R+1],12,-389564586);W=H(W,V,Y,X,Z[R+2],17,606105819);X=H(X,W,V,Y,Z[R+3],22,-1044525330);Y=H(Y,X,W,V,Z[R+4],7,-176418897);V=H(V,Y,X,W,Z[R+5],12,1200080426);W=H(W,V,Y,X,Z[R+6],17,-1473231341);X=H(X,W,V,Y,Z[R+7],22,-45705983);Y=H(Y,X,W,V,Z[R+8],7,1770035416);V=H(V,Y,X,W,Z[R+9],12,-1958414417);W=H(W,V,Y,X,Z[R+10],17,-42063);X=H(X,W,V,Y,Z[R+11],22,-1990404162);Y=H(Y,X,W,V,Z[R+12],7,1804603682);V=H(V,Y,X,W,Z[R+13],12,-40341101);W=H(W,V,Y,X,Z[R+14],17,-1502002290);X=H(X,W,V,Y,Z[R+15],22,1236535329);Y=B(Y,X,W,V,Z[R+1],5,-165796510);V=B(V,Y,X,W,Z[R+6],9,-1069501632);W=B(W,V,Y,X,Z[R+11],14,643717713);X=B(X,W,V,Y,Z[R+0],20,-373897302);Y=B(Y,X,W,V,Z[R+5],5,-701558691);V=B(V,Y,X,W,Z[R+10],9,38016083);W=B(W,V,Y,X,Z[R+15],14,-660478335);X=B(X,W,V,Y,Z[R+4],20,-405537848);Y=B(Y,X,W,V,Z[R+9],5,568446438);V=B(V,Y,X,W,Z[R+14],9,-1019803690);W=B(W,V,Y,X,Z[R+3],14,-187363961);X=B(X,W,V,Y,Z[R+8],20,1163531501);Y=B(Y,X,W,V,Z[R+13],5,-1444681467);V=B(V,Y,X,W,Z[R+2],9,-51403784);W=B(W,V,Y,X,Z[R+7],14,1735328473);X=B(X,W,V,Y,Z[R+12],20,-1926607734);Y=J(Y,X,W,V,Z[R+5],4,-378558);V=J(V,Y,X,W,Z[R+8],11,-2022574463);W=J(W,V,Y,X,Z[R+11],16,1839030562);X=J(X,W,V,Y,Z[R+14],23,-35309556);Y=J(Y,X,W,V,Z[R+1],4,-1530992060);V=J(V,Y,X,W,Z[R+4],11,1272893353);W=J(W,V,Y,X,Z[R+7],16,-155497632);X=J(X,W,V,Y,Z[R+10],23,-1094730640);Y=J(Y,X,W,V,Z[R+13],4,681279174);V=J(V,Y,X,W,Z[R+0],11,-358537222);W=J(W,V,Y,X,Z[R+3],16,-722521979);X=J(X,W,V,Y,Z[R+6],23,76029189);Y=J(Y,X,W,V,Z[R+9],4,-640364487);V=J(V,Y,X,W,Z[R+12],11,-421815835);W=J(W,V,Y,X,Z[R+15],16,530742520);X=J(X,W,V,Y,Z[R+2],23,-995338651);Y=F(Y,X,W,V,Z[R+0],6,-198630844);V=F(V,Y,X,W,Z[R+7],10,1126891415);W=F(W,V,Y,X,Z[R+14],15,-1416354905);X=F(X,W,V,Y,Z[R+5],21,-57434055);Y=F(Y,X,W,V,Z[R+12],6,1700485571);V=F(V,Y,X,W,Z[R+3],10,-1894986606);W=F(W,V,Y,X,Z[R+10],15,-1051523);X=F(X,W,V,Y,Z[R+1],21,-2054922799);Y=F(Y,X,W,V,Z[R+8],6,1873313359);V=F(V,Y,X,W,Z[R+15],10,-30611744);W=F(W,V,Y,X,Z[R+6],15,-1560198380);X=F(X,W,V,Y,Z[R+13],21,1309151649);Y=F(Y,X,W,V,Z[R+4],6,-145523070);V=F(V,Y,X,W,Z[R+11],10,-1120210379);W=F(W,V,Y,X,Z[R+2],15,718787259);X=F(X,W,V,Y,Z[R+9],21,-343485551);Y=G(Y,T);X=G(X,S);W=G(W,Q);V=G(V,P)}return[Y,X,W,V]}function A(S){var R=[];var P=(1<<I)-1;for(var Q=0;Q<S.length*I;Q+=I){R[Q>>5]|=(S.charCodeAt(Q/I)&P)<<(Q%32)}return R}function D(R){var S="";var P=(1<<I)-1;for(var Q=0;Q<R.length*32;Q+=I){S+=String.fromCharCode((R[Q>>5]>>>(Q%32))&P)}return S}function N(R){var Q=L?"0123456789ABCDEF":"0123456789abcdef";var S="";for(var P=0;P<R.length*4;P++){S+=Q.charAt((R[P>>2]>>((P%4)*8+4))&15)+Q.charAt((R[P>>2]>>((P%4)*8))&15)}return S}return(M?D(E(A(O),O.length*I)):N(E(A(O),O.length*I)))};this.io={version:"0.6",setPath:function(A){if(window.console&&console.error){console.error("io.setPath will be removed. Please set the variable WEB_SOCKET_SWF_LOCATION pointing to WebSocketMain.swf")}this.path=/\/$/.test(A)?A:A+"/";WEB_SOCKET_SWF_LOCATION=A+"lib/vendor/web-socket-js/WebSocketMain.swf"}};if("jQuery" in this){jQuery.io=this.io}if(typeof window!="undefined"){WEB_SOCKET_SWF_LOCATION="/socket.io/lib/vendor/web-socket-js/WebSocketMain.swf"}(function(){var A=false;io.util={ios:false,load:function(B){if(document.readyState=="complete"||A){return B()}if("attachEvent" in window){window.attachEvent("onload",B)}else{window.addEventListener("load",B,false)}},inherit:function(D,B){for(var C in B.prototype){D.prototype[C]=B.prototype[C]}},indexOf:function(B,E,F){for(var C=B.length,D=(F<0)?Math.max(0,C+F):F||0;D<C;D++){if(B[D]===E){return D}}return -1},isArray:function(B){return Object.prototype.toString.call(B)==="[object Array]"},merge:function(D,B){for(var C in B){if(B.hasOwnProperty(C)){D[C]=B[C]}}}};io.util.ios=/iphone|ipad/i.test(navigator.userAgent);io.util.android=/android/i.test(navigator.userAgent);io.util.opera=/opera/i.test(navigator.userAgent);io.util.load(function(){A=true})})();(function(){var A="~m~",B=function(C){if(Object.prototype.toString.call(C)=="[object Object]"){if(!("JSON" in window)){if("console" in window&&console.error){console.error("Trying to encode as JSON, but JSON.stringify is missing.")}return'{ "$error": "Invalid message" }'}return"~j~"+JSON.stringify(C)}else{return String(C)}};Transport=io.Transport=function(D,C){this.base=D;this.options={timeout:15000};io.util.merge(this.options,C)};Transport.prototype.send=function(){throw new Error("Missing send() implementation")};Transport.prototype.connect=function(){throw new Error("Missing connect() implementation")};Transport.prototype.disconnect=function(){throw new Error("Missing disconnect() implementation")};Transport.prototype._encode=function(G){var D="",F,G=io.util.isArray(G)?G:[G];for(var E=0,C=G.length;E<C;E++){F=G[E]===null||G[E]===undefined?"":B(G[E]);D+=A+F.length+A+F}return D};Transport.prototype._decode=function(G){var F=[],E,H;do{if(G.substr(0,3)!==A){return F}G=G.substr(3);E="",H="";for(var D=0,C=G.length;D<C;D++){H=Number(G.substr(D,1));if(G.substr(D,1)==H){E+=H}else{G=G.substr(E.length+A.length);E=Number(E);break}}F.push(G.substr(0,E));G=G.substr(E)}while(G!=="");return F};Transport.prototype._onData=function(F){this._setTimeout();var E=this._decode(F);if(E&&E.length){for(var D=0,C=E.length;D<C;D++){this._onMessage(E[D])}}};Transport.prototype._setTimeout=function(){var C=this;if(this._timeout){clearTimeout(this._timeout)}this._timeout=setTimeout(function(){C._onTimeout()},this.options.timeout)};Transport.prototype._onTimeout=function(){this._onDisconnect()};Transport.prototype._onMessage=function(C){if(!this.sessionid){this.sessionid=C;this._onConnect()}else{if(C.substr(0,3)=="~h~"){this._onHeartbeat(C.substr(3))}else{if(C.substr(0,3)=="~j~"){this.base._onMessage(JSON.parse(C.substr(3)))}else{this.base._onMessage(C)}}}},Transport.prototype._onHeartbeat=function(C){this.send("~h~"+C)};Transport.prototype._onConnect=function(){this.connected=true;this.connecting=false;this.base._onConnect();this._setTimeout()};Transport.prototype._onDisconnect=function(){this.connecting=false;this.connected=false;this.sessionid=null;this.base._onDisconnect()};Transport.prototype._prepareUrl=function(){return(this.base.options.secure?"https":"http")+"://"+this.base.host+":"+this.base.options.port+"/"+this.base.options.resource+"/"+this.type+(this.sessionid?("/"+this.sessionid):"/")}})();(function(){var D=new Function,A=(function(){if(!("XMLHttpRequest" in window)){return false}var E=new XMLHttpRequest();return E.withCredentials!=undefined})(),C=function(G){if("XDomainRequest" in window&&G){return new XDomainRequest()}if("XMLHttpRequest" in window&&(!G||A)){return new XMLHttpRequest()}if(!G){try{var F=new ActiveXObject("MSXML2.XMLHTTP");return F}catch(H){}try{var E=new ActiveXObject("Microsoft.XMLHTTP");return E}catch(H){}}return false},B=io.Transport.XHR=function(){io.Transport.apply(this,arguments);this._sendBuffer=[]};io.util.inherit(B,io.Transport);B.prototype.connect=function(){this._get();return this};B.prototype._checkSend=function(){if(!this._posting&&this._sendBuffer.length){var E=this._encode(this._sendBuffer);this._sendBuffer=[];this._send(E)}};B.prototype.send=function(E){if(io.util.isArray(E)){this._sendBuffer.push.apply(this._sendBuffer,E)}else{this._sendBuffer.push(E)}this._checkSend();return this};B.prototype._send=function(F){var E=this;this._posting=true;this._sendXhr=this._request("send","POST");this._sendXhr.onreadystatechange=function(){var G;if(E._sendXhr.readyState==4){E._sendXhr.onreadystatechange=D;try{G=E._sendXhr.status}catch(H){}E._posting=false;if(G==200){E._checkSend()}else{E._onDisconnect()}}};this._sendXhr.send("data="+encodeURIComponent(F))};B.prototype.disconnect=function(){this._onDisconnect();return this};B.prototype._onDisconnect=function(){if(this._xhr){this._xhr.onreadystatechange=this._xhr.onload=D;this._xhr.abort();this._xhr=null}if(this._sendXhr){this._sendXhr.onreadystatechange=this._sendXhr.onload=D;this._sendXhr.abort();this._sendXhr=null}this._sendBuffer=[];io.Transport.prototype._onDisconnect.call(this)};B.prototype._request=function(F,H,E){var G=C(this.base._isXDomain());if(E){G.multipart=true}G.open(H||"GET",this._prepareUrl()+(F?"/"+F:""));if(H=="POST"&&"setRequestHeader" in G){G.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8")}return G};B.check=function(E){try{if(C(E)){return true}}catch(F){}return false};B.xdomainCheck=function(){return B.check(true)};B.request=C})();(function(){var A=io.Transport.websocket=function(){io.Transport.apply(this,arguments)};io.util.inherit(A,io.Transport);A.prototype.type="websocket";A.prototype.connect=function(){var B=this;this.socket=new WebSocket(this._prepareUrl());this.socket.onmessage=function(C){B._onData(C.data)};this.socket.onclose=function(C){B._onClose()};return this};A.prototype.send=function(B){if(this.socket){this.socket.send(this._encode(B))}return this};A.prototype.disconnect=function(){if(this.socket){this.socket.close()}return this};A.prototype._onClose=function(){this._onDisconnect();return this};A.prototype._prepareUrl=function(){return(this.base.options.secure?"wss":"ws")+"://"+this.base.host+":"+this.base.options.port+"/"+this.base.options.resource+"/"+this.type+(this.sessionid?("/"+this.sessionid):"")};A.check=function(){return"WebSocket" in window&&WebSocket.prototype&&(WebSocket.prototype.send&&!!WebSocket.prototype.send.toString().match(/native/i))&&typeof WebSocket!=="undefined"};A.xdomainCheck=function(){return true}})();(function(){var A=io.Transport.flashsocket=function(){io.Transport.websocket.apply(this,arguments)};io.util.inherit(A,io.Transport.websocket);A.prototype.type="flashsocket";A.prototype.connect=function(){var B=this,C=arguments;WebSocket.__addTask(function(){io.Transport.websocket.prototype.connect.apply(B,C)});return this};A.prototype.send=function(){var B=this,C=arguments;WebSocket.__addTask(function(){io.Transport.websocket.prototype.send.apply(B,C)});return this};A.check=function(){if(typeof WebSocket=="undefined"||!("__addTask" in WebSocket)){return false}if(io.util.opera){return false}if("navigator" in window&&"plugins" in navigator&&navigator.plugins["Shockwave Flash"]){return !!navigator.plugins["Shockwave Flash"].description}if("ActiveXObject" in window){try{return !!new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(B){}}return false};A.xdomainCheck=function(){return true}})();(function(){var A=io.Transport.htmlfile=function(){io.Transport.XHR.apply(this,arguments)};io.util.inherit(A,io.Transport.XHR);A.prototype.type="htmlfile";A.prototype._get=function(){var B=this;this._open();window.attachEvent("onunload",function(){B._destroy()})};A.prototype._open=function(){this._doc=new ActiveXObject("htmlfile");this._doc.open();this._doc.write("<html></html>");this._doc.parentWindow.s=this;this._doc.close();var B=this._doc.createElement("div");this._doc.body.appendChild(B);this._iframe=this._doc.createElement("iframe");B.appendChild(this._iframe);this._iframe.src=this._prepareUrl()+"/"+(+new Date)};A.prototype._=function(C,D){this._onData(C);var B=D.getElementsByTagName("script")[0];B.parentNode.removeChild(B)};A.prototype._destroy=function(){if(this._iframe){this._iframe.src="about:blank";this._doc=null;CollectGarbage()}};A.prototype.disconnect=function(){this._destroy();return io.Transport.XHR.prototype.disconnect.call(this)};A.check=function(){if("ActiveXObject" in window){try{var B=new ActiveXObject("htmlfile");return B&&io.Transport.XHR.check()}catch(C){}}return false};A.xdomainCheck=function(){return false}})();(function(){var A=io.Transport["xhr-multipart"]=function(){io.Transport.XHR.apply(this,arguments)};io.util.inherit(A,io.Transport.XHR);A.prototype.type="xhr-multipart";A.prototype._get=function(){var B=this;this._xhr=this._request("","GET",true);this._xhr.onreadystatechange=function(){if(B._xhr.readyState==3){B._onData(B._xhr.responseText)}};this._xhr.send()};A.check=function(){return"XMLHttpRequest" in window&&"prototype" in XMLHttpRequest&&"multipart" in XMLHttpRequest.prototype};A.xdomainCheck=function(){return true}})();(function(){var A=new Function(),B=io.Transport["xhr-polling"]=function(){io.Transport.XHR.apply(this,arguments)};io.util.inherit(B,io.Transport.XHR);B.prototype.type="xhr-polling";B.prototype.connect=function(){if(io.util.ios||io.util.android){var C=this;io.util.load(function(){setTimeout(function(){io.Transport.XHR.prototype.connect.call(C)},10)})}else{io.Transport.XHR.prototype.connect.call(this)}};B.prototype._get=function(){var C=this;this._xhr=this._request(+new Date,"GET");if("onload" in this._xhr){this._xhr.onload=function(){C._onData(this.responseText);C._get()}}else{this._xhr.onreadystatechange=function(){var D;if(C._xhr.readyState==4){C._xhr.onreadystatechange=A;try{D=C._xhr.status}catch(E){}if(D==200){C._onData(C._xhr.responseText);C._get()}else{C._onDisconnect()}}}}this._xhr.send()};B.check=function(){return io.Transport.XHR.check()};B.xdomainCheck=function(){return io.Transport.XHR.xdomainCheck()}})();io.JSONP=[];JSONPPolling=io.Transport["jsonp-polling"]=function(){io.Transport.XHR.apply(this,arguments);this._insertAt=document.getElementsByTagName("script")[0];this._index=io.JSONP.length;io.JSONP.push(this)};io.util.inherit(JSONPPolling,io.Transport["xhr-polling"]);JSONPPolling.prototype.type="jsonp-polling";JSONPPolling.prototype._send=function(G){var I=this;if(!("_form" in this)){var B=document.createElement("FORM"),C=document.createElement("TEXTAREA"),A=this._iframeId="socket_io_iframe_"+this._index,F;B.style.position="absolute";B.style.top="-1000px";B.style.left="-1000px";B.target=A;B.method="POST";B.action=this._prepareUrl()+"/"+(+new Date)+"/"+this._index;C.name="data";B.appendChild(C);this._insertAt.parentNode.insertBefore(B,this._insertAt);document.body.appendChild(B);this._form=B;this._area=C}function D(){E();I._posting=false;I._checkSend()}function E(){if(I._iframe){I._form.removeChild(I._iframe)}try{F=document.createElement('<iframe name="'+I._iframeId+'">')}catch(J){F=document.createElement("iframe");F.name=I._iframeId}F.id=I._iframeId;I._form.appendChild(F);I._iframe=F}E();this._posting=true;this._area.value=G;try{this._form.submit()}catch(H){}if(this._iframe.attachEvent){F.onreadystatechange=function(){if(I._iframe.readyState=="complete"){D()}}}else{this._iframe.onload=D}};JSONPPolling.prototype._get=function(){var B=this,A=document.createElement("SCRIPT");if(this._script){this._script.parentNode.removeChild(this._script);this._script=null}A.async=true;A.src=this._prepareUrl()+"/"+(+new Date)+"/"+this._index;A.onerror=function(){B._onDisconnect()};this._insertAt.parentNode.insertBefore(A,this._insertAt);this._script=A};JSONPPolling.prototype._=function(){this._onData.apply(this,arguments);this._get();return this};JSONPPolling.check=function(){return true};JSONPPolling.xdomainCheck=function(){return true};(function(){var A=io.Socket=function(C,B){this.host=C||document.domain;this.options={secure:false,document:document,port:document.location.port||80,resource:"socket.io",transports:["websocket","flashsocket","htmlfile","xhr-multipart","xhr-polling","jsonp-polling"],transportOptions:{"xhr-polling":{timeout:25000},"jsonp-polling":{timeout:25000}},connectTimeout:5000,tryTransportsOnConnectTimeout:true,rememberTransport:true};io.util.merge(this.options,B);this.connected=false;this.connecting=false;this._events={};this.transport=this.getTransport();if(!this.transport&&"console" in window){console.error("No transport available")}};A.prototype.getTransport=function(E){var B=E||this.options.transports,C;if(this.options.rememberTransport&&!E){C=this.options.document.cookie.match("(?:^|;)\\s*socketio=([^;]*)");if(C){this._rememberedTransport=true;B=[decodeURIComponent(C[1])]}}for(var D=0,F;F=B[D];D++){if(io.Transport[F]&&io.Transport[F].check()&&(!this._isXDomain()||io.Transport[F].xdomainCheck())){return new io.Transport[F](this,this.options.transportOptions[F]||{})}}return null};A.prototype.connect=function(){if(this.transport&&!this.connected){if(this.connecting){this.disconnect()}this.connecting=true;this.transport.connect();if(this.options.connectTimeout){var B=this;setTimeout(function(){if(!B.connected){B.disconnect();if(B.options.tryTransportsOnConnectTimeout&&!B._rememberedTransport){var C=[],D=B.options.transports;for(var E=0,F;F=D[E];E++){if(F!=B.transport.type){C.push(F)}}if(C.length){B.transport=B.getTransport(C);B.connect()}}}},this.options.connectTimeout)}}return this};A.prototype.send=function(B){if(!this.transport||!this.transport.connected){return this._queue(B)}this.transport.send(B);return this};A.prototype.disconnect=function(){this.transport.disconnect();return this};A.prototype.on=function(B,C){if(!(B in this._events)){this._events[B]=[]}this._events[B].push(C);return this};A.prototype.fire=function(C,B){if(C in this._events){for(var D=0,E=this._events[C].length;D<E;D++){this._events[C][D].apply(this,B===undefined?[]:B)}}return this};A.prototype.removeEvent=function(D,E){if(D in this._events){for(var C=0,B=this._events[D].length;C<B;C++){if(this._events[D][C]==E){this._events[D].splice(C,1)}}}return this};A.prototype._queue=function(B){if(!("_queueStack" in this)){this._queueStack=[]}this._queueStack.push(B);return this};A.prototype._doQueue=function(){if(!("_queueStack" in this)||!this._queueStack.length){return this}this.transport.send(this._queueStack);this._queueStack=[];return this};A.prototype._isXDomain=function(){return this.host!==document.domain};A.prototype._onConnect=function(){this.connected=true;this.connecting=false;this._doQueue();if(this.options.rememberTransport){this.options.document.cookie="socketio="+encodeURIComponent(this.transport.type)}this.fire("connect")};A.prototype._onMessage=function(B){this.fire("message",[B])};A.prototype._onDisconnect=function(){var B=this.connected;this.connected=false;this.connecting=false;this._queueStack=[];if(B){this.fire("disconnect")}};A.prototype.addListener=A.prototype.addEvent=A.prototype.addEventListener=A.prototype.on})();var swfobject=function(){var AQ="undefined",Ac="object",AB="Shockwave Flash",X="ShockwaveFlash.ShockwaveFlash",Ad="application/x-shockwave-flash",AC="SWFObjectExprInst",AW="onreadystatechange",AF=window,Ak=document,Aa=navigator,AA=false,Z=[Am],Af=[],AG=[],AL=[],Ai,AD,AP,AS,AK=false,At=false,Ag,AN,Ah=true,AH=function(){var A=typeof Ak.getElementById!=AQ&&typeof Ak.getElementsByTagName!=AQ&&typeof Ak.createElement!=AQ,E=Aa.userAgent.toLowerCase(),C=Aa.platform.toLowerCase(),H=C?/win/.test(C):/win/.test(E),J=C?/mac/.test(C):/mac/.test(E),G=/webkit/.test(E)?parseFloat(E.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,D=!+"\v1",F=[0,0,0],K=null;if(typeof Aa.plugins!=AQ&&typeof Aa.plugins[AB]==Ac){K=Aa.plugins[AB].description;if(K&&!(typeof Aa.mimeTypes!=AQ&&Aa.mimeTypes[Ad]&&!Aa.mimeTypes[Ad].enabledPlugin)){AA=true;D=false;K=K.replace(/^.*\s+(\S+\s+\S+$)/,"$1");F[0]=parseInt(K.replace(/^(.*)\..*$/,"$1"),10);F[1]=parseInt(K.replace(/^.*\.(.*)\s.*$/,"$1"),10);F[2]=/[a-zA-Z]/.test(K)?parseInt(K.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof AF.ActiveXObject!=AQ){try{var I=new ActiveXObject(X);if(I){K=I.GetVariable("$version");if(K){D=true;K=K.split(" ")[1].split(",");F=[parseInt(K[0],10),parseInt(K[1],10),parseInt(K[2],10)]}}}catch(B){}}}return{w3:A,pv:F,wk:G,ie:D,win:H,mac:J}}(),Aj=function(){if(!AH.w3){return }if((typeof Ak.readyState!=AQ&&Ak.readyState=="complete")||(typeof Ak.readyState==AQ&&(Ak.getElementsByTagName("body")[0]||Ak.body))){Ao()}if(!AK){if(typeof Ak.addEventListener!=AQ){Ak.addEventListener("DOMContentLoaded",Ao,false)}if(AH.ie&&AH.win){Ak.attachEvent(AW,function(){if(Ak.readyState=="complete"){Ak.detachEvent(AW,arguments.callee);Ao()}});if(AF==top){(function(){if(AK){return }try{Ak.documentElement.doScroll("left")}catch(A){setTimeout(arguments.callee,0);return }Ao()})()}}if(AH.wk){(function(){if(AK){return }if(!/loaded|complete/.test(Ak.readyState)){setTimeout(arguments.callee,0);return }Ao()})()}Ab(Ao)}}();function Ao(){if(AK){return }try{var B=Ak.getElementsByTagName("body")[0].appendChild(AR("span"));B.parentNode.removeChild(B)}catch(A){return }AK=true;var D=Z.length;for(var C=0;C<D;C++){Z[C]()}}function AJ(A){if(AK){A()}else{Z[Z.length]=A}}function Ab(A){if(typeof AF.addEventListener!=AQ){AF.addEventListener("load",A,false)}else{if(typeof Ak.addEventListener!=AQ){Ak.addEventListener("load",A,false)}else{if(typeof AF.attachEvent!=AQ){Al(AF,"onload",A)}else{if(typeof AF.onload=="function"){var B=AF.onload;AF.onload=function(){B();A()}}else{AF.onload=A}}}}}function Am(){if(AA){Y()}else{AM()}}function Y(){var D=Ak.getElementsByTagName("body")[0];var B=AR(Ac);B.setAttribute("type",Ad);var A=D.appendChild(B);if(A){var C=0;(function(){if(typeof A.GetVariable!=AQ){var E=A.GetVariable("$version");if(E){E=E.split(" ")[1].split(",");AH.pv=[parseInt(E[0],10),parseInt(E[1],10),parseInt(E[2],10)]}}else{if(C<10){C++;setTimeout(arguments.callee,10);return }}D.removeChild(B);A=null;AM()})()}else{AM()}}function AM(){var G=Af.length;if(G>0){for(var H=0;H<G;H++){var C=Af[H].id;var L=Af[H].callbackFn;var A={success:false,id:C};if(AH.pv[0]>0){var I=Ar(C);if(I){if(AO(Af[H].swfVersion)&&!(AH.wk&&AH.wk<312)){AX(C,true);if(L){A.success=true;A.ref=AU(C);L(A)}}else{if(Af[H].expressInstall&&AT()){var E={};E.data=Af[H].expressInstall;E.width=I.getAttribute("width")||"0";E.height=I.getAttribute("height")||"0";if(I.getAttribute("class")){E.styleclass=I.getAttribute("class")}if(I.getAttribute("align")){E.align=I.getAttribute("align")}var F={};var D=I.getElementsByTagName("param");var K=D.length;for(var J=0;J<K;J++){if(D[J].getAttribute("name").toLowerCase()!="movie"){F[D[J].getAttribute("name")]=D[J].getAttribute("value")}}AE(E,F,C,L)}else{Ae(I);if(L){L(A)}}}}}else{AX(C,true);if(L){var B=AU(C);if(B&&typeof B.SetVariable!=AQ){A.success=true;A.ref=B}L(A)}}}}}function AU(B){var D=null;var C=Ar(B);if(C&&C.nodeName=="OBJECT"){if(typeof C.SetVariable!=AQ){D=C}else{var A=C.getElementsByTagName(Ac)[0];if(A){D=A}}}return D}function AT(){return !At&&AO("6.0.65")&&(AH.win||AH.mac)&&!(AH.wk&&AH.wk<312)}function AE(F,D,H,E){At=true;AP=E||null;AS={success:false,id:H};var A=Ar(H);if(A){if(A.nodeName=="OBJECT"){Ai=An(A);AD=null}else{Ai=A;AD=H}F.id=AC;if(typeof F.width==AQ||(!/%$/.test(F.width)&&parseInt(F.width,10)<310)){F.width="310"}if(typeof F.height==AQ||(!/%$/.test(F.height)&&parseInt(F.height,10)<137)){F.height="137"}Ak.title=Ak.title.slice(0,47)+" - Flash Player Installation";var B=AH.ie&&AH.win?"ActiveX":"PlugIn",C="MMredirectURL="+AF.location.toString().replace(/&/g,"%26")+"&MMplayerType="+B+"&MMdoctitle="+Ak.title;if(typeof D.flashvars!=AQ){D.flashvars+="&"+C}else{D.flashvars=C}if(AH.ie&&AH.win&&A.readyState!=4){var G=AR("div");H+="SWFObjectNew";G.setAttribute("id",H);A.parentNode.insertBefore(G,A);A.style.display="none";(function(){if(A.readyState==4){A.parentNode.removeChild(A)}else{setTimeout(arguments.callee,10)}})()}AZ(F,D,H)}}function Ae(A){if(AH.ie&&AH.win&&A.readyState!=4){var B=AR("div");A.parentNode.insertBefore(B,A);B.parentNode.replaceChild(An(A),B);A.style.display="none";(function(){if(A.readyState==4){A.parentNode.removeChild(A)}else{setTimeout(arguments.callee,10)}})()}else{A.parentNode.replaceChild(An(A),A)}}function An(B){var D=AR("div");if(AH.win&&AH.ie){D.innerHTML=B.innerHTML}else{var E=B.getElementsByTagName(Ac)[0];if(E){var A=E.childNodes;if(A){var F=A.length;for(var C=0;C<F;C++){if(!(A[C].nodeType==1&&A[C].nodeName=="PARAM")&&!(A[C].nodeType==8)){D.appendChild(A[C].cloneNode(true))}}}}}return D}function AZ(E,G,C){var D,A=Ar(C);if(AH.wk&&AH.wk<312){return D}if(A){if(typeof E.id==AQ){E.id=C}if(AH.ie&&AH.win){var F="";for(var I in E){if(E[I]!=Object.prototype[I]){if(I.toLowerCase()=="data"){G.movie=E[I]}else{if(I.toLowerCase()=="styleclass"){F+=' class="'+E[I]+'"'}else{if(I.toLowerCase()!="classid"){F+=" "+I+'="'+E[I]+'"'}}}}}var H="";for(var J in G){if(G[J]!=Object.prototype[J]){H+='<param name="'+J+'" value="'+G[J]+'" />'}}A.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+F+">"+H+"</object>";AG[AG.length]=E.id;D=Ar(E.id)}else{var B=AR(Ac);B.setAttribute("type",Ad);for(var K in E){if(E[K]!=Object.prototype[K]){if(K.toLowerCase()=="styleclass"){B.setAttribute("class",E[K])}else{if(K.toLowerCase()!="classid"){B.setAttribute(K,E[K])}}}}for(var L in G){if(G[L]!=Object.prototype[L]&&L.toLowerCase()!="movie"){Ap(B,L,G[L])}}A.parentNode.replaceChild(B,A);D=B}}return D}function Ap(B,D,C){var A=AR("param");A.setAttribute("name",D);A.setAttribute("value",C);B.appendChild(A)}function AV(A){var B=Ar(A);if(B&&B.nodeName=="OBJECT"){if(AH.ie&&AH.win){B.style.display="none";(function(){if(B.readyState==4){As(A)}else{setTimeout(arguments.callee,10)}})()}else{B.parentNode.removeChild(B)}}}function As(A){var B=Ar(A);if(B){for(var C in B){if(typeof B[C]=="function"){B[C]=null}}B.parentNode.removeChild(B)}}function Ar(A){var C=null;try{C=Ak.getElementById(A)}catch(B){}return C}function AR(A){return Ak.createElement(A)}function Al(A,C,B){A.attachEvent(C,B);AL[AL.length]=[A,C,B]}function AO(A){var B=AH.pv,C=A.split(".");C[0]=parseInt(C[0],10);C[1]=parseInt(C[1],10)||0;C[2]=parseInt(C[2],10)||0;return(B[0]>C[0]||(B[0]==C[0]&&B[1]>C[1])||(B[0]==C[0]&&B[1]==C[1]&&B[2]>=C[2]))?true:false}function AY(B,F,A,C){if(AH.ie&&AH.mac){return }var E=Ak.getElementsByTagName("head")[0];if(!E){return }var G=(A&&typeof A=="string")?A:"screen";if(C){Ag=null;AN=null}if(!Ag||AN!=G){var D=AR("style");D.setAttribute("type","text/css");D.setAttribute("media",G);Ag=E.appendChild(D);if(AH.ie&&AH.win&&typeof Ak.styleSheets!=AQ&&Ak.styleSheets.length>0){Ag=Ak.styleSheets[Ak.styleSheets.length-1]}AN=G}if(AH.ie&&AH.win){if(Ag&&typeof Ag.addRule==Ac){Ag.addRule(B,F)}}else{if(Ag&&typeof Ak.createTextNode!=AQ){Ag.appendChild(Ak.createTextNode(B+" {"+F+"}"))}}}function AX(A,C){if(!Ah){return }var B=C?"visible":"hidden";if(AK&&Ar(A)){Ar(A).style.visibility=B}else{AY("#"+A,"visibility:"+B)}}function AI(B){var A=/[\\\"<>\.;]/;var C=A.exec(B)!=null;return C&&typeof encodeURIComponent!=AQ?encodeURIComponent(B):B}var Aq=function(){if(AH.ie&&AH.win){window.attachEvent("onunload",function(){var A=AL.length;for(var B=0;B<A;B++){AL[B][0].detachEvent(AL[B][1],AL[B][2])}var D=AG.length;for(var C=0;C<D;C++){AV(AG[C])}for(var E in AH){AH[E]=null}AH=null;for(var F in swfobject){swfobject[F]=null}swfobject=null})}}();return{registerObject:function(A,E,C,B){if(AH.w3&&A&&E){var D={};D.id=A;D.swfVersion=E;D.expressInstall=C;D.callbackFn=B;Af[Af.length]=D;AX(A,false)}else{if(B){B({success:false,id:A})}}},getObjectById:function(A){if(AH.w3){return AU(A)}},embedSWF:function(K,E,H,F,C,A,B,I,G,J){var D={success:false,id:E};if(AH.w3&&!(AH.wk&&AH.wk<312)&&K&&E&&H&&F&&C){AX(E,false);AJ(function(){H+="";F+="";var Q={};if(G&&typeof G===Ac){for(var O in G){Q[O]=G[O]}}Q.data=K;Q.width=H;Q.height=F;var N={};if(I&&typeof I===Ac){for(var P in I){N[P]=I[P]}}if(B&&typeof B===Ac){for(var L in B){if(typeof N.flashvars!=AQ){N.flashvars+="&"+L+"="+B[L]}else{N.flashvars=L+"="+B[L]}}}if(AO(C)){var M=AZ(Q,N,E);if(Q.id==E){AX(E,true)}D.success=true;D.ref=M}else{if(A&&AT()){Q.data=A;AE(Q,N,E,J);return }else{AX(E,true)}}if(J){J(D)}})}else{if(J){J(D)}}},switchOffAutoHideShow:function(){Ah=false},ua:AH,getFlashPlayerVersion:function(){return{major:AH.pv[0],minor:AH.pv[1],release:AH.pv[2]}},hasFlashPlayerVersion:AO,createSWF:function(A,B,C){if(AH.w3){return AZ(A,B,C)}else{return undefined}},showExpressInstall:function(B,A,D,C){if(AH.w3&&AT()){AE(B,A,D,C)}},removeSWF:function(A){if(AH.w3){AV(A)}},createCSS:function(B,A,C,D){if(AH.w3){AY(B,A,C,D)}},addDomLoadEvent:AJ,addLoadEvent:Ab,getQueryParamValue:function(B){var A=Ak.location.search||Ak.location.hash;if(A){if(/\?/.test(A)){A=A.split("?")[1]}if(B==null){return AI(A)}var C=A.split("&");for(var D=0;D<C.length;D++){if(C[D].substring(0,C[D].indexOf("="))==B){return AI(C[D].substring((C[D].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(At){var A=Ar(AC);if(A&&Ai){A.parentNode.replaceChild(Ai,A);if(AD){AX(AD,true);if(AH.ie&&AH.win){Ai.style.display="block"}}if(AP){AP(AS)}}At=false}}}}();function FABridge(B,A){this.target=B;this.remoteTypeCache={};this.remoteInstanceCache={};this.remoteFunctionCache={};this.localFunctionCache={};this.bridgeID=FABridge.nextBridgeID++;this.name=A;this.nextLocalFuncID=0;FABridge.instances[this.name]=this;FABridge.idMap[this.bridgeID]=this;return this}FABridge.TYPE_ASINSTANCE=1;FABridge.TYPE_ASFUNCTION=2;FABridge.TYPE_JSFUNCTION=3;FABridge.TYPE_ANONYMOUS=4;FABridge.initCallbacks={};FABridge.userTypes={};FABridge.addToUserTypes=function(){for(var A=0;A<arguments.length;A++){FABridge.userTypes[arguments[A]]={typeName:arguments[A],enriched:false}}};FABridge.argsToArray=function(B){var A=[];for(var C=0;C<B.length;C++){A[C]=B[C]}return A};function instanceFactory(A){this.fb_instance_id=A;return this}function FABridge__invokeJSFunction(A){var C=A[0];var B=A.concat();B.shift();var D=FABridge.extractBridgeFromID(C);return D.invokeLocalFunction(C,B)}FABridge.addInitializationCallback=function(B,D){var C=FABridge.instances[B];if(C!=undefined){D.call(C);return }var A=FABridge.initCallbacks[B];if(A==null){FABridge.initCallbacks[B]=A=[]}A.push(D)};function FABridge__bridgeInitialized(G){var A=document.getElementsByTagName("object");var F=A.length;var D=[];if(F>0){for(var P=0;P<F;P++){if(typeof A[P].SetVariable!="undefined"){D[D.length]=A[P]}}}var I=document.getElementsByTagName("embed");var B=I.length;var O=[];if(B>0){for(var M=0;M<B;M++){if(typeof I[M].SetVariable!="undefined"){O[O.length]=I[M]}}}var C=D.length;var N=O.length;var H="bridgeName="+G;if((C==1&&!N)||(C==1&&N==1)){FABridge.attachBridge(D[0],G)}else{if(N==1&&!C){FABridge.attachBridge(O[0],G)}else{var Q=false;if(C>1){for(var L=0;L<C;L++){var S=D[L].childNodes;for(var K=0;K<S.length;K++){var E=S[K];if(E.nodeType==1&&E.tagName.toLowerCase()=="param"&&E.name.toLowerCase()=="flashvars"&&E.value.indexOf(H)>=0){FABridge.attachBridge(D[L],G);Q=true;break}}if(Q){break}}}if(!Q&&N>1){for(var J=0;J<N;J++){var R=O[J].attributes.getNamedItem("flashVars").nodeValue;if(R.indexOf(H)>=0){FABridge.attachBridge(O[J],G);break}}}}}return true}FABridge.nextBridgeID=0;FABridge.instances={};FABridge.idMap={};FABridge.refCount=0;FABridge.extractBridgeFromID=function(B){var A=(B>>16);return FABridge.idMap[A]};FABridge.attachBridge=function(A,C){var B=new FABridge(A,C);FABridge[C]=B;var E=FABridge.initCallbacks[C];if(E==null){return }for(var D=0;D<E.length;D++){E[D].call(B)}delete FABridge.initCallbacks[C]};FABridge.blockedMethods={toString:true,get:true,set:true,call:true};FABridge.prototype={root:function(){return this.deserialize(this.target.getRoot())},releaseASObjects:function(){return this.target.releaseASObjects()},releaseNamedASObject:function(B){if(typeof (B)!="object"){return false}else{var A=this.target.releaseNamedASObject(B.fb_instance_id);return A}},create:function(A){return this.deserialize(this.target.create(A))},makeID:function(A){return(this.bridgeID<<16)+A},getPropertyFromAS:function(B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.getPropFromAS(B,A);retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},setPropertyInAS:function(C,B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.setPropInAS(C,B,this.serialize(A));retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},callASFunction:function(B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.invokeASFunction(B,this.serialize(A));retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},callASMethod:function(B,C,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;A=this.serialize(A);retVal=this.target.invokeASMethod(B,C,A);retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},invokeLocalFunction:function(D,B){var A;var C=this.localFunctionCache[D];if(C!=undefined){A=this.serialize(C.apply(null,this.deserialize(B)))}return A},getTypeFromName:function(A){return this.remoteTypeCache[A]},createProxy:function(C,B){var D=this.getTypeFromName(B);instanceFactory.prototype=D;var A=new instanceFactory(C);this.remoteInstanceCache[C]=A;return A},getProxy:function(A){return this.remoteInstanceCache[A]},addTypeDataToCache:function(E){var C=new ASProxy(this,E.name);var B=E.accessors;for(var D=0;D<B.length;D++){this.addPropertyToType(C,B[D])}var A=E.methods;for(var D=0;D<A.length;D++){if(FABridge.blockedMethods[A[D]]==undefined){this.addMethodToType(C,A[D])}}this.remoteTypeCache[C.typeName]=C;return C},addPropertyToType:function(A,D){var E=D.charAt(0);var B;var C;if(E>="a"&&E<="z"){C="get"+E.toUpperCase()+D.substr(1);B="set"+E.toUpperCase()+D.substr(1)}else{C="get"+D;B="set"+D}A[B]=function(F){this.bridge.setPropertyInAS(this.fb_instance_id,D,F)};A[C]=function(){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,D))}},addMethodToType:function(A,B){A[B]=function(){return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id,B,FABridge.argsToArray(arguments)))}},getFunctionProxy:function(A){var B=this;if(this.remoteFunctionCache[A]==null){this.remoteFunctionCache[A]=function(){B.callASFunction(A,FABridge.argsToArray(arguments))}}return this.remoteFunctionCache[A]},getFunctionID:function(A){if(A.__bridge_id__==undefined){A.__bridge_id__=this.makeID(this.nextLocalFuncID++);this.localFunctionCache[A.__bridge_id__]=A}return A.__bridge_id__},serialize:function(D){var A={};var C=typeof (D);if(C=="number"||C=="string"||C=="boolean"||C==null||C==undefined){A=D}else{if(D instanceof Array){A=[];for(var B=0;B<D.length;B++){A[B]=this.serialize(D[B])}}else{if(C=="function"){A.type=FABridge.TYPE_JSFUNCTION;A.value=this.getFunctionID(D)}else{if(D instanceof ASProxy){A.type=FABridge.TYPE_ASINSTANCE;A.value=D.fb_instance_id}else{A.type=FABridge.TYPE_ANONYMOUS;A.value=D}}}}return A},deserialize:function(E){var A;var C=typeof (E);if(C=="number"||C=="string"||C=="boolean"||E==null||E==undefined){A=this.handleError(E)}else{if(E instanceof Array){A=[];for(var B=0;B<E.length;B++){A[B]=this.deserialize(E[B])}}else{if(C=="object"){for(var B=0;B<E.newTypes.length;B++){this.addTypeDataToCache(E.newTypes[B])}for(var D in E.newRefs){this.createProxy(D,E.newRefs[D])}if(E.type==FABridge.TYPE_PRIMITIVE){A=E.value}else{if(E.type==FABridge.TYPE_ASFUNCTION){A=this.getFunctionProxy(E.value)}else{if(E.type==FABridge.TYPE_ASINSTANCE){A=this.getProxy(E.value)}else{if(E.type==FABridge.TYPE_ANONYMOUS){A=E.value}}}}}}}return A},addRef:function(A){this.target.incRef(A.fb_instance_id)},release:function(A){this.target.releaseRef(A.fb_instance_id)},handleError:function(B){if(typeof (B)=="string"&&B.indexOf("__FLASHERROR")==0){var A=B.split("||");if(FABridge.refCount>0){FABridge.refCount--}throw new Error(A[1]);return B}else{return B}}};ASProxy=function(B,A){this.bridge=B;this.typeName=A;return this};ASProxy.prototype={get:function(A){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,A))},set:function(B,A){this.bridge.setPropertyInAS(this.fb_instance_id,B,A)},call:function(B,A){this.bridge.callASMethod(this.fb_instance_id,B,A)},addRef:function(){this.bridge.addRef(this)},release:function(){this.bridge.release(this)}};(function(){if(window.WebSocket){return }var A=window.console;if(!A){A={log:function(){},error:function(){}}}if(!swfobject.hasFlashPlayerVersion("9.0.0")){A.error("Flash Player is not installed.");return }if(location.protocol=="file:"){A.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://...")}WebSocket=function(E,H,D,G,F){var C=this;C.readyState=WebSocket.CONNECTING;C.bufferedAmount=0;setTimeout(function(){WebSocket.__addTask(function(){C.__createFlash(E,H,D,G,F)})},1)};WebSocket.prototype.__createFlash=function(E,H,D,G,F){var C=this;C.__flash=WebSocket.__flash.create(E,H,D||null,G||0,F||null);C.__flash.addEventListener("open",function(I){try{C.readyState=C.__flash.getReadyState();if(C.__timer){clearInterval(C.__timer)}if(window.opera){C.__timer=setInterval(function(){C.__handleMessages()},500)}if(C.onopen){C.onopen()}}catch(J){A.error(J.toString())}});C.__flash.addEventListener("close",function(I){try{C.readyState=C.__flash.getReadyState();if(C.__timer){clearInterval(C.__timer)}if(C.onclose){C.onclose()}}catch(J){A.error(J.toString())}});C.__flash.addEventListener("message",function(){try{C.__handleMessages()}catch(I){A.error(I.toString())}});C.__flash.addEventListener("error",function(I){try{if(C.__timer){clearInterval(C.__timer)}if(C.onerror){C.onerror()}}catch(J){A.error(J.toString())}});C.__flash.addEventListener("stateChange",function(I){try{C.readyState=C.__flash.getReadyState();C.bufferedAmount=I.getBufferedAmount()}catch(J){A.error(J.toString())}})};WebSocket.prototype.send=function(D){if(this.__flash){this.readyState=this.__flash.getReadyState()}if(!this.__flash||this.readyState==WebSocket.CONNECTING){throw"INVALID_STATE_ERR: Web Socket connection has not been established"}var C=this.__flash.send(encodeURIComponent(D));if(C<0){return true}else{this.bufferedAmount=C;return false}};WebSocket.prototype.close=function(){var C=this;if(!C.__flash){return }C.readyState=C.__flash.getReadyState();if(C.readyState==WebSocket.CLOSED||C.readyState==WebSocket.CLOSING){return }C.__flash.close();C.readyState=WebSocket.CLOSED;if(C.__timer){clearInterval(C.__timer)}if(C.onclose){setTimeout(C.onclose,1)}};WebSocket.prototype.addEventListener=function(D,E,C){if(!("__events" in this)){this.__events={}}if(!(D in this.__events)){this.__events[D]=[];if("function"==typeof this["on"+D]){this.__events[D].defaultHandler=this["on"+D];this["on"+D]=this.__createEventHandler(this,D)}}this.__events[D].push(E)};WebSocket.prototype.removeEventListener=function(E,F,C){if(!("__events" in this)){this.__events={}}if(!(E in this.__events)){return }for(var D=this.__events.length;D>-1;--D){if(F===this.__events[E][D]){this.__events[E].splice(D,1);break}}};WebSocket.prototype.dispatchEvent=function(E){if(!("__events" in this)){throw"UNSPECIFIED_EVENT_TYPE_ERR"}if(!(E.type in this.__events)){throw"UNSPECIFIED_EVENT_TYPE_ERR"}for(var D=0,C=this.__events[E.type].length;D<C;++D){this.__events[E.type][D](E);if(E.cancelBubble){break}}if(false!==E.returnValue&&"function"==typeof this.__events[E.type].defaultHandler){this.__events[E.type].defaultHandler(E)}};WebSocket.prototype.__handleMessages=function(){var C=this.__flash.readSocketData();for(var D=0;D<C.length;D++){var E=decodeURIComponent(C[D]);try{if(this.onmessage){var F;if(window.MessageEvent){F=document.createEvent("MessageEvent");F.initMessageEvent("message",false,false,E,null,null,window,null)}else{F={data:E}}this.onmessage(F)}}catch(F){A.error(F.toString())}}};WebSocket.prototype.__createEventHandler=function(C,D){return function(G){var F=new B();F.initEvent(D,true,true);F.target=F.currentTarget=C;for(var E in G){F[E]=G[E]}C.dispatchEvent(F,arguments)}};function B(){}B.prototype.cancelable=true;B.prototype.cancelBubble=false;B.prototype.preventDefault=function(){if(this.cancelable){this.returnValue=false}};B.prototype.stopPropagation=function(){this.cancelBubble=true};B.prototype.initEvent=function(C,E,D){this.type=C;this.cancelable=D;this.timeStamp=new Date()};WebSocket.CONNECTING=0;WebSocket.OPEN=1;WebSocket.CLOSING=2;WebSocket.CLOSED=3;WebSocket.__tasks=[];WebSocket.__initialize=function(){if(WebSocket.__swfLocation){window.WEB_SOCKET_SWF_LOCATION=WebSocket.__swfLocation}if(!window.WEB_SOCKET_SWF_LOCATION){A.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");return }var C=document.createElement("div");C.id="webSocketContainer";C.style.position="absolute";if(WebSocket.__isFlashLite()){C.style.left="0px";C.style.top="0px"}else{C.style.left="-100px";C.style.top="-100px"}var D=document.createElement("div");D.id="webSocketFlash";C.appendChild(D);document.body.appendChild(C);swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","9.0.0",null,{bridgeName:"webSocket"},{hasPriority:true,allowScriptAccess:"always"},null,function(E){if(!E.success){A.error("[WebSocket] swfobject.embedSWF failed")}});FABridge.addInitializationCallback("webSocket",function(){try{WebSocket.__flash=FABridge.webSocket.root();WebSocket.__flash.setCallerUrl(location.href);WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var E=0;E<WebSocket.__tasks.length;++E){WebSocket.__tasks[E]()}WebSocket.__tasks=[]}catch(F){A.error("[WebSocket] "+F.toString())}})};WebSocket.__addTask=function(C){if(WebSocket.__flash){C()}else{WebSocket.__tasks.push(C)}};WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes){return false}var C=window.navigator.mimeTypes["application/x-shockwave-flash"];if(!C||!C.enabledPlugin||!C.enabledPlugin.filename){return false}return C.enabledPlugin.filename.match(/flashlite/i)?true:false};window.webSocketLog=function(C){A.log(decodeURIComponent(C))};window.webSocketError=function(C){A.error(decodeURIComponent(C))};if(!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION){if(window.addEventListener){window.addEventListener("load",WebSocket.__initialize,false)}else{window.attachEvent("onload",WebSocket.__initialize)}}})();Ext.regApplication("App",{defaultTarget:"viewport",defaultUrl:"Viewport/index",name:"App",useHistory:false,useLoadMask:true,launch:function(){Ext.Viewport.init();Ext.Viewport.onOrientationChange();this.viewport=new App.View.Viewport({application:this});Ext.dispatch({controller:"Viewport",action:"index"})}});Ext.regController("Viewport",{index:function(){var A=new App.Store.Config();A.load();if(A.getCount()>0){this.showChat()}else{this.showConfig()}},showChat:function(){Ext.dispatch({controller:"Chat",action:"index"})},showConfig:function(){if(!this.viewConfig){this.viewConfig=this.render({xtype:"App.View.Config"});this.viewConfig.query("#backButton")[0].on("tap",this.showChat,this)}this.application.viewport.setActiveItem(this.viewConfig,{type:"slide",direction:"left"})}});Ext.regController("Chat",{index:function(){if(!this.socket){this.initSocketConnection()}this.showChat()},initSocketConnection:function(){var E=new App.Store.Chat();var D=Ext.StoreMgr.get("ConfigStore");var C=D.getAt(0);var B={nickname:C.get("nickname"),gravatar:C.get("gravatar")};var A=new io.Socket(C.get("server"),{port:4000});this.socket=A;A.connect();A.on("connect",function(){A.send(B)},this);A.on("message",function(F){E.add(F)});App.on("newMsg",function(F){this.socket.send(F)},this)},showChat:function(){if(!this.viewChat){this.viewChat=this.render({xtype:"App.View.Chat"});this.viewChat.query("#settingsButton")[0].on("tap",this.showConfig,this)}this.application.viewport.setActiveItem(this.viewChat,{type:"slide",direction:"left"})},showConfig:function(){Ext.dispatch({controller:"Viewport",action:"showConfig"})}});Ext.regModel("ChatMessage",{fields:[{name:"user",type:"string"},{name:"message",type:"string"}]});Ext.regModel("Config",{fields:[{name:"server",type:"string"},{name:"nickname",type:"string"},{name:"email",type:"string"},{name:"gravatar",type:"string"}],proxy:{type:"localstorage",id:"chat-settings"}});Ext.ns("App.Store");App.Store.Chat=Ext.extend(Ext.data.Store,{constructor:function(A){A=A||{};var B=Ext.apply({model:"ChatMessage",storeId:"ChatStore"},A);App.Store.Chat.superclass.constructor.call(this,B)}});Ext.reg("App.Store.Chat",App.Store.Chat);Ext.ns("App.Store");App.Store.Config=Ext.extend(Ext.data.Store,{constructor:function(A){A=A||{};var B=Ext.apply({model:"Config",storeId:"ConfigStore"},A);App.Store.Config.superclass.constructor.call(this,B)}});Ext.reg("App.Store.Config",App.Store.Config);Ext.ns("App.View");App.View.Viewport=Ext.extend(Ext.Panel,{id:"viewport",layout:"card",fullscreen:true,initComponent:function(){var A={};Ext.apply(this,A);App.View.Viewport.superclass.initComponent.call(this);this.addEventListener()},addEventListener:function(){this.on("afterrender",this.removeLoadingMask,this)},removeLoadingMask:function(){var A=Ext.get("pre-loading-mask");if(A){Ext.Anim.run(A,"fade",{easing:"out",duration:500,after:function(){A.remove()}})}}});Ext.reg("App.View.Viewport",App.View.Viewport);Ext.ns("App.View");App.View.Config=Ext.extend(Ext.form.FormPanel,{initComponent:function(){this.store=Ext.StoreMgr.get("ConfigStore");this.store.load();var A={fullscreen:true,scroll:"vertical",defaults:{},items:[{xtype:"textfield",name:"nickname",label:"Nickname",placeHolder:"nickname83"},{xtype:"emailfield",name:"email",label:"Gravatar",placeHolder:"gravatar@email-adress.com"},{xtype:"textfield",name:"server",label:"Server",placeHolder:"192.168.178.50",listeners:{blur:function(B){Ext.Viewport.scrollToTop()}}}],dockedItems:[{dock:"top",title:"Settings",xtype:"toolbar",items:[{ui:"back",text:"back",itemId:"backButton"}]},{dock:"top",xtype:"panel",itemId:"gravatar",html:'<img src="http://www.gravatar.com/avatar/?s=80&d=mm" height="80"/>',tpl:'<img src="http://www.gravatar.com/avatar/{gravatar}?s=80&d=mm" height="80"/>'},{dock:"bottom",xtype:"toolbar",items:[{xtype:"spacer"},{xtype:"button",text:"save",handler:this.saveAction,scope:this}]}]};Ext.apply(this,A);App.View.Config.superclass.initComponent.call(this);this.addEventListener()},addEventListener:function(){this.on("activate",this.loadSettings,this)},loadSettings:function(){var A=this.store.getAt(0);if(Ext.isObject(A)){this.load(A);this.updateGravatarImg(A)}},saveAction:function(){var B=this.getValues();var A=Ext.ModelMgr.create({nickname:B.nickname,email:B.email,gravatar:Ext.util.MD5(B.email),server:B.server},"Config");this.updateGravatarImg(A);this.store.removeAt(0);this.store.sync();this.store.add(A);this.store.sync()},updateGravatarImg:function(A){var B=this.getComponent("gravatar");B.update(A.data)}});Ext.reg("App.View.Config",App.View.Config);Ext.ns("App.View");App.View.Chat=Ext.extend(Ext.Panel,{initComponent:function(){this.store=Ext.StoreMgr.get("ChatStore");var A={layout:"fit",dockedItems:[{xtype:"toolbar",dock:"top",layout:"fit",title:"Chat",items:[{xtype:"spacer"},{iconMask:true,ui:"plain",iconCls:"settings",itemId:"settingsButton"}]},{xtype:"toolbar",dock:"bottom",itemId:"msgToolbar",layout:"fit",items:[{xtype:"textfield",width:"96%",listeners:{blur:function(B){Ext.Viewport.scrollToTop();App.fireEvent("newMsg",B.getValue());B.reset()}}}]}],items:[{xtype:"list",itemId:"chatList",itemTpl:new Ext.XTemplate('<tpl if="xindex % 2 === 0">',' <img class="odd" src="http://www.gravatar.com/avatar/{gravatar}?s=28&d=mm" />',' <p class="triangle-right left"><span class="nickname">{nickname}:</span> {message}</p>',"</tpl>",'<tpl if="xindex % 2 === 1">',' <p class="triangle-right right"><span class="nickname">{nickname}:</span> {message}</p>',' <img class="even" src="http://www.gravatar.com/avatar/{gravatar}?s=28&d=mm" />',"</tpl>"),store:this.store,scroll:"vertical"}]};Ext.apply(this,A);App.View.Chat.superclass.initComponent.call(this);this.addEventListener()},addEventListener:function(){this.store.on("datachanged",this.scrollToBottom,this)},scrollToBottom:function(){var A=this.getComponent("chatList");A.scroller.updateBoundary();A.scroller.scrollTo({x:0,y:A.scroller.size.height},true)}});Ext.reg("App.View.Chat",App.View.Chat);
+Ext.util.MD5=function(O,M,L,I){M=M||false;L=L||false;I=I||8;function G(P,S){var R=(P&65535)+(S&65535);var Q=(P>>16)+(S>>16)+(R>>16);return(Q<<16)|(R&65535)}function K(P,Q){return(P<<Q)|(P>>>(32-Q))}function C(U,R,Q,P,T,S){return G(K(G(G(R,U),G(P,S)),T),Q)}function H(R,Q,V,U,P,T,S){return C((Q&V)|((~Q)&U),R,Q,P,T,S)}function B(R,Q,V,U,P,T,S){return C((Q&U)|(V&(~U)),R,Q,P,T,S)}function J(R,Q,V,U,P,T,S){return C(Q^V^U,R,Q,P,T,S)}function F(R,Q,V,U,P,T,S){return C(V^(Q|(~U)),R,Q,P,T,S)}function E(Z,U){Z[U>>5]|=128<<((U)%32);Z[(((U+64)>>>9)<<4)+14]=U;var Y=1732584193;var X=-271733879;var W=-1732584194;var V=271733878;for(var R=0;R<Z.length;R+=16){var T=Y;var S=X;var Q=W;var P=V;Y=H(Y,X,W,V,Z[R+0],7,-680876936);V=H(V,Y,X,W,Z[R+1],12,-389564586);W=H(W,V,Y,X,Z[R+2],17,606105819);X=H(X,W,V,Y,Z[R+3],22,-1044525330);Y=H(Y,X,W,V,Z[R+4],7,-176418897);V=H(V,Y,X,W,Z[R+5],12,1200080426);W=H(W,V,Y,X,Z[R+6],17,-1473231341);X=H(X,W,V,Y,Z[R+7],22,-45705983);Y=H(Y,X,W,V,Z[R+8],7,1770035416);V=H(V,Y,X,W,Z[R+9],12,-1958414417);W=H(W,V,Y,X,Z[R+10],17,-42063);X=H(X,W,V,Y,Z[R+11],22,-1990404162);Y=H(Y,X,W,V,Z[R+12],7,1804603682);V=H(V,Y,X,W,Z[R+13],12,-40341101);W=H(W,V,Y,X,Z[R+14],17,-1502002290);X=H(X,W,V,Y,Z[R+15],22,1236535329);Y=B(Y,X,W,V,Z[R+1],5,-165796510);V=B(V,Y,X,W,Z[R+6],9,-1069501632);W=B(W,V,Y,X,Z[R+11],14,643717713);X=B(X,W,V,Y,Z[R+0],20,-373897302);Y=B(Y,X,W,V,Z[R+5],5,-701558691);V=B(V,Y,X,W,Z[R+10],9,38016083);W=B(W,V,Y,X,Z[R+15],14,-660478335);X=B(X,W,V,Y,Z[R+4],20,-405537848);Y=B(Y,X,W,V,Z[R+9],5,568446438);V=B(V,Y,X,W,Z[R+14],9,-1019803690);W=B(W,V,Y,X,Z[R+3],14,-187363961);X=B(X,W,V,Y,Z[R+8],20,1163531501);Y=B(Y,X,W,V,Z[R+13],5,-1444681467);V=B(V,Y,X,W,Z[R+2],9,-51403784);W=B(W,V,Y,X,Z[R+7],14,1735328473);X=B(X,W,V,Y,Z[R+12],20,-1926607734);Y=J(Y,X,W,V,Z[R+5],4,-378558);V=J(V,Y,X,W,Z[R+8],11,-2022574463);W=J(W,V,Y,X,Z[R+11],16,1839030562);X=J(X,W,V,Y,Z[R+14],23,-35309556);Y=J(Y,X,W,V,Z[R+1],4,-1530992060);V=J(V,Y,X,W,Z[R+4],11,1272893353);W=J(W,V,Y,X,Z[R+7],16,-155497632);X=J(X,W,V,Y,Z[R+10],23,-1094730640);Y=J(Y,X,W,V,Z[R+13],4,681279174);V=J(V,Y,X,W,Z[R+0],11,-358537222);W=J(W,V,Y,X,Z[R+3],16,-722521979);X=J(X,W,V,Y,Z[R+6],23,76029189);Y=J(Y,X,W,V,Z[R+9],4,-640364487);V=J(V,Y,X,W,Z[R+12],11,-421815835);W=J(W,V,Y,X,Z[R+15],16,530742520);X=J(X,W,V,Y,Z[R+2],23,-995338651);Y=F(Y,X,W,V,Z[R+0],6,-198630844);V=F(V,Y,X,W,Z[R+7],10,1126891415);W=F(W,V,Y,X,Z[R+14],15,-1416354905);X=F(X,W,V,Y,Z[R+5],21,-57434055);Y=F(Y,X,W,V,Z[R+12],6,1700485571);V=F(V,Y,X,W,Z[R+3],10,-1894986606);W=F(W,V,Y,X,Z[R+10],15,-1051523);X=F(X,W,V,Y,Z[R+1],21,-2054922799);Y=F(Y,X,W,V,Z[R+8],6,1873313359);V=F(V,Y,X,W,Z[R+15],10,-30611744);W=F(W,V,Y,X,Z[R+6],15,-1560198380);X=F(X,W,V,Y,Z[R+13],21,1309151649);Y=F(Y,X,W,V,Z[R+4],6,-145523070);V=F(V,Y,X,W,Z[R+11],10,-1120210379);W=F(W,V,Y,X,Z[R+2],15,718787259);X=F(X,W,V,Y,Z[R+9],21,-343485551);Y=G(Y,T);X=G(X,S);W=G(W,Q);V=G(V,P)}return[Y,X,W,V]}function A(S){var R=[];var P=(1<<I)-1;for(var Q=0;Q<S.length*I;Q+=I){R[Q>>5]|=(S.charCodeAt(Q/I)&P)<<(Q%32)}return R}function D(R){var S="";var P=(1<<I)-1;for(var Q=0;Q<R.length*32;Q+=I){S+=String.fromCharCode((R[Q>>5]>>>(Q%32))&P)}return S}function N(R){var Q=L?"0123456789ABCDEF":"0123456789abcdef";var S="";for(var P=0;P<R.length*4;P++){S+=Q.charAt((R[P>>2]>>((P%4)*8+4))&15)+Q.charAt((R[P>>2]>>((P%4)*8))&15)}return S}return(M?D(E(A(O),O.length*I)):N(E(A(O),O.length*I)))};this.io={version:"0.6",setPath:function(A){if(window.console&&console.error){console.error("io.setPath will be removed. Please set the variable WEB_SOCKET_SWF_LOCATION pointing to WebSocketMain.swf")}this.path=/\/$/.test(A)?A:A+"/";WEB_SOCKET_SWF_LOCATION=A+"lib/vendor/web-socket-js/WebSocketMain.swf"}};if("jQuery" in this){jQuery.io=this.io}if(typeof window!="undefined"){WEB_SOCKET_SWF_LOCATION="/socket.io/lib/vendor/web-socket-js/WebSocketMain.swf"}(function(){var A=false;io.util={ios:false,load:function(B){if(document.readyState=="complete"||A){return B()}if("attachEvent" in window){window.attachEvent("onload",B)}else{window.addEventListener("load",B,false)}},inherit:function(D,B){for(var C in B.prototype){D.prototype[C]=B.prototype[C]}},indexOf:function(B,E,F){for(var C=B.length,D=(F<0)?Math.max(0,C+F):F||0;D<C;D++){if(B[D]===E){return D}}return -1},isArray:function(B){return Object.prototype.toString.call(B)==="[object Array]"},merge:function(D,B){for(var C in B){if(B.hasOwnProperty(C)){D[C]=B[C]}}}};io.util.ios=/iphone|ipad/i.test(navigator.userAgent);io.util.android=/android/i.test(navigator.userAgent);io.util.opera=/opera/i.test(navigator.userAgent);io.util.load(function(){A=true})})();(function(){var A="~m~",B=function(C){if(Object.prototype.toString.call(C)=="[object Object]"){if(!("JSON" in window)){if("console" in window&&console.error){console.error("Trying to encode as JSON, but JSON.stringify is missing.")}return'{ "$error": "Invalid message" }'}return"~j~"+JSON.stringify(C)}else{return String(C)}};Transport=io.Transport=function(D,C){this.base=D;this.options={timeout:15000};io.util.merge(this.options,C)};Transport.prototype.send=function(){throw new Error("Missing send() implementation")};Transport.prototype.connect=function(){throw new Error("Missing connect() implementation")};Transport.prototype.disconnect=function(){throw new Error("Missing disconnect() implementation")};Transport.prototype._encode=function(G){var D="",F,G=io.util.isArray(G)?G:[G];for(var E=0,C=G.length;E<C;E++){F=G[E]===null||G[E]===undefined?"":B(G[E]);D+=A+F.length+A+F}return D};Transport.prototype._decode=function(G){var F=[],E,H;do{if(G.substr(0,3)!==A){return F}G=G.substr(3);E="",H="";for(var D=0,C=G.length;D<C;D++){H=Number(G.substr(D,1));if(G.substr(D,1)==H){E+=H}else{G=G.substr(E.length+A.length);E=Number(E);break}}F.push(G.substr(0,E));G=G.substr(E)}while(G!=="");return F};Transport.prototype._onData=function(F){this._setTimeout();var E=this._decode(F);if(E&&E.length){for(var D=0,C=E.length;D<C;D++){this._onMessage(E[D])}}};Transport.prototype._setTimeout=function(){var C=this;if(this._timeout){clearTimeout(this._timeout)}this._timeout=setTimeout(function(){C._onTimeout()},this.options.timeout)};Transport.prototype._onTimeout=function(){this._onDisconnect()};Transport.prototype._onMessage=function(C){if(!this.sessionid){this.sessionid=C;this._onConnect()}else{if(C.substr(0,3)=="~h~"){this._onHeartbeat(C.substr(3))}else{if(C.substr(0,3)=="~j~"){this.base._onMessage(JSON.parse(C.substr(3)))}else{this.base._onMessage(C)}}}},Transport.prototype._onHeartbeat=function(C){this.send("~h~"+C)};Transport.prototype._onConnect=function(){this.connected=true;this.connecting=false;this.base._onConnect();this._setTimeout()};Transport.prototype._onDisconnect=function(){this.connecting=false;this.connected=false;this.sessionid=null;this.base._onDisconnect()};Transport.prototype._prepareUrl=function(){return(this.base.options.secure?"https":"http")+"://"+this.base.host+":"+this.base.options.port+"/"+this.base.options.resource+"/"+this.type+(this.sessionid?("/"+this.sessionid):"/")}})();(function(){var D=new Function,A=(function(){if(!("XMLHttpRequest" in window)){return false}var E=new XMLHttpRequest();return E.withCredentials!=undefined})(),C=function(G){if("XDomainRequest" in window&&G){return new XDomainRequest()}if("XMLHttpRequest" in window&&(!G||A)){return new XMLHttpRequest()}if(!G){try{var F=new ActiveXObject("MSXML2.XMLHTTP");return F}catch(H){}try{var E=new ActiveXObject("Microsoft.XMLHTTP");return E}catch(H){}}return false},B=io.Transport.XHR=function(){io.Transport.apply(this,arguments);this._sendBuffer=[]};io.util.inherit(B,io.Transport);B.prototype.connect=function(){this._get();return this};B.prototype._checkSend=function(){if(!this._posting&&this._sendBuffer.length){var E=this._encode(this._sendBuffer);this._sendBuffer=[];this._send(E)}};B.prototype.send=function(E){if(io.util.isArray(E)){this._sendBuffer.push.apply(this._sendBuffer,E)}else{this._sendBuffer.push(E)}this._checkSend();return this};B.prototype._send=function(F){var E=this;this._posting=true;this._sendXhr=this._request("send","POST");this._sendXhr.onreadystatechange=function(){var G;if(E._sendXhr.readyState==4){E._sendXhr.onreadystatechange=D;try{G=E._sendXhr.status}catch(H){}E._posting=false;if(G==200){E._checkSend()}else{E._onDisconnect()}}};this._sendXhr.send("data="+encodeURIComponent(F))};B.prototype.disconnect=function(){this._onDisconnect();return this};B.prototype._onDisconnect=function(){if(this._xhr){this._xhr.onreadystatechange=this._xhr.onload=D;this._xhr.abort();this._xhr=null}if(this._sendXhr){this._sendXhr.onreadystatechange=this._sendXhr.onload=D;this._sendXhr.abort();this._sendXhr=null}this._sendBuffer=[];io.Transport.prototype._onDisconnect.call(this)};B.prototype._request=function(F,H,E){var G=C(this.base._isXDomain());if(E){G.multipart=true}G.open(H||"GET",this._prepareUrl()+(F?"/"+F:""));if(H=="POST"&&"setRequestHeader" in G){G.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=utf-8")}return G};B.check=function(E){try{if(C(E)){return true}}catch(F){}return false};B.xdomainCheck=function(){return B.check(true)};B.request=C})();(function(){var A=io.Transport.websocket=function(){io.Transport.apply(this,arguments)};io.util.inherit(A,io.Transport);A.prototype.type="websocket";A.prototype.connect=function(){var B=this;this.socket=new WebSocket(this._prepareUrl());this.socket.onmessage=function(C){B._onData(C.data)};this.socket.onclose=function(C){B._onClose()};return this};A.prototype.send=function(B){if(this.socket){this.socket.send(this._encode(B))}return this};A.prototype.disconnect=function(){if(this.socket){this.socket.close()}return this};A.prototype._onClose=function(){this._onDisconnect();return this};A.prototype._prepareUrl=function(){return(this.base.options.secure?"wss":"ws")+"://"+this.base.host+":"+this.base.options.port+"/"+this.base.options.resource+"/"+this.type+(this.sessionid?("/"+this.sessionid):"")};A.check=function(){return"WebSocket" in window&&WebSocket.prototype&&(WebSocket.prototype.send&&!!WebSocket.prototype.send.toString().match(/native/i))&&typeof WebSocket!=="undefined"};A.xdomainCheck=function(){return true}})();(function(){var A=io.Transport.flashsocket=function(){io.Transport.websocket.apply(this,arguments)};io.util.inherit(A,io.Transport.websocket);A.prototype.type="flashsocket";A.prototype.connect=function(){var B=this,C=arguments;WebSocket.__addTask(function(){io.Transport.websocket.prototype.connect.apply(B,C)});return this};A.prototype.send=function(){var B=this,C=arguments;WebSocket.__addTask(function(){io.Transport.websocket.prototype.send.apply(B,C)});return this};A.check=function(){if(typeof WebSocket=="undefined"||!("__addTask" in WebSocket)){return false}if(io.util.opera){return false}if("navigator" in window&&"plugins" in navigator&&navigator.plugins["Shockwave Flash"]){return !!navigator.plugins["Shockwave Flash"].description}if("ActiveXObject" in window){try{return !!new ActiveXObject("ShockwaveFlash.ShockwaveFlash").GetVariable("$version")}catch(B){}}return false};A.xdomainCheck=function(){return true}})();(function(){var A=io.Transport.htmlfile=function(){io.Transport.XHR.apply(this,arguments)};io.util.inherit(A,io.Transport.XHR);A.prototype.type="htmlfile";A.prototype._get=function(){var B=this;this._open();window.attachEvent("onunload",function(){B._destroy()})};A.prototype._open=function(){this._doc=new ActiveXObject("htmlfile");this._doc.open();this._doc.write("<html></html>");this._doc.parentWindow.s=this;this._doc.close();var B=this._doc.createElement("div");this._doc.body.appendChild(B);this._iframe=this._doc.createElement("iframe");B.appendChild(this._iframe);this._iframe.src=this._prepareUrl()+"/"+(+new Date)};A.prototype._=function(C,D){this._onData(C);var B=D.getElementsByTagName("script")[0];B.parentNode.removeChild(B)};A.prototype._destroy=function(){if(this._iframe){this._iframe.src="about:blank";this._doc=null;CollectGarbage()}};A.prototype.disconnect=function(){this._destroy();return io.Transport.XHR.prototype.disconnect.call(this)};A.check=function(){if("ActiveXObject" in window){try{var B=new ActiveXObject("htmlfile");return B&&io.Transport.XHR.check()}catch(C){}}return false};A.xdomainCheck=function(){return false}})();(function(){var A=io.Transport["xhr-multipart"]=function(){io.Transport.XHR.apply(this,arguments)};io.util.inherit(A,io.Transport.XHR);A.prototype.type="xhr-multipart";A.prototype._get=function(){var B=this;this._xhr=this._request("","GET",true);this._xhr.onreadystatechange=function(){if(B._xhr.readyState==3){B._onData(B._xhr.responseText)}};this._xhr.send()};A.check=function(){return"XMLHttpRequest" in window&&"prototype" in XMLHttpRequest&&"multipart" in XMLHttpRequest.prototype};A.xdomainCheck=function(){return true}})();(function(){var A=new Function(),B=io.Transport["xhr-polling"]=function(){io.Transport.XHR.apply(this,arguments)};io.util.inherit(B,io.Transport.XHR);B.prototype.type="xhr-polling";B.prototype.connect=function(){if(io.util.ios||io.util.android){var C=this;io.util.load(function(){setTimeout(function(){io.Transport.XHR.prototype.connect.call(C)},10)})}else{io.Transport.XHR.prototype.connect.call(this)}};B.prototype._get=function(){var C=this;this._xhr=this._request(+new Date,"GET");if("onload" in this._xhr){this._xhr.onload=function(){C._onData(this.responseText);C._get()}}else{this._xhr.onreadystatechange=function(){var D;if(C._xhr.readyState==4){C._xhr.onreadystatechange=A;try{D=C._xhr.status}catch(E){}if(D==200){C._onData(C._xhr.responseText);C._get()}else{C._onDisconnect()}}}}this._xhr.send()};B.check=function(){return io.Transport.XHR.check()};B.xdomainCheck=function(){return io.Transport.XHR.xdomainCheck()}})();io.JSONP=[];JSONPPolling=io.Transport["jsonp-polling"]=function(){io.Transport.XHR.apply(this,arguments);this._insertAt=document.getElementsByTagName("script")[0];this._index=io.JSONP.length;io.JSONP.push(this)};io.util.inherit(JSONPPolling,io.Transport["xhr-polling"]);JSONPPolling.prototype.type="jsonp-polling";JSONPPolling.prototype._send=function(G){var I=this;if(!("_form" in this)){var B=document.createElement("FORM"),C=document.createElement("TEXTAREA"),A=this._iframeId="socket_io_iframe_"+this._index,F;B.style.position="absolute";B.style.top="-1000px";B.style.left="-1000px";B.target=A;B.method="POST";B.action=this._prepareUrl()+"/"+(+new Date)+"/"+this._index;C.name="data";B.appendChild(C);this._insertAt.parentNode.insertBefore(B,this._insertAt);document.body.appendChild(B);this._form=B;this._area=C}function D(){E();I._posting=false;I._checkSend()}function E(){if(I._iframe){I._form.removeChild(I._iframe)}try{F=document.createElement('<iframe name="'+I._iframeId+'">')}catch(J){F=document.createElement("iframe");F.name=I._iframeId}F.id=I._iframeId;I._form.appendChild(F);I._iframe=F}E();this._posting=true;this._area.value=G;try{this._form.submit()}catch(H){}if(this._iframe.attachEvent){F.onreadystatechange=function(){if(I._iframe.readyState=="complete"){D()}}}else{this._iframe.onload=D}};JSONPPolling.prototype._get=function(){var B=this,A=document.createElement("SCRIPT");if(this._script){this._script.parentNode.removeChild(this._script);this._script=null}A.async=true;A.src=this._prepareUrl()+"/"+(+new Date)+"/"+this._index;A.onerror=function(){B._onDisconnect()};this._insertAt.parentNode.insertBefore(A,this._insertAt);this._script=A};JSONPPolling.prototype._=function(){this._onData.apply(this,arguments);this._get();return this};JSONPPolling.check=function(){return true};JSONPPolling.xdomainCheck=function(){return true};(function(){var A=io.Socket=function(C,B){this.host=C||document.domain;this.options={secure:false,document:document,port:document.location.port||80,resource:"socket.io",transports:["websocket","flashsocket","htmlfile","xhr-multipart","xhr-polling","jsonp-polling"],transportOptions:{"xhr-polling":{timeout:25000},"jsonp-polling":{timeout:25000}},connectTimeout:5000,tryTransportsOnConnectTimeout:true,rememberTransport:true};io.util.merge(this.options,B);this.connected=false;this.connecting=false;this._events={};this.transport=this.getTransport();if(!this.transport&&"console" in window){console.error("No transport available")}};A.prototype.getTransport=function(E){var B=E||this.options.transports,C;if(this.options.rememberTransport&&!E){C=this.options.document.cookie.match("(?:^|;)\\s*socketio=([^;]*)");if(C){this._rememberedTransport=true;B=[decodeURIComponent(C[1])]}}for(var D=0,F;F=B[D];D++){if(io.Transport[F]&&io.Transport[F].check()&&(!this._isXDomain()||io.Transport[F].xdomainCheck())){return new io.Transport[F](this,this.options.transportOptions[F]||{})}}return null};A.prototype.connect=function(){if(this.transport&&!this.connected){if(this.connecting){this.disconnect()}this.connecting=true;this.transport.connect();if(this.options.connectTimeout){var B=this;setTimeout(function(){if(!B.connected){B.disconnect();if(B.options.tryTransportsOnConnectTimeout&&!B._rememberedTransport){var C=[],D=B.options.transports;for(var E=0,F;F=D[E];E++){if(F!=B.transport.type){C.push(F)}}if(C.length){B.transport=B.getTransport(C);B.connect()}}}},this.options.connectTimeout)}}return this};A.prototype.send=function(B){if(!this.transport||!this.transport.connected){return this._queue(B)}this.transport.send(B);return this};A.prototype.disconnect=function(){this.transport.disconnect();return this};A.prototype.on=function(B,C){if(!(B in this._events)){this._events[B]=[]}this._events[B].push(C);return this};A.prototype.fire=function(C,B){if(C in this._events){for(var D=0,E=this._events[C].length;D<E;D++){this._events[C][D].apply(this,B===undefined?[]:B)}}return this};A.prototype.removeEvent=function(D,E){if(D in this._events){for(var C=0,B=this._events[D].length;C<B;C++){if(this._events[D][C]==E){this._events[D].splice(C,1)}}}return this};A.prototype._queue=function(B){if(!("_queueStack" in this)){this._queueStack=[]}this._queueStack.push(B);return this};A.prototype._doQueue=function(){if(!("_queueStack" in this)||!this._queueStack.length){return this}this.transport.send(this._queueStack);this._queueStack=[];return this};A.prototype._isXDomain=function(){return this.host!==document.domain};A.prototype._onConnect=function(){this.connected=true;this.connecting=false;this._doQueue();if(this.options.rememberTransport){this.options.document.cookie="socketio="+encodeURIComponent(this.transport.type)}this.fire("connect")};A.prototype._onMessage=function(B){this.fire("message",[B])};A.prototype._onDisconnect=function(){var B=this.connected;this.connected=false;this.connecting=false;this._queueStack=[];if(B){this.fire("disconnect")}};A.prototype.addListener=A.prototype.addEvent=A.prototype.addEventListener=A.prototype.on})();var swfobject=function(){var AQ="undefined",Ac="object",AB="Shockwave Flash",X="ShockwaveFlash.ShockwaveFlash",Ad="application/x-shockwave-flash",AC="SWFObjectExprInst",AW="onreadystatechange",AF=window,Ak=document,Aa=navigator,AA=false,Z=[Am],Af=[],AG=[],AL=[],Ai,AD,AP,AS,AK=false,At=false,Ag,AN,Ah=true,AH=function(){var A=typeof Ak.getElementById!=AQ&&typeof Ak.getElementsByTagName!=AQ&&typeof Ak.createElement!=AQ,E=Aa.userAgent.toLowerCase(),C=Aa.platform.toLowerCase(),H=C?/win/.test(C):/win/.test(E),J=C?/mac/.test(C):/mac/.test(E),G=/webkit/.test(E)?parseFloat(E.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,D=!+"\v1",F=[0,0,0],K=null;if(typeof Aa.plugins!=AQ&&typeof Aa.plugins[AB]==Ac){K=Aa.plugins[AB].description;if(K&&!(typeof Aa.mimeTypes!=AQ&&Aa.mimeTypes[Ad]&&!Aa.mimeTypes[Ad].enabledPlugin)){AA=true;D=false;K=K.replace(/^.*\s+(\S+\s+\S+$)/,"$1");F[0]=parseInt(K.replace(/^(.*)\..*$/,"$1"),10);F[1]=parseInt(K.replace(/^.*\.(.*)\s.*$/,"$1"),10);F[2]=/[a-zA-Z]/.test(K)?parseInt(K.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof AF.ActiveXObject!=AQ){try{var I=new ActiveXObject(X);if(I){K=I.GetVariable("$version");if(K){D=true;K=K.split(" ")[1].split(",");F=[parseInt(K[0],10),parseInt(K[1],10),parseInt(K[2],10)]}}}catch(B){}}}return{w3:A,pv:F,wk:G,ie:D,win:H,mac:J}}(),Aj=function(){if(!AH.w3){return }if((typeof Ak.readyState!=AQ&&Ak.readyState=="complete")||(typeof Ak.readyState==AQ&&(Ak.getElementsByTagName("body")[0]||Ak.body))){Ao()}if(!AK){if(typeof Ak.addEventListener!=AQ){Ak.addEventListener("DOMContentLoaded",Ao,false)}if(AH.ie&&AH.win){Ak.attachEvent(AW,function(){if(Ak.readyState=="complete"){Ak.detachEvent(AW,arguments.callee);Ao()}});if(AF==top){(function(){if(AK){return }try{Ak.documentElement.doScroll("left")}catch(A){setTimeout(arguments.callee,0);return }Ao()})()}}if(AH.wk){(function(){if(AK){return }if(!/loaded|complete/.test(Ak.readyState)){setTimeout(arguments.callee,0);return }Ao()})()}Ab(Ao)}}();function Ao(){if(AK){return }try{var B=Ak.getElementsByTagName("body")[0].appendChild(AR("span"));B.parentNode.removeChild(B)}catch(A){return }AK=true;var D=Z.length;for(var C=0;C<D;C++){Z[C]()}}function AJ(A){if(AK){A()}else{Z[Z.length]=A}}function Ab(A){if(typeof AF.addEventListener!=AQ){AF.addEventListener("load",A,false)}else{if(typeof Ak.addEventListener!=AQ){Ak.addEventListener("load",A,false)}else{if(typeof AF.attachEvent!=AQ){Al(AF,"onload",A)}else{if(typeof AF.onload=="function"){var B=AF.onload;AF.onload=function(){B();A()}}else{AF.onload=A}}}}}function Am(){if(AA){Y()}else{AM()}}function Y(){var D=Ak.getElementsByTagName("body")[0];var B=AR(Ac);B.setAttribute("type",Ad);var A=D.appendChild(B);if(A){var C=0;(function(){if(typeof A.GetVariable!=AQ){var E=A.GetVariable("$version");if(E){E=E.split(" ")[1].split(",");AH.pv=[parseInt(E[0],10),parseInt(E[1],10),parseInt(E[2],10)]}}else{if(C<10){C++;setTimeout(arguments.callee,10);return }}D.removeChild(B);A=null;AM()})()}else{AM()}}function AM(){var G=Af.length;if(G>0){for(var H=0;H<G;H++){var C=Af[H].id;var L=Af[H].callbackFn;var A={success:false,id:C};if(AH.pv[0]>0){var I=Ar(C);if(I){if(AO(Af[H].swfVersion)&&!(AH.wk&&AH.wk<312)){AX(C,true);if(L){A.success=true;A.ref=AU(C);L(A)}}else{if(Af[H].expressInstall&&AT()){var E={};E.data=Af[H].expressInstall;E.width=I.getAttribute("width")||"0";E.height=I.getAttribute("height")||"0";if(I.getAttribute("class")){E.styleclass=I.getAttribute("class")}if(I.getAttribute("align")){E.align=I.getAttribute("align")}var F={};var D=I.getElementsByTagName("param");var K=D.length;for(var J=0;J<K;J++){if(D[J].getAttribute("name").toLowerCase()!="movie"){F[D[J].getAttribute("name")]=D[J].getAttribute("value")}}AE(E,F,C,L)}else{Ae(I);if(L){L(A)}}}}}else{AX(C,true);if(L){var B=AU(C);if(B&&typeof B.SetVariable!=AQ){A.success=true;A.ref=B}L(A)}}}}}function AU(B){var D=null;var C=Ar(B);if(C&&C.nodeName=="OBJECT"){if(typeof C.SetVariable!=AQ){D=C}else{var A=C.getElementsByTagName(Ac)[0];if(A){D=A}}}return D}function AT(){return !At&&AO("6.0.65")&&(AH.win||AH.mac)&&!(AH.wk&&AH.wk<312)}function AE(F,D,H,E){At=true;AP=E||null;AS={success:false,id:H};var A=Ar(H);if(A){if(A.nodeName=="OBJECT"){Ai=An(A);AD=null}else{Ai=A;AD=H}F.id=AC;if(typeof F.width==AQ||(!/%$/.test(F.width)&&parseInt(F.width,10)<310)){F.width="310"}if(typeof F.height==AQ||(!/%$/.test(F.height)&&parseInt(F.height,10)<137)){F.height="137"}Ak.title=Ak.title.slice(0,47)+" - Flash Player Installation";var B=AH.ie&&AH.win?"ActiveX":"PlugIn",C="MMredirectURL="+AF.location.toString().replace(/&/g,"%26")+"&MMplayerType="+B+"&MMdoctitle="+Ak.title;if(typeof D.flashvars!=AQ){D.flashvars+="&"+C}else{D.flashvars=C}if(AH.ie&&AH.win&&A.readyState!=4){var G=AR("div");H+="SWFObjectNew";G.setAttribute("id",H);A.parentNode.insertBefore(G,A);A.style.display="none";(function(){if(A.readyState==4){A.parentNode.removeChild(A)}else{setTimeout(arguments.callee,10)}})()}AZ(F,D,H)}}function Ae(A){if(AH.ie&&AH.win&&A.readyState!=4){var B=AR("div");A.parentNode.insertBefore(B,A);B.parentNode.replaceChild(An(A),B);A.style.display="none";(function(){if(A.readyState==4){A.parentNode.removeChild(A)}else{setTimeout(arguments.callee,10)}})()}else{A.parentNode.replaceChild(An(A),A)}}function An(B){var D=AR("div");if(AH.win&&AH.ie){D.innerHTML=B.innerHTML}else{var E=B.getElementsByTagName(Ac)[0];if(E){var A=E.childNodes;if(A){var F=A.length;for(var C=0;C<F;C++){if(!(A[C].nodeType==1&&A[C].nodeName=="PARAM")&&!(A[C].nodeType==8)){D.appendChild(A[C].cloneNode(true))}}}}}return D}function AZ(E,G,C){var D,A=Ar(C);if(AH.wk&&AH.wk<312){return D}if(A){if(typeof E.id==AQ){E.id=C}if(AH.ie&&AH.win){var F="";for(var I in E){if(E[I]!=Object.prototype[I]){if(I.toLowerCase()=="data"){G.movie=E[I]}else{if(I.toLowerCase()=="styleclass"){F+=' class="'+E[I]+'"'}else{if(I.toLowerCase()!="classid"){F+=" "+I+'="'+E[I]+'"'}}}}}var H="";for(var J in G){if(G[J]!=Object.prototype[J]){H+='<param name="'+J+'" value="'+G[J]+'" />'}}A.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+F+">"+H+"</object>";AG[AG.length]=E.id;D=Ar(E.id)}else{var B=AR(Ac);B.setAttribute("type",Ad);for(var K in E){if(E[K]!=Object.prototype[K]){if(K.toLowerCase()=="styleclass"){B.setAttribute("class",E[K])}else{if(K.toLowerCase()!="classid"){B.setAttribute(K,E[K])}}}}for(var L in G){if(G[L]!=Object.prototype[L]&&L.toLowerCase()!="movie"){Ap(B,L,G[L])}}A.parentNode.replaceChild(B,A);D=B}}return D}function Ap(B,D,C){var A=AR("param");A.setAttribute("name",D);A.setAttribute("value",C);B.appendChild(A)}function AV(A){var B=Ar(A);if(B&&B.nodeName=="OBJECT"){if(AH.ie&&AH.win){B.style.display="none";(function(){if(B.readyState==4){As(A)}else{setTimeout(arguments.callee,10)}})()}else{B.parentNode.removeChild(B)}}}function As(A){var B=Ar(A);if(B){for(var C in B){if(typeof B[C]=="function"){B[C]=null}}B.parentNode.removeChild(B)}}function Ar(A){var C=null;try{C=Ak.getElementById(A)}catch(B){}return C}function AR(A){return Ak.createElement(A)}function Al(A,C,B){A.attachEvent(C,B);AL[AL.length]=[A,C,B]}function AO(A){var B=AH.pv,C=A.split(".");C[0]=parseInt(C[0],10);C[1]=parseInt(C[1],10)||0;C[2]=parseInt(C[2],10)||0;return(B[0]>C[0]||(B[0]==C[0]&&B[1]>C[1])||(B[0]==C[0]&&B[1]==C[1]&&B[2]>=C[2]))?true:false}function AY(B,F,A,C){if(AH.ie&&AH.mac){return }var E=Ak.getElementsByTagName("head")[0];if(!E){return }var G=(A&&typeof A=="string")?A:"screen";if(C){Ag=null;AN=null}if(!Ag||AN!=G){var D=AR("style");D.setAttribute("type","text/css");D.setAttribute("media",G);Ag=E.appendChild(D);if(AH.ie&&AH.win&&typeof Ak.styleSheets!=AQ&&Ak.styleSheets.length>0){Ag=Ak.styleSheets[Ak.styleSheets.length-1]}AN=G}if(AH.ie&&AH.win){if(Ag&&typeof Ag.addRule==Ac){Ag.addRule(B,F)}}else{if(Ag&&typeof Ak.createTextNode!=AQ){Ag.appendChild(Ak.createTextNode(B+" {"+F+"}"))}}}function AX(A,C){if(!Ah){return }var B=C?"visible":"hidden";if(AK&&Ar(A)){Ar(A).style.visibility=B}else{AY("#"+A,"visibility:"+B)}}function AI(B){var A=/[\\\"<>\.;]/;var C=A.exec(B)!=null;return C&&typeof encodeURIComponent!=AQ?encodeURIComponent(B):B}var Aq=function(){if(AH.ie&&AH.win){window.attachEvent("onunload",function(){var A=AL.length;for(var B=0;B<A;B++){AL[B][0].detachEvent(AL[B][1],AL[B][2])}var D=AG.length;for(var C=0;C<D;C++){AV(AG[C])}for(var E in AH){AH[E]=null}AH=null;for(var F in swfobject){swfobject[F]=null}swfobject=null})}}();return{registerObject:function(A,E,C,B){if(AH.w3&&A&&E){var D={};D.id=A;D.swfVersion=E;D.expressInstall=C;D.callbackFn=B;Af[Af.length]=D;AX(A,false)}else{if(B){B({success:false,id:A})}}},getObjectById:function(A){if(AH.w3){return AU(A)}},embedSWF:function(K,E,H,F,C,A,B,I,G,J){var D={success:false,id:E};if(AH.w3&&!(AH.wk&&AH.wk<312)&&K&&E&&H&&F&&C){AX(E,false);AJ(function(){H+="";F+="";var Q={};if(G&&typeof G===Ac){for(var O in G){Q[O]=G[O]}}Q.data=K;Q.width=H;Q.height=F;var N={};if(I&&typeof I===Ac){for(var P in I){N[P]=I[P]}}if(B&&typeof B===Ac){for(var L in B){if(typeof N.flashvars!=AQ){N.flashvars+="&"+L+"="+B[L]}else{N.flashvars=L+"="+B[L]}}}if(AO(C)){var M=AZ(Q,N,E);if(Q.id==E){AX(E,true)}D.success=true;D.ref=M}else{if(A&&AT()){Q.data=A;AE(Q,N,E,J);return }else{AX(E,true)}}if(J){J(D)}})}else{if(J){J(D)}}},switchOffAutoHideShow:function(){Ah=false},ua:AH,getFlashPlayerVersion:function(){return{major:AH.pv[0],minor:AH.pv[1],release:AH.pv[2]}},hasFlashPlayerVersion:AO,createSWF:function(A,B,C){if(AH.w3){return AZ(A,B,C)}else{return undefined}},showExpressInstall:function(B,A,D,C){if(AH.w3&&AT()){AE(B,A,D,C)}},removeSWF:function(A){if(AH.w3){AV(A)}},createCSS:function(B,A,C,D){if(AH.w3){AY(B,A,C,D)}},addDomLoadEvent:AJ,addLoadEvent:Ab,getQueryParamValue:function(B){var A=Ak.location.search||Ak.location.hash;if(A){if(/\?/.test(A)){A=A.split("?")[1]}if(B==null){return AI(A)}var C=A.split("&");for(var D=0;D<C.length;D++){if(C[D].substring(0,C[D].indexOf("="))==B){return AI(C[D].substring((C[D].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(At){var A=Ar(AC);if(A&&Ai){A.parentNode.replaceChild(Ai,A);if(AD){AX(AD,true);if(AH.ie&&AH.win){Ai.style.display="block"}}if(AP){AP(AS)}}At=false}}}}();function FABridge(B,A){this.target=B;this.remoteTypeCache={};this.remoteInstanceCache={};this.remoteFunctionCache={};this.localFunctionCache={};this.bridgeID=FABridge.nextBridgeID++;this.name=A;this.nextLocalFuncID=0;FABridge.instances[this.name]=this;FABridge.idMap[this.bridgeID]=this;return this}FABridge.TYPE_ASINSTANCE=1;FABridge.TYPE_ASFUNCTION=2;FABridge.TYPE_JSFUNCTION=3;FABridge.TYPE_ANONYMOUS=4;FABridge.initCallbacks={};FABridge.userTypes={};FABridge.addToUserTypes=function(){for(var A=0;A<arguments.length;A++){FABridge.userTypes[arguments[A]]={typeName:arguments[A],enriched:false}}};FABridge.argsToArray=function(B){var A=[];for(var C=0;C<B.length;C++){A[C]=B[C]}return A};function instanceFactory(A){this.fb_instance_id=A;return this}function FABridge__invokeJSFunction(A){var C=A[0];var B=A.concat();B.shift();var D=FABridge.extractBridgeFromID(C);return D.invokeLocalFunction(C,B)}FABridge.addInitializationCallback=function(B,D){var C=FABridge.instances[B];if(C!=undefined){D.call(C);return }var A=FABridge.initCallbacks[B];if(A==null){FABridge.initCallbacks[B]=A=[]}A.push(D)};function FABridge__bridgeInitialized(G){var A=document.getElementsByTagName("object");var F=A.length;var D=[];if(F>0){for(var P=0;P<F;P++){if(typeof A[P].SetVariable!="undefined"){D[D.length]=A[P]}}}var I=document.getElementsByTagName("embed");var B=I.length;var O=[];if(B>0){for(var M=0;M<B;M++){if(typeof I[M].SetVariable!="undefined"){O[O.length]=I[M]}}}var C=D.length;var N=O.length;var H="bridgeName="+G;if((C==1&&!N)||(C==1&&N==1)){FABridge.attachBridge(D[0],G)}else{if(N==1&&!C){FABridge.attachBridge(O[0],G)}else{var Q=false;if(C>1){for(var L=0;L<C;L++){var S=D[L].childNodes;for(var K=0;K<S.length;K++){var E=S[K];if(E.nodeType==1&&E.tagName.toLowerCase()=="param"&&E.name.toLowerCase()=="flashvars"&&E.value.indexOf(H)>=0){FABridge.attachBridge(D[L],G);Q=true;break}}if(Q){break}}}if(!Q&&N>1){for(var J=0;J<N;J++){var R=O[J].attributes.getNamedItem("flashVars").nodeValue;if(R.indexOf(H)>=0){FABridge.attachBridge(O[J],G);break}}}}}return true}FABridge.nextBridgeID=0;FABridge.instances={};FABridge.idMap={};FABridge.refCount=0;FABridge.extractBridgeFromID=function(B){var A=(B>>16);return FABridge.idMap[A]};FABridge.attachBridge=function(A,C){var B=new FABridge(A,C);FABridge[C]=B;var E=FABridge.initCallbacks[C];if(E==null){return }for(var D=0;D<E.length;D++){E[D].call(B)}delete FABridge.initCallbacks[C]};FABridge.blockedMethods={toString:true,get:true,set:true,call:true};FABridge.prototype={root:function(){return this.deserialize(this.target.getRoot())},releaseASObjects:function(){return this.target.releaseASObjects()},releaseNamedASObject:function(B){if(typeof (B)!="object"){return false}else{var A=this.target.releaseNamedASObject(B.fb_instance_id);return A}},create:function(A){return this.deserialize(this.target.create(A))},makeID:function(A){return(this.bridgeID<<16)+A},getPropertyFromAS:function(B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.getPropFromAS(B,A);retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},setPropertyInAS:function(C,B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.setPropInAS(C,B,this.serialize(A));retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},callASFunction:function(B,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;retVal=this.target.invokeASFunction(B,this.serialize(A));retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},callASMethod:function(B,C,A){if(FABridge.refCount>0){throw new Error("You are trying to call recursively into the Flash Player which is not allowed. In most cases the JavaScript setTimeout function, can be used as a workaround.")}else{FABridge.refCount++;A=this.serialize(A);retVal=this.target.invokeASMethod(B,C,A);retVal=this.handleError(retVal);FABridge.refCount--;return retVal}},invokeLocalFunction:function(D,B){var A;var C=this.localFunctionCache[D];if(C!=undefined){A=this.serialize(C.apply(null,this.deserialize(B)))}return A},getTypeFromName:function(A){return this.remoteTypeCache[A]},createProxy:function(C,B){var D=this.getTypeFromName(B);instanceFactory.prototype=D;var A=new instanceFactory(C);this.remoteInstanceCache[C]=A;return A},getProxy:function(A){return this.remoteInstanceCache[A]},addTypeDataToCache:function(E){var C=new ASProxy(this,E.name);var B=E.accessors;for(var D=0;D<B.length;D++){this.addPropertyToType(C,B[D])}var A=E.methods;for(var D=0;D<A.length;D++){if(FABridge.blockedMethods[A[D]]==undefined){this.addMethodToType(C,A[D])}}this.remoteTypeCache[C.typeName]=C;return C},addPropertyToType:function(A,D){var E=D.charAt(0);var B;var C;if(E>="a"&&E<="z"){C="get"+E.toUpperCase()+D.substr(1);B="set"+E.toUpperCase()+D.substr(1)}else{C="get"+D;B="set"+D}A[B]=function(F){this.bridge.setPropertyInAS(this.fb_instance_id,D,F)};A[C]=function(){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,D))}},addMethodToType:function(A,B){A[B]=function(){return this.bridge.deserialize(this.bridge.callASMethod(this.fb_instance_id,B,FABridge.argsToArray(arguments)))}},getFunctionProxy:function(A){var B=this;if(this.remoteFunctionCache[A]==null){this.remoteFunctionCache[A]=function(){B.callASFunction(A,FABridge.argsToArray(arguments))}}return this.remoteFunctionCache[A]},getFunctionID:function(A){if(A.__bridge_id__==undefined){A.__bridge_id__=this.makeID(this.nextLocalFuncID++);this.localFunctionCache[A.__bridge_id__]=A}return A.__bridge_id__},serialize:function(D){var A={};var C=typeof (D);if(C=="number"||C=="string"||C=="boolean"||C==null||C==undefined){A=D}else{if(D instanceof Array){A=[];for(var B=0;B<D.length;B++){A[B]=this.serialize(D[B])}}else{if(C=="function"){A.type=FABridge.TYPE_JSFUNCTION;A.value=this.getFunctionID(D)}else{if(D instanceof ASProxy){A.type=FABridge.TYPE_ASINSTANCE;A.value=D.fb_instance_id}else{A.type=FABridge.TYPE_ANONYMOUS;A.value=D}}}}return A},deserialize:function(E){var A;var C=typeof (E);if(C=="number"||C=="string"||C=="boolean"||E==null||E==undefined){A=this.handleError(E)}else{if(E instanceof Array){A=[];for(var B=0;B<E.length;B++){A[B]=this.deserialize(E[B])}}else{if(C=="object"){for(var B=0;B<E.newTypes.length;B++){this.addTypeDataToCache(E.newTypes[B])}for(var D in E.newRefs){this.createProxy(D,E.newRefs[D])}if(E.type==FABridge.TYPE_PRIMITIVE){A=E.value}else{if(E.type==FABridge.TYPE_ASFUNCTION){A=this.getFunctionProxy(E.value)}else{if(E.type==FABridge.TYPE_ASINSTANCE){A=this.getProxy(E.value)}else{if(E.type==FABridge.TYPE_ANONYMOUS){A=E.value}}}}}}}return A},addRef:function(A){this.target.incRef(A.fb_instance_id)},release:function(A){this.target.releaseRef(A.fb_instance_id)},handleError:function(B){if(typeof (B)=="string"&&B.indexOf("__FLASHERROR")==0){var A=B.split("||");if(FABridge.refCount>0){FABridge.refCount--}throw new Error(A[1]);return B}else{return B}}};ASProxy=function(B,A){this.bridge=B;this.typeName=A;return this};ASProxy.prototype={get:function(A){return this.bridge.deserialize(this.bridge.getPropertyFromAS(this.fb_instance_id,A))},set:function(B,A){this.bridge.setPropertyInAS(this.fb_instance_id,B,A)},call:function(B,A){this.bridge.callASMethod(this.fb_instance_id,B,A)},addRef:function(){this.bridge.addRef(this)},release:function(){this.bridge.release(this)}};(function(){if(window.WebSocket){return }var A=window.console;if(!A){A={log:function(){},error:function(){}}}if(!swfobject.hasFlashPlayerVersion("9.0.0")){A.error("Flash Player is not installed.");return }if(location.protocol=="file:"){A.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://...")}WebSocket=function(E,H,D,G,F){var C=this;C.readyState=WebSocket.CONNECTING;C.bufferedAmount=0;setTimeout(function(){WebSocket.__addTask(function(){C.__createFlash(E,H,D,G,F)})},1)};WebSocket.prototype.__createFlash=function(E,H,D,G,F){var C=this;C.__flash=WebSocket.__flash.create(E,H,D||null,G||0,F||null);C.__flash.addEventListener("open",function(I){try{C.readyState=C.__flash.getReadyState();if(C.__timer){clearInterval(C.__timer)}if(window.opera){C.__timer=setInterval(function(){C.__handleMessages()},500)}if(C.onopen){C.onopen()}}catch(J){A.error(J.toString())}});C.__flash.addEventListener("close",function(I){try{C.readyState=C.__flash.getReadyState();if(C.__timer){clearInterval(C.__timer)}if(C.onclose){C.onclose()}}catch(J){A.error(J.toString())}});C.__flash.addEventListener("message",function(){try{C.__handleMessages()}catch(I){A.error(I.toString())}});C.__flash.addEventListener("error",function(I){try{if(C.__timer){clearInterval(C.__timer)}if(C.onerror){C.onerror()}}catch(J){A.error(J.toString())}});C.__flash.addEventListener("stateChange",function(I){try{C.readyState=C.__flash.getReadyState();C.bufferedAmount=I.getBufferedAmount()}catch(J){A.error(J.toString())}})};WebSocket.prototype.send=function(D){if(this.__flash){this.readyState=this.__flash.getReadyState()}if(!this.__flash||this.readyState==WebSocket.CONNECTING){throw"INVALID_STATE_ERR: Web Socket connection has not been established"}var C=this.__flash.send(encodeURIComponent(D));if(C<0){return true}else{this.bufferedAmount=C;return false}};WebSocket.prototype.close=function(){var C=this;if(!C.__flash){return }C.readyState=C.__flash.getReadyState();if(C.readyState==WebSocket.CLOSED||C.readyState==WebSocket.CLOSING){return }C.__flash.close();C.readyState=WebSocket.CLOSED;if(C.__timer){clearInterval(C.__timer)}if(C.onclose){setTimeout(C.onclose,1)}};WebSocket.prototype.addEventListener=function(D,E,C){if(!("__events" in this)){this.__events={}}if(!(D in this.__events)){this.__events[D]=[];if("function"==typeof this["on"+D]){this.__events[D].defaultHandler=this["on"+D];this["on"+D]=this.__createEventHandler(this,D)}}this.__events[D].push(E)};WebSocket.prototype.removeEventListener=function(E,F,C){if(!("__events" in this)){this.__events={}}if(!(E in this.__events)){return }for(var D=this.__events.length;D>-1;--D){if(F===this.__events[E][D]){this.__events[E].splice(D,1);break}}};WebSocket.prototype.dispatchEvent=function(E){if(!("__events" in this)){throw"UNSPECIFIED_EVENT_TYPE_ERR"}if(!(E.type in this.__events)){throw"UNSPECIFIED_EVENT_TYPE_ERR"}for(var D=0,C=this.__events[E.type].length;D<C;++D){this.__events[E.type][D](E);if(E.cancelBubble){break}}if(false!==E.returnValue&&"function"==typeof this.__events[E.type].defaultHandler){this.__events[E.type].defaultHandler(E)}};WebSocket.prototype.__handleMessages=function(){var C=this.__flash.readSocketData();for(var D=0;D<C.length;D++){var E=decodeURIComponent(C[D]);try{if(this.onmessage){var F;if(window.MessageEvent){F=document.createEvent("MessageEvent");F.initMessageEvent("message",false,false,E,null,null,window,null)}else{F={data:E}}this.onmessage(F)}}catch(F){A.error(F.toString())}}};WebSocket.prototype.__createEventHandler=function(C,D){return function(G){var F=new B();F.initEvent(D,true,true);F.target=F.currentTarget=C;for(var E in G){F[E]=G[E]}C.dispatchEvent(F,arguments)}};function B(){}B.prototype.cancelable=true;B.prototype.cancelBubble=false;B.prototype.preventDefault=function(){if(this.cancelable){this.returnValue=false}};B.prototype.stopPropagation=function(){this.cancelBubble=true};B.prototype.initEvent=function(C,E,D){this.type=C;this.cancelable=D;this.timeStamp=new Date()};WebSocket.CONNECTING=0;WebSocket.OPEN=1;WebSocket.CLOSING=2;WebSocket.CLOSED=3;WebSocket.__tasks=[];WebSocket.__initialize=function(){if(WebSocket.__swfLocation){window.WEB_SOCKET_SWF_LOCATION=WebSocket.__swfLocation}if(!window.WEB_SOCKET_SWF_LOCATION){A.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");return }var C=document.createElement("div");C.id="webSocketContainer";C.style.position="absolute";if(WebSocket.__isFlashLite()){C.style.left="0px";C.style.top="0px"}else{C.style.left="-100px";C.style.top="-100px"}var D=document.createElement("div");D.id="webSocketFlash";C.appendChild(D);document.body.appendChild(C);swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","9.0.0",null,{bridgeName:"webSocket"},{hasPriority:true,allowScriptAccess:"always"},null,function(E){if(!E.success){A.error("[WebSocket] swfobject.embedSWF failed")}});FABridge.addInitializationCallback("webSocket",function(){try{WebSocket.__flash=FABridge.webSocket.root();WebSocket.__flash.setCallerUrl(location.href);WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var E=0;E<WebSocket.__tasks.length;++E){WebSocket.__tasks[E]()}WebSocket.__tasks=[]}catch(F){A.error("[WebSocket] "+F.toString())}})};WebSocket.__addTask=function(C){if(WebSocket.__flash){C()}else{WebSocket.__tasks.push(C)}};WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes){return false}var C=window.navigator.mimeTypes["application/x-shockwave-flash"];if(!C||!C.enabledPlugin||!C.enabledPlugin.filename){return false}return C.enabledPlugin.filename.match(/flashlite/i)?true:false};window.webSocketLog=function(C){A.log(decodeURIComponent(C))};window.webSocketError=function(C){A.error(decodeURIComponent(C))};if(!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION){if(window.addEventListener){window.addEventListener("load",WebSocket.__initialize,false)}else{window.attachEvent("onload",WebSocket.__initialize)}}})();Ext.regApplication("App",{defaultTarget:"viewport",defaultUrl:"Viewport/index",name:"App",useHistory:false,useLoadMask:true,launch:function(){Ext.Viewport.init();Ext.Viewport.onOrientationChange();this.viewport=new App.View.Viewport({application:this});Ext.dispatch({controller:"Viewport",action:"index"})}});Ext.ns("App.util");App.util.Socketio=Ext.extend(Ext.util.Observable,{constructor:function(C,A){A=A||{};App.util.Socketio.superclass.constructor.call(this);this.socket=new io.Socket(C,A);var B=this;this.socket.on("connect",function(){B.onConnect()});this.socket.on("message",function(D){B.onMessage(D)});this.socket.on("close",function(){B.onClose()});this.socket.on("disconnect",function(){B.onDisconnect()})},connect:function(){this.socket.connect()},disconnect:function(){this.socket.disconnect()},send:function(A){this.socket.send(A)},onConnect:function(){this.fireEvent("connect")},onDisconnect:function(){this.fireEvent("disconnect")},onClose:function(){this.fireEvent("close")},onMessage:function(A){this.fireEvent("message",A)}});Ext.reg("App.util.Socketio",App.util.Socketio);Ext.regController("Viewport",{index:function(){var A=new App.Store.Config();A.load();if(A.getCount()>0){this.showChat()}else{this.showConfig()}},showChat:function(){Ext.dispatch({controller:"Chat",action:"index"})},showConfig:function(){if(!this.viewConfig){this.viewConfig=this.render({xtype:"App.View.Config"});this.viewConfig.query("#backButton")[0].on("tap",this.showChat,this)}this.application.viewport.setActiveItem(this.viewConfig,{type:"slide",direction:"left"})}});Ext.regController("Chat",{index:function(){if(!this.socket){this.initSocketConnection()}this.showChat()},initSocketConnection:function(){this.chatStore=new App.Store.Chat();this.configStore=Ext.StoreMgr.get("ConfigStore");var A=this.configStore.getAt(0);this.socket=new App.util.Socketio(A.get("server"),{port:4000});this.socket.connect();this.socket.on("connect",this.registerUser,this);this.socket.on("message",this.addMessageToChatStore,this);App.on("newMsg",this.sendMessageToServer,this)},sendMessageToServer:function(A){this.socket.send(A)},addMessageToChatStore:function(A){this.chatStore.add(A)},registerUser:function(){var B=this.configStore.getAt(0);var A={nickname:B.get("nickname"),gravatar:B.get("gravatar")};this.socket.send(A)},showChat:function(){if(!this.viewChat){this.viewChat=this.render({xtype:"App.View.Chat"});this.viewChat.query("#settingsButton")[0].on("tap",this.showConfig,this)}this.application.viewport.setActiveItem(this.viewChat,{type:"slide",direction:"left"})},showConfig:function(){Ext.dispatch({controller:"Viewport",action:"showConfig"})}});Ext.regModel("ChatMessage",{fields:[{name:"user",type:"string"},{name:"message",type:"string"}]});Ext.regModel("Config",{fields:[{name:"server",type:"string"},{name:"nickname",type:"string"},{name:"email",type:"string"},{name:"gravatar",type:"string"}],proxy:{type:"localstorage",id:"chat-settings"}});Ext.ns("App.Store");App.Store.Chat=Ext.extend(Ext.data.Store,{constructor:function(A){A=A||{};var B=Ext.apply({model:"ChatMessage",storeId:"ChatStore"},A);App.Store.Chat.superclass.constructor.call(this,B)}});Ext.reg("App.Store.Chat",App.Store.Chat);Ext.ns("App.Store");App.Store.Config=Ext.extend(Ext.data.Store,{constructor:function(A){A=A||{};var B=Ext.apply({model:"Config",storeId:"ConfigStore"},A);App.Store.Config.superclass.constructor.call(this,B)}});Ext.reg("App.Store.Config",App.Store.Config);Ext.ns("App.View");App.View.Viewport=Ext.extend(Ext.Panel,{id:"viewport",layout:"card",fullscreen:true,initComponent:function(){var A={};Ext.apply(this,A);App.View.Viewport.superclass.initComponent.call(this);this.addEventListener()},addEventListener:function(){this.on("afterrender",this.removeLoadingMask,this)},removeLoadingMask:function(){var A=Ext.get("pre-loading-mask");if(A){Ext.Anim.run(A,"fade",{easing:"out",duration:500,after:function(){A.remove()}})}}});Ext.reg("App.View.Viewport",App.View.Viewport);Ext.ns("App.View");App.View.Config=Ext.extend(Ext.form.FormPanel,{initComponent:function(){this.store=Ext.StoreMgr.get("ConfigStore");this.store.load();var A={fullscreen:true,scroll:"vertical",defaults:{},items:[{xtype:"textfield",name:"nickname",label:"Nickname",placeHolder:"nickname83"},{xtype:"emailfield",name:"email",label:"Gravatar",placeHolder:"gravatar@email-adress.com"},{xtype:"textfield",name:"server",label:"Server",placeHolder:"192.168.178.50",listeners:{blur:function(B){Ext.Viewport.scrollToTop()}}}],dockedItems:[{dock:"top",title:"Settings",xtype:"toolbar",items:[{ui:"back",text:"back",itemId:"backButton"}]},{dock:"top",xtype:"panel",itemId:"gravatar",html:'<img src="http://www.gravatar.com/avatar/?s=80&d=mm" height="80"/>',tpl:'<img src="http://www.gravatar.com/avatar/{gravatar}?s=80&d=mm" height="80"/>'},{dock:"bottom",xtype:"toolbar",items:[{xtype:"spacer"},{xtype:"button",text:"save",handler:this.saveAction,scope:this}]}]};Ext.apply(this,A);App.View.Config.superclass.initComponent.call(this);this.addEventListener()},addEventListener:function(){this.on("activate",this.loadSettings,this)},loadSettings:function(){var A=this.store.getAt(0);if(Ext.isObject(A)){this.load(A);this.updateGravatarImg(A)}},saveAction:function(){var B=this.getValues();var A=Ext.ModelMgr.create({nickname:B.nickname,email:B.email,gravatar:Ext.util.MD5(B.email),server:B.server},"Config");this.updateGravatarImg(A);this.store.removeAt(0);this.store.sync();this.store.add(A);this.store.sync()},updateGravatarImg:function(A){var B=this.getComponent("gravatar");B.update(A.data)}});Ext.reg("App.View.Config",App.View.Config);Ext.ns("App.View");App.View.Chat=Ext.extend(Ext.Panel,{initComponent:function(){this.store=Ext.StoreMgr.get("ChatStore");var A={layout:"fit",dockedItems:[{xtype:"toolbar",dock:"top",layout:"fit",title:"Chat",items:[{xtype:"spacer"},{iconMask:true,ui:"plain",iconCls:"settings",itemId:"settingsButton"}]},{xtype:"toolbar",dock:"bottom",itemId:"msgToolbar",layout:"fit",items:[{xtype:"textfield",width:"96%",listeners:{blur:function(B){Ext.Viewport.scrollToTop();App.fireEvent("newMsg",B.getValue());B.reset()}}}]}],items:[{xtype:"list",itemId:"chatList",itemTpl:new Ext.XTemplate('<tpl if="xindex % 2 === 0">',' <img class="odd" src="http://www.gravatar.com/avatar/{gravatar}?s=28&d=mm" />',' <p class="triangle-right left"><span class="nickname">{nickname}:</span> {message}</p>',"</tpl>",'<tpl if="xindex % 2 === 1">',' <p class="triangle-right right"><span class="nickname">{nickname}:</span> {message}</p>',' <img class="even" src="http://www.gravatar.com/avatar/{gravatar}?s=28&d=mm" />',"</tpl>"),store:this.store,scroll:"vertical"}]};Ext.apply(this,A);App.View.Chat.superclass.initComponent.call(this);this.addEventListener()},addEventListener:function(){this.store.on("datachanged",this.scrollToBottom,this)},scrollToBottom:function(){var A=this.getComponent("chatList");A.scroller.updateBoundary();A.scroller.scrollTo({x:0,y:A.scroller.size.height},true)}});Ext.reg("App.View.Chat",App.View.Chat);
View
54 js/conrollers/Controller.Chat.js
@@ -24,40 +24,50 @@ Ext.regController('Chat', {
*
*/
initSocketConnection: function() {
- var chatStore = new App.Store.Chat();
- var configStore = Ext.StoreMgr.get('ConfigStore');
- var settings = configStore.getAt(0);
- var user = {
- nickname: settings.get('nickname'),
- gravatar: settings.get('gravatar')
- };
-
- var socket = new io.Socket(settings.get('server'), {port: 4000});
- this.socket = socket;
+ this.chatStore = new App.Store.Chat();
+ this.configStore = Ext.StoreMgr.get('ConfigStore');
+ var settings = this.configStore.getAt(0);
- socket.connect();
+ this.socket = new App.util.Socketio(settings.get('server'), {port: 4000});
+ this.socket.connect();
- socket.on('connect',
- function() {
- socket.send(user);
- },
+ // Event Listener
+ this.socket.on(
+ 'connect',
+ this.registerUser,
this
);
-
- socket.on('message', function(message) {
- chatStore.add(message);
- });
+ this.socket.on(
+ 'message',
+ this.addMessageToChatStore,
+ this
+ );
App.on(
'newMsg',
- function(msg){
- this.socket.send(msg);
- },
+ this.sendMessageToServer,
this
);
},
+ sendMessageToServer: function(msg){
+ this.socket.send(msg);
+ },
+
+ addMessageToChatStore: function(message) {
+ this.chatStore.add(message);
+ },
+
+ registerUser: function() {
+ var settings = this.configStore.getAt(0);
+ var user = {
+ nickname: settings.get('nickname'),
+ gravatar: settings.get('gravatar')
+ };
+ this.socket.send(user);
+ },
+
/**
* Show chat view
*/

0 comments on commit 2b17b47

Please sign in to comment.
Something went wrong with that request. Please try again.