if(function(e,t){var n=e;n.version="0.9.11",n.protocol=1,n.transports=[],n.j=[],n.sockets={},n.connect=function(e,o){var i,r,s=n.util.parseUri(e);t&&t.location&&(s.protocol=s.protocol||t.location.protocol.slice(0,-1),s.host=s.host||(t.document?t.document.domain:t.location.hostname),s.port=s.port||t.location.port),i=n.util.uniqueUri(s);var a={host:s.host,secure:"https"==s.protocol,port:s.port||("https"==s.protocol?443:80),query:s.query||""};return n.util.merge(a,o),!a["force new connection"]&&n.sockets[i]||(r=new n.Socket(a)),!a["force new connection"]&&r&&(n.sockets[i]=r),r=r||n.sockets[i],r.of(s.path.length>1?s.path:"")}}("object"==typeof module?module.exports:this.io={},this),function(e,t){var n=e.util={},o=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,i=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];n.parseUri=function(e){for(var t=o.exec(e||""),n={},r=14;r--;)n[i[r]]=t[r]||"";return n},n.uniqueUri=function(e){var n=e.protocol,o=e.host,i=e.port;return"document"in t?(o=o||document.domain,i=i||("https"==n&&"https:"!==document.location.protocol?443:document.location.port)):(o=o||"localhost",i||"https"!=n||(i=443)),(n||"http")+"://"+o+":"+(i||80)},n.query=function(e,t){var o=n.chunkQuery(e||""),i=[];n.merge(o,n.chunkQuery(t||""));for(var r in o)o.hasOwnProperty(r)&&i.push(r+"="+o[r]);return i.length?"?"+i.join("&"):""},n.chunkQuery=function(e){for(var t,n={},o=e.split("&"),i=0,r=o.length;it.length?e:t,r=e.length>t.length?t:e,s=0,a=r.length;s0&&e.splice(0,1)[0]!=n.transport.name;);if(e.length)return void u(e)}n.publish("connect_failed"),n.reconnecting||n.reconnect()}},n.options["connect timeout"]))}):(n.connecting=!1,n.publish("connect_failed"),void(n.reconnecting||n.reconnect()))}n.sessionid=o,n.closeTimeout=1e3*r,n.heartbeatTimeout=1e3*i,null==a?n.options.socketHost=n.options.host:n.options.socketHost=a,null==c?n.options.socketPort=n.options.port:n.options.socketPort=c,n.options.sessionCnt=p,n.transports=n.origTransports=s?t.util.intersect(s.split(","),n.options.transports):n.options.transports,n.setHeartbeatTimeout(),u(n.transports),n.once("connect",function(){clearTimeout(n.connectTimeoutTimer),e&&"function"==typeof e&&e()})}),this},o.prototype.setHeartbeatTimeout=function(){if(clearTimeout(this.heartbeatTimeoutTimer),!this.transport||this.transport.heartbeats()){var e=this;this.heartbeatTimeoutTimer=setTimeout(function(){e.transport.onClose()},this.heartbeatTimeout)}},o.prototype.packet=function(e){return this.connected&&!this.doBuffer?this.transport.packet(e):this.buffer.push(e),this},o.prototype.setBuffer=function(e){this.doBuffer=e,!e&&this.connected&&this.buffer.length&&(this.options.manualFlush||this.flushBuffer())},o.prototype.flushBuffer=function(){this.transport.payload(this.buffer),this.buffer=[]},o.prototype.disconnect=function(){return(this.connected||this.connecting)&&(this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted")),this},o.prototype.disconnectSync=function(){var e=t.util.request(),n=["http"+(this.options.secure?"s":"")+":/",this.options.host+":"+this.options.port,this.options.resource,t.protocol,"",this.sessionid].join("/")+"/?disconnect=1";e.open("GET",n,!1),e.send(null),this.onDisconnect("booted")},o.prototype.isXDomain=function(){var e=n.location.port||("https:"==n.location.protocol?443:80);return this.options.host!==n.location.hostname||this.options.port!=e},o.prototype.onConnect=function(){this.connected||(this.connected=!0,this.connecting=!1,this.doBuffer||this.setBuffer(!1),this.emit("connect"))},o.prototype.onOpen=function(){this.open=!0},o.prototype.onClose=function(){this.open=!1,clearTimeout(this.heartbeatTimeoutTimer)},o.prototype.onPacket=function(e){this.of(e.endpoint).onPacket(e)},o.prototype.onError=function(e){e&&e.advice&&"reconnect"===e.advice&&(this.connected||this.connecting)&&(this.disconnect(),this.options.reconnect&&this.reconnect()),this.publish("error",e&&e.reason?e.reason:e)},o.prototype.onDisconnect=function(e){var t=this.connected,n=this.connecting;this.connected=!1,this.connecting=!1,this.open=!1,(t||n)&&(this.transport.close(),this.transport.clearTimeouts(),t&&(this.publish("disconnect",e),"booted"!=e&&this.options.reconnect&&!this.reconnecting&&this.reconnect()))},o.prototype.reconnect=function(){function e(){if(n.connected){for(var e in n.namespaces)n.namespaces.hasOwnProperty(e)&&""!==e&&n.namespaces[e].packet({type:"connect"});n.publish("reconnect",n.transport.name,n.reconnectionAttempts)}clearTimeout(n.reconnectionTimer),n.removeListener("connect_failed",t),n.removeListener("connect",t),n.reconnecting=!1,delete n.reconnectionAttempts,delete n.reconnectionDelay,delete n.reconnectionTimer,delete n.redoTransports,n.options["try multiple transports"]=i}function t(){if(n.reconnecting)return n.connected?e():n.connecting&&n.reconnecting?n.reconnectionTimer=setTimeout(t,1e3):void(n.reconnectionAttempts++>=o?n.redoTransports?(n.publish("reconnect_failed"),e()):(n.on("connect_failed",t),n.options["try multiple transports"]=!0,n.transports=n.origTransports,n.transport=n.getTransport(),n.redoTransports=!0,n.connect()):(n.reconnectionDelay=10},n.xdomainCheck=function(){return!0},"undefined"!=typeof window&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),t.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),"undefined"!=typeof window)var swfobject=function(){function e(){if(!U){try{var e=P.getElementsByTagName("body")[0].appendChild(v("span"));e.parentNode.removeChild(e)}catch(t){return}U=!0;for(var n=F.length,o=0;o0)for(var t=0;t0){var r=y(n);if(r)if(!k(M[t].swfVersion)||X.wk&&X.wk<312)if(M[t].expressInstall&&a()){var u={};u.data=M[t].expressInstall,u.width=r.getAttribute("width")||"0",u.height=r.getAttribute("height")||"0",r.getAttribute("class")&&(u.styleclass=r.getAttribute("class")),r.getAttribute("align")&&(u.align=r.getAttribute("align"));for(var l={},f=r.getElementsByTagName("param"),h=f.length,d=0;d');i.outerHTML='"+a+"",q[q.length]=e.id,o=y(e.id)}else{var p=v(A);p.setAttribute("type",I);for(var u in e)e[u]!=Object.prototype[u]&&("styleclass"==u.toLowerCase()?p.setAttribute("class",e[u]):"classid"!=u.toLowerCase()&&p.setAttribute(u,e[u]));for(var l in t)t[l]!=Object.prototype[l]&&"movie"!=l.toLowerCase()&&f(p,l,t[l]);i.parentNode.replaceChild(p,i),o=p}return o}function f(e,t,n){var o=v("param");o.setAttribute("name",t),o.setAttribute("value",n),e.appendChild(o)}function h(e){var t=y(e);t&&"OBJECT"==t.nodeName&&(X.ie&&X.win?(t.style.display="none",function(){4==t.readyState?d(e):setTimeout(arguments.callee,10)}()):t.parentNode.removeChild(t))}function d(e){var t=y(e);if(t){for(var n in t)"function"==typeof t[n]&&(t[n]=null);t.parentNode.removeChild(t)}}function y(e){var t=null;try{t=P.getElementById(e)}catch(n){}return t}function v(e){return P.createElement(e)}function m(e,t,n){e.attachEvent(t,n),R[R.length]=[e,t,n]}function k(e){var t=X.pv,n=e.split(".");return n[0]=parseInt(n[0],10),n[1]=parseInt(n[1],10)||0,n[2]=parseInt(n[2],10)||0,t[0]>n[0]||t[0]==n[0]&&t[1]>n[1]||t[0]==n[0]&&t[1]==n[1]&&t[2]>=n[2]}function b(e,t,n,o){if(!X.ie||!X.mac){var i=P.getElementsByTagName("head")[0];if(i){var r=n&&"string"==typeof n?n:"screen";if(o&&(C=null,O=null),!C||O!=r){var s=v("style");s.setAttribute("type","text/css"),s.setAttribute("media",r),C=i.appendChild(s),X.ie&&X.win&&typeof P.styleSheets!=W&&P.styleSheets.length>0&&(C=P.styleSheets[P.styleSheets.length-1]),O=r}X.ie&&X.win?C&&typeof C.addRule==A&&C.addRule(e,t):C&&typeof P.createTextNode!=W&&C.appendChild(P.createTextNode(e+" {"+t+"}"))}}}function g(e,t){if(J){var n=t?"visible":"hidden";U&&y(e)?y(e).style.visibility=n:b("#"+e,"visibility:"+n)}}function w(e){var t=/[\\\"<>\.;]/,n=null!=t.exec(e);return n&&typeof encodeURIComponent!=W?encodeURIComponent(e):e}var S,_,T,E,C,O,W="undefined",A="object",x="Shockwave Flash",N="ShockwaveFlash.ShockwaveFlash",I="application/x-shockwave-flash",j="SWFObjectExprInst",L="onreadystatechange",$=window,P=document,B=navigator,D=!1,F=[o],M=[],q=[],R=[],U=!1,H=!1,J=!0,X=function(){var e=typeof P.getElementById!=W&&typeof P.getElementsByTagName!=W&&typeof P.createElement!=W,t=B.userAgent.toLowerCase(),n=B.platform.toLowerCase(),o=n?/win/.test(n):/win/.test(t),i=n?/mac/.test(n):/mac/.test(t),r=!!/webkit/.test(t)&&parseFloat(t.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")),s=!1,a=[0,0,0],c=null;if(typeof B.plugins!=W&&typeof B.plugins[x]==A)c=B.plugins[x].description,!c||typeof B.mimeTypes!=W&&B.mimeTypes[I]&&!B.mimeTypes[I].enabledPlugin||(D=!0,s=!1,c=c.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),a[0]=parseInt(c.replace(/^(.*)\..*$/,"$1"),10),a[1]=parseInt(c.replace(/^.*\.(.*)\s.*$/,"$1"),10),a[2]=/[a-zA-Z]/.test(c)?parseInt(c.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof $[["Active"].concat("Object").join("X")]!=W)try{var p=new(window[["Active"].concat("Object").join("X")])(N);p&&(c=p.GetVariable("$version"),c&&(s=!0,c=c.split(" ")[1].split(","),a=[parseInt(c[0],10),parseInt(c[1],10),parseInt(c[2],10)]))}catch(u){}return{w3:e,pv:a,wk:r,ie:s,win:o,mac:i}}();(function(){X.w3&&((typeof P.readyState!=W&&"complete"==P.readyState||typeof P.readyState==W&&(P.getElementsByTagName("body")[0]||P.body))&&e(),U||(typeof P.addEventListener!=W&&P.addEventListener("DOMContentLoaded",e,!1),X.ie&&X.win&&(P.attachEvent(L,function(){"complete"==P.readyState&&(P.detachEvent(L,arguments.callee),e())}),$==top&&!function(){if(!U){try{P.documentElement.doScroll("left")}catch(t){return void setTimeout(arguments.callee,0)}e()}}()),X.wk&&!function(){if(!U)return/loaded|complete/.test(P.readyState)?void e():void setTimeout(arguments.callee,0)}(),n(e)))})(),function(){X.ie&&X.win&&window.attachEvent("onunload",function(){for(var e=R.length,t=0;t= 10.0.0 is required.");"file:"==location.protocol&&e.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,t,n,o,i){var r=this;r.__id=WebSocket.__nextId++,WebSocket.__instances[r.__id]=r,r.readyState=WebSocket.CONNECTING,r.bufferedAmount=0,r.__events={},t?"string"==typeof t&&(t=[t]):t=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(r.__id,e,t,n||null,o||0,i||null)})},0)},WebSocket.prototype.send=function(e){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var t=WebSocket.__flash.send(this.__id,encodeURIComponent(e));return t<0||(this.bufferedAmount+=t,!1)},WebSocket.prototype.close=function(){this.readyState!=WebSocket.CLOSED&&this.readyState!=WebSocket.CLOSING&&(this.readyState=WebSocket.CLOSING,WebSocket.__flash.close(this.__id))},WebSocket.prototype.addEventListener=function(e,t,n){e in this.__events||(this.__events[e]=[]),this.__events[e].push(t)},WebSocket.prototype.removeEventListener=function(e,t,n){if(e in this.__events)for(var o=this.__events[e],i=o.length-1;i>=0;--i)if(o[i]===t){o.splice(i,1);break}},WebSocket.prototype.dispatchEvent=function(e){for(var t=this.__events[e.type]||[],n=0;n0?r+"&tm"+(new Date).getTime()+"=1":r+"?tm"+(new Date).getTime()+"=1",e.topic?o.open("GET",r+"&topic="+e.topic,!0):o.open("GET",r,!0),o.onreadystatechange=function(){if(4==o.readyState){o.onreadystatechange=function(){};try{if(200==o.status){n.util.info("getToken:"+o.responseText);var t=o.responseText.replace(/(^\s*)|(\s*$)/g,"");if(t.length>10&&"token="==t.substring(0,6))return void i.call(null,t.substring(6));n.util.error("token invalid:"+o.responseText+",url:"+r)}else n.util.error("getToken err,http status:"+o.status+",url:"+r)}catch(s){n.util.error("tokenExpiredCb err:"+s)}e.topic&&setTimeout(function(){u.tokenExpiredCb(e,i)},6e4)}},o.withCredentials=!0,o.send(null)},u.connectCallback=c,u.reconnectCallback=a,u.disconnectCallback=l,u.msgCallback=i,u.appId=e,u.tokenUrl=s,u.terminalId=o,u.terminalType=r,u.init(),u}}("object"==typeof module?module.exports:this.Apush2={},this),function(e,t){function n(){this.msgHandlers={};var e=this;io.util.on(t,"beforeunload",function(){e.close()},!1)}var s=e;s.Client=n,n.prototype.init=function(){var e=this,n=t.io.util.request(),i=e.tokenUrl;i=i.indexOf("?")>0?i+"&tm"+(new Date).getTime()+"=1":i+"?tm"+(new Date).getTime()+"=1",n.open("GET",i,!0),n.onreadystatechange=function(){if(4==n.readyState){try{if(n.onreadystatechange=function(){},200==n.status){s.util.info("getToken:"+n.responseText);var t=n.responseText.replace(/(^\s*)|(\s*$)/g,"");if(t.length>10&&"token="==t.substring(0,6)){var o=t.substring(6),r=""+Math.round(1e4*Math.random())+(""+(new Date).getTime()).substring(4),c=window.location.protocol.slice(0,-1),a=s.port;return"https"==c&&(a=443),e.apushUrl="//"+s.serverDomain+":"+a+"/?param="+r+","+e.appId+","+encodeURIComponent(o),e.terminalId||(e.terminalId=r,"info"===s._loglevel&&s.util.info("terminalId:"+e.terminalId)),e.apushUrl=e.apushUrl+"&terminalId="+e.terminalId,e.terminalType&&(e.apushUrl=e.apushUrl+"&terminalType="+e.terminalType),e.createSocket(),void e.registerMsgHandler(e.appId,o,e.msgCallback)}s.util.error("token invalid:"+n.responseText+",url:"+i)}else s.util.error("gettoken err,http status:"+n.status+",url:"+i)}catch(l){s.util.error("init err:"+l+",url:"+i)}null==e.initRetryInterval&&(e.initRetryInterval=1e3),setTimeout(function(){e.init()},e.initRetryInterval),e.initRetryInterval<6e4&&(e.initRetryInterval=2*e.initRetryInterval)}},n.withCredentials=!0,n.send(null)},n.prototype.subscribeUserMsg=function(e){var t=this.appId,n=this.getMainToken();this.apushUrl=this.apushUrl.replace(n,encodeURIComponent(e));var s=this.registerMsgHandler(t,e,this.msgCallback);s&&(this.socket.isConnected()||(this.socket.updateToken(encodeURIComponent(e)),this.socket.reconnect()))},n.prototype.subscribeTopicMsg=function(e,t){var n=this.appId+"_t_"+e,s=this.registerMsgHandler(n,t,this.msgCallback);s&&this.socket&&this.socket.isConnected()&&this.socket.send("subscribeTopicMsg",{appTopic:n,token:t})},n.prototype.subscribeTopic=function(e){var t={};t.app=this.appId,t.topic=e;var n=this,s=function(e){n.subscribeTopicMsg(t.topic,e)};this.tokenExpiredCb(t,s)},n.prototype.unSubscribeTopic=function(e){var t=this.appId+"_t_"+e,n=this.unRegisterMsgHandler(t,this.msgCallback);n&&this.socket&&this.socket.send("unSubscribeTopicMsg",t)},n.prototype.reqUnReadMsgCount=function(){if(this.socket){var e={reqType:"reqUnReadMsgCount",cnt:this.appId};this.socket.send("upMsg",e)}},n.prototype.reqUnReadMsg=function(e){if(this.socket){var t={reqType:"reqUnReadMsg",cnt:this.appId+","+e};this.socket.send("upMsg",t)}},n.prototype.close=function(){this.socket&&this.socket.close()},n.prototype.getMainToken=function(){var e,t=this.apushUrl.indexOf("param=");t=this.apushUrl.indexOf(",",t+1);var n=this.apushUrl.indexOf(",",t+1),s=this.apushUrl.indexOf("&",n+1);return e=s>-1?this.apushUrl.substring(n+1,s):this.apushUrl.substring(n+1)},n.prototype.dealMsg=function(e){var t=this,n=e.app;e.topic&&(n=e.app+"_t_"+e.topic);var i=this.msgHandlers[n];if("tokenExpired"==e.msgType){i&&delete t.msgHandlers[n];var o=function(n){e.topic?t.subscribeTopicMsg(e.topic,n):t.subscribeUserMsg(n)};return t.tokenExpiredCb(e,o),!0}if(!i)return!1;try{"subscribed"==e.msgType?null==t.connectTimes?(t.connectTimes=0,t.connectCallback&&t.connectCallback.call(null,e)):(t.connectTimes+=1,t.reconnectCallback&&t.reconnectCallback.call(null,e)):"unsubscribed"==e.msgType?t.disconnectCallback&&t.disconnectCallback.call(null,e):i.fn.call(null,e)}catch(r){s.util.error("dealMsg err:"+r)}return!0},n.prototype.registerMsgHandler=function(e,t,n){return this.msgHandlers[e]?(this.msgHandlers[e]={fn:n,token:t},!1):(this.msgHandlers[e]={fn:n,token:t},!0)},n.prototype.unRegisterMsgHandler=function(e,t){var n=this.msgHandlers[e];return!(!n||n.fn!==t)&&(delete this.msgHandlers[e],!0)},n.prototype.onconnect=function(){for(var e in this.msgHandlers)e.indexOf("_t_")>0&&this.socket.send("subscribeTopicMsg",{appTopic:e,token:this.msgHandlers[e].token})},n.prototype.createSocket=function(){var e=this;this.socket&&this.socket.close();var n=t.io.connect(this.apushUrl,{resource:"apush","reconnection limit":6e4,"max reconnection attempts":1/0,"force new connection":!0});n.on("connect",function(){e.onconnect()}),n.on("apushMsg",function(t){t.msgId&&n.emit("ackMsg",{app:t.app,tm:t.tm,msgId:t.msgId}),e.dealMsg(t)}),n.on("disconnect",function(t){var n={app:e.appId,msgType:"unsubscribed"};e.dealMsg(n)}),n.on("error",function(t){if("401"==t){var n=e.appId,s={app:n,msgType:"tokenExpired"};e.dealMsg(s)}}),this.socket={send:function(e,t){n.emit(e,t)},packet:function(e){n.packet(e)},isConnected:function(){return n.socket.connected},updateToken:function(e){var t=n.socket.options.query,s=t.lastIndexOf(","),i=t.indexOf("&",s);n.socket.options.query=t.substring(0,s+1)+e,i>0&&(n.socket.options.query=n.socket.options.query+t.substring(i))},close:function(){n.disconnect()},reconnect:function(){n.socket.reconnect()}}}}("undefined"!=typeof Apush2?Apush2:module.exports,this),function(e,t){var n=window.console;n&&n.log&&n.error||(n={info:function(){},error:function(){}}),e.util={off:function(e,t,n){e.removeEventListener?e.removeEventListener(t,n,!1):e.detachEvent&&e.detachEvent("on"+t,n)},info:function(e){n.info(e)},error:function(e){n.error(e)}}}("undefined"!=typeof Apush2?Apush2:module.exports,this);