Files
socket.io/dist/socket.io.min.js
2011-06-09 19:46:04 +02:00

2 lines
23 KiB
JavaScript
Raw Blame History

/*! Socket.IO.min.js build:0.7.0, production. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
(function(a){var b=a;b.version="0.7.0",b.protocol=1,b.transports=["websocket","htmlfile","xhr-polling","jsonp-polling"],b.j=[],b.sockets={},b.connect=function(a,c){var d=b.util.parseUri(a),e=b.util.uniqueUri(d);if(c||!b.sockets[e])var f=new b.Socket({host:d.host,secure:d.protocol=="https://",port:d.port||80});c||(this.sockets[e]=f);return f.of(d.path.length>1?d.path:"")}})("object"==typeof module?module.exports:window.io={}),function(a){var b=a.util={},c=/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,d=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];b.parseUri=function(a){var b=c.exec(a||""),e={},f=14;while(f--)e[d[f]]=b[f]||"";return e},b.uniqueUri=function(a){var b=a.protocol,c=a.host,d=a.port;"undefined"!=typeof document?(c=c||document.domain,d=d||document.location.port):c=c||"localhost";return(b||"http")+"://"+c+":"+(d||b&&b==="https"?443:80)};var e=!1;b.load=function(a){if(document.readyState==="complete"||e)return a();b.on(window,"load",a,!1)},b.on=function(a,b,c,d){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener(b,c,d)};var f="undefined"!=typeof window&&window.XMLHttpRequest&&function(){var a=new XMLHttpRequest;return a.withCredentials!=undefined}();b.request=function(a){if("undefined"!=typeof window){if(a&&window.XDomainRequest)return new XDomainRequest;if(window.XMLHttpRequest&&(!a||f))return new XMLHttpRequest;if(!a)try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}return null},"undefined"!=typeof window&&b.load(function(){e=!0}),b.defer=function(a){if(!b.ua.webkit)return a();b.load(function(){setTimeout(a,100)})},b.merge=function(a,b,c,d){var e=d||[],f=typeof c=="undefined"?2:c,g;for(g in b)b.hasOwnProperty(g)&&this.indexOf(e,g)<0&&(typeof a[g]!="object"||!f?(a[g]=b[g],e.push(b[g])):this.merge(a[g],b[g],f-1,e));return a},b.mixin=function(a,c){b.merge(a.prototype,c.prototype)},b.inherit=function(a,c){a.prototype=new c,b.merge(a,c)},b.isArray=Array.isArray||function(a){return Object.prototype.toString.call(a)==="[object Array]"},b.intersect=function(a,c){var d=[],e=a.length>c.length?a:c,f=a.length>c.length?c:a;for(var g=0,h=f.length;g<h;g++)~b.indexOf(e,f[g])&&d.push(f[g]);return d},b.indexOf=function(a,b,c){if(Array.prototype.indexOf)return Array.prototype.indexOf.call(a,b,c);for(var d=a.length,c=c<0?c+d<0?0:c+d:c||0;c<d&&a[c]!==b;c++);return d<=c?-1:c},b.ua={},b.ua.webkit="undefined"!=typeof navigator&&/webkit/i.test(navigator.userAgent)}("undefined"!=typeof window?io:module.exports),function(a,b){function c(){}a.EventEmitter=c,c.prototype.on=function(a,c){this.$events||(this.$events={}),this.$events[a]?b.util.isArray(this.$events[a])?this.$events[a].push(c):this.$events[a]=[this.$events[a],c]:this.$events[a]=c;return this},c.prototype.addListener=c.prototype.on,c.prototype.once=function(a,b){function d(){c.removeListener(a,d),b.apply(this,arguments)}var c=this;d.listener=b,this.on(a,d);return this},c.prototype.removeListener=function(a,c){if(this.$events&&this.$events[a]){var d=this.$events[a];if(b.util.isArray(d)){var e=-1;for(var f=0,g=d.length;f<g;f++)if(d[f]===c||d[f].listener&&d[f].listener===c){e=f;break}if(e<0)return this;d.splice(e,1),d.length||delete this.$events[a]}else(d===c||d.listener&&d.listener===c)&&delete this.$events[a]}return this},c.prototype.removeAllListeners=function(a){if(a===undefined){this.$events={};return this}this.$events&&this.$events[a]&&(this.$events[a]=null);return this},c.prototype.listeners=function(a){this.$events||(this.$events={}),this.$events[a]||(this.$events[a]=[]),b.util.isArray(this.$events[a])||(this.$events[a]=[this.$events[a]]);return this.$events[a]},c.prototype.emit=function(a){if(!this.$events)return!1;var c=this.$events[a];if(!c)return!1;var d=Array.prototype.slice.call(arguments,1);if("function"==typeof c)c.apply(this,d);else{if(!b.util.isArray(c))return!1;var e=c.slice();for(var f=0,g=e.length;f<g;f++)e[f].apply(this,d)}return!0}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(exports,nativeJSON){function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i instanceof Date&&(i=date(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g;return e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)typeof rep[c]=="string"&&(d=rep[c],e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.prototype.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g;return e}}function quote(a){escapable.lastIndex=0;return escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function date(a,b){return isFinite(a.valueOf())?a.getUTCFullYear()+"-"+f(a.getUTCMonth()+1)+"-"+f(a.getUTCDate())+"T"+f(a.getUTCHours())+":"+f(a.getUTCMinutes())+":"+f(a.getUTCSeconds())+"Z":null}function f(a){return a<10?"0"+a:a}"use strict";if(nativeJSON&&nativeJSON.parse)return exports.JSON={parse:nativeJSON.parse,stringify:nativeJSON.stringify};var JSON=exports.JSON={},cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(b&&typeof b!="function"&&(typeof b!="object"||typeof b.length!="number"))throw new Error("JSON.stringify");return str("",{"":a})},JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.prototype.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){j=eval("("+text+")");return typeof reviver=="function"?walk({"":j},""):j}throw new SyntaxError("JSON.parse")}}("undefined"!=typeof io?io:module.exports,JSON),function(a,b){var c=a.parser={},d=c.packets=["disconnect","connect","heartbeat","message","json","event","ack","error"],e=c.reasons=["transport not supported","client not handshaken","unauthorized"],f=c.advice=["reconnect"],g=b.JSON,h=b.util.indexOf;c.encodePacket=function(a){var b=d.indexOf(a.type),c=a.id||"",h=a.endpoint||"",i=a.ack,j=null;switch(a.type){case"error":var k=a.reason?e.indexOf(a.reason):"",l=a.advice?f.indexOf(a.advice):"";if(k!==""||l!=="")j=k+(l!==""?"+"+l:"");break;case"message":a.data!==""&&(j=a.data);break;case"event":var m=a.args&&a.args.length?g.stringify(a.args):"";j=a.name+(m!==""?"<22>"+m:"");break;case"json":j=g.stringify(a.data);break;case"connect":a.qs&&(j=a.qs);break;case"ack":j=a.ackId+(a.args&&a.args.length?"+"+g.stringify(a.args):"");break;case"heartbeat":case"disconect":}var n=[b,c+(i=="data"?"+":""),h];j!==null&&j!==undefined&&n.push(j);return n.join(":")},c.encodePayload=function(a){var b="";if(a.length==1)return a[0];for(var c=0,d=a.length;c<d;c++){var e=a[c];b+="<22>"+e.length+"<22>"+a[c]}return b};var i=/^([^:]+):([0-9]+)?(\+)?:([^:]+)?:?(.*)?$/;c.decodePacket=function(a){var b=a.match(i);if(!b)return{};var c=b[2]||"",a=b[5]||"",h={type:d[b[1]],endpoint:b[4]||""};c&&(h.id=c,b[3]?h.ack="data":h.ack=!0);switch(h.type){case"error":var b=a.split("+");h.reason=e[b[0]]||"",h.advice=f[b[1]]||"";break;case"message":h.data=a||"";break;case"event":var b=a.match(/([^\ufffd]+)(\ufffd)?(.*)/);h.name=b[1]||"",h.args=[];if(b[3])try{h.args=g.parse(b[3])}catch(j){}break;case"json":try{h.data=g.parse(a)}catch(j){}break;case"connect":h.qs=a||"";break;case"ack":var b=a.match(/^([0-9]+)(\+)?(.*)/);if(b){h.ackId=b[1],h.args=[];if(b[3])try{h.args=b[3]?g.parse(b[3]):[]}catch(j){}}break;case"disconnect":case"heartbeat":}return h},c.decodePayload=function(a){if(a[0]=="<22>"){var b=[];for(var d=1,e="";d<a.length;d++)a[d]=="<22>"?(b.push(c.decodePacket(a.substr(d+1).substr(0,e))),d+=Number(e)+1,e=""):e+=a[d];return b}return[c.decodePacket(a)]}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a,b){this.socket=a,this.sessid=b}a.Transport=c,b.util.mixin(c,b.EventEmitter),c.prototype.onData=function(a){this.clearCloseTimeout();if(a!==""){var c=b.parser.decodePayload(a);if(c&&c.length)for(var d=0,e=c.length;d<e;d++)this.onPacket(c[d])}return this},c.prototype.onPacket=function(a){if(a.type=="heartbeat")return this.onHeartbeat();if(a.type=="disconnect"&&a.endpoint=="")return this.onDisconnect();this.socket.onPacket(a);return this},c.prototype.setCloseTimeout=function(){if(!this.closeTimeout){var a=this;this.closeTimeout=setTimeout(function(){a.onDisconnect()},this.socket.closeTimeout)}},c.prototype.onDisconnect=function(){this.close&&this.close(),this.clearTimeouts(),this.socket.onDisconnect();return this},c.prototype.clearCloseTimeout=function(){this.closeTimeout&&(clearTimeout(this.closeTimeout),this.closeTimeout=null)},c.prototype.clearTimeouts=function(){this.clearCloseTimeout(),this.reopenTimeout&&clearTimeout(this.reopenTimeout)},c.prototype.packet=function(a){this.send(b.parser.encodePacket(a))},c.prototype.onHeartbeat=function(a){this.packet({type:"heartbeat"})},c.prototype.onOpen=function(){this.clearCloseTimeout(),this.socket.onOpen()},c.prototype.onClose=function(){this.reopenTimeout=setTimeout(function(){this.open()},this.socket.options["reopen delay"]),this.setCloseTimeout(),this.socket.onClose()},c.prototype.prepareUrl=function(){return this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){this.options={port:80,secure:!1,document:document,resource:"socket.io",transports:b.transports,"connect timeout":1e4,"try multiple transports":!0,reconnect:!0,"reconnection delay":500,"reopen delay":3e3,"max reconnection attempts":10,"sync disconnect on unload":!0,"auto connect":!0},b.util.merge(this.options,a),this.connected=!1,this.open=!1,this.connecting=!1,this.reconnecting=!1;if(this.options["sync disconnect on unload"]){var c=this;b.util.on(window,"beforeunload",function(){c.disconnect(!0)},!1)}this.options["auto connect"]&&this.connect()}a.Socket=c,b.util.mixin(c,b.EventEmitter),c.prototype.of=function(a){this.namespaces||(this.namespaces={}),this.namespaces[a]||(this.namespaces[a]=new b.SocketNamespace(this,a));return this.namespaces[a]},c.prototype.handshake=function(a){function e(b){b instanceof Error?c.onError(b.message):a.apply(null,b.split(":"))}var c=this,f=this.options.resource+"/"+b.protocol+"/?t="+ +(new Date);if(this.isXDomain()){var g=document.getElementsByTagName("script")[0],h=document.createElement("SCRIPT");h.src=f+"&jsonp="+b.j.length,g.parentNode.insertBefore(h,g),b.j.push(function(a){e(a),h.parentNode.removeChild(h)})}else{var i=b.util.request();i.open("GET",f),i.onreadystatechange=function(){i.readyState==4&&(i.onreadystatechange=d,i.status==200?e(i.responseText):c.onError(i.responseText))},i.send(null)}},c.prototype.getTransport=function(a){var c=a||this.transports,d;for(var e=0,f;f=c[e];e++)if(b.Transport[f]&&b.Transport[f].check()&&(!this.isXDomain()||b.Transport[f].xdomainCheck()))return new b.Transport[f](this,this.sessionid);return null},c.prototype.connect=function(a){if(this.connecting)return this;var c=this;this.handshake(function(d,e,f,g){c.sessionid=d,c.closeTimeout=e,c.heartbeatTimeout=f,c.transports=b.util.intersect(g.split(","),c.options.transports),c.transport=c.getTransport();!c.transport||(c.connecting=!0,c.emit("connecting",c.transport.name),c.transport.open(),c.options.connectTimeout&&(c.connectTimeoutTimer=setTimeout(function(){if(!c.connected){if(c.options["try multiple transports"]){c.remainingTransports||(c.remainingTransports=c.transports.slice(0));var a=c.remainingTransports;while(a.length>0&&a.splice(0,1)[0]!=c.transport.name);a.length&&(c.transport=c.getTransport(a),c.connect())}(!c.remainingTransports||c.remainingTransports.length==0)&&c.emit("connect_failed")}c.remainingTransports&&c.remainingTransports.length==0&&delete c.remainingTransports},c.options["connect timeout"])),a&&typeof a=="function"&&c.once("connect",a),c.onConnect())});return this},c.prototype.packet=function(a){this.transport.packet(a);return this},c.prototype.disconnect=function(a){if(this.connected){this.open&&this.of("").packet({type:"disconnect"});var c=b.util.request();c.open("GET",this.resource+"/"+b.protocol+"/"+this.sessionid),a&&(c.sync=!0),this.onDisconnect()}return this},c.prototype.isXDomain=function(){var a=window.location.port||80;return this.options.host!==document.domain||this.options.port!=a},c.prototype.onConnect=function(){this.connected=!0,this.connecting=!1,this.emit("connect");for(var a in this.namespaces)this.of(a).$emit("connect")},c.prototype.onOpen=function(){this.connected||this.onConnect(),this.open=!0},c.prototype.onClose=function(){this.open=!1},c.prototype.onPacket=function(a){this.of(a.endpoint).onPacket(a)},c.prototype.onError=function(a){this.emit("error",a);for(var b in this.namespaces)this.of(b).$emit("error",a)},c.prototype.onDisconnect=function(a){var b=this.connected;this.connected=!1,this.connecting=!1,this.open=!1;if(b){this.emit("disconnect"),this.transport.clearTimeouts();for(var c in this.namespaces)this.of(c).$emit("disconnect",a);this.options.reconnect&&!this.reconnecting&&this.reconnect()}},c.prototype.reconnect=function(){function e(){if(!!a.reconnecting){if(a.connected)return d();if(a.connecting&&a.reconnecting)return a.reconnectionTimer=setTimeout(e,1e3);a.reconnectionAttempts++>=b?a.redoTransports?(a.emit("reconnect_failed"),d()):(a.on("connect_failed",e),a.options["try multiple transports"]=!0,a.transport=a.getTransport(),a.redoTransports=!0,a.connect()):(a.reconnectionDelay*=2,a.connect(),a.emit("reconnecting",a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(e,a.reconnectionDelay))}}function d(){a.connected&&a.emit("reconnect",a.transport.name,a.reconnectionAttempts),a.removeListener("connect_failed",e),a.removeListener("connect",e),a.reconnecting=!1,delete a.reconnectionAttempts,delete a.reconnectionDelay,delete a.reconnectionTimer,delete a.redoTransports,a.options["try multiple transports"]=c}this.reconnecting=!0,this.reconnectionAttempts=0,this.reconnectionDelay=this.options["reconnection delay"];var a=this,b=this.options["max reconnection attempts"],c=this.options["try multiple transports"];this.options["try multiple transports"]=!1,this.reconnectionTimer=setTimeout(e,this.reconnectionDelay),this.on("connect",e)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(a,b){this.namespace=a,this.name=b}function c(a){this.name=a||"",this.flags={},this.json=new d(this,"json"),this.ackPackets=0,this.acks={}}a.SocketNamespace=c,b.util.mixin(c,b.EventEmitter),c.prototype.$emit=b.EventEmitter.prototype.emit,c.prototype.packet=function(a){a.endpoint=this.name,this.socket.packet(a),this.flags={};return this},c.prototype.send=function(a,b){var c={type:this.flags.json?"json":"message",data:a};"function"==typeof b&&(c.id=++this.ackPackets,c.ack=b.length?"data":!0,this.acks[c.id]=b);return this.packet(c)},c.prototype.emit=function(a){var b=Array.prototype.slice.call(arguments,1),c=b[b.length-1],d={type:"event",name:a};"function"==typeof c&&(d.id=++this.ackPackets,d.ack=c.length?"data":!0,this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b;return this.packet(d)},c.prototype.onPacket=function(a){switch(a.type){case"connect":case"disconnect":this.$emit(a.type);break;case"message":case"json":this.$emit("message",a.data);break;case"event":this.$emit.apply(this,[a.name].concat(a.args))}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this,arguments)}}("undefined"!=typeof io?io:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.apply(this,arguments),this.name="websocket"}a.websocket=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.websocket=new WebSocket(this.prepareUrl());var a=this;this.websocket.onopen=function(){a.onOpen()},this.websocket.onmessage=function(b){a.onData(b.data)},this.websocket.onclose=function(){a.onClose()},this.websocket.onerror=function(b){a.onError(b)};return this},c.prototype.send=function(a){this.websocket.send(a);return this},c.prototype.close=function(){this.websocket.close();return this},c.prototype.onError=function(a){this.socket.onError(a)},c.prototype.scheme=function(){return this.socket.options.secure?"wss":"ws"},c.prototype.prepareUrl=function(){return this.scheme()+"://"+this.socket.options.host+":"+this.socket.options.port+"/"+this.socket.options.resource+"/"+b.protocol+"/"+this.name+"/"+this.sessid},c.check=function(){return!!window.WebSocket},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(a){!a||(b.Transport.apply(this,arguments),this.sendBuffer=[],this.onOpen())}a.XHR=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.get(),this.setCloseTimeout();return this},c.prototype.checkSend=function(){if(!this.posting&&this.sendBuffer.length){var a=b.parser.encodePayload(this.sendBuffer);this.sendBuffer=[],this.post(a)}},c.prototype.send=function(a){b.util.isArray(a)?this.sendBuffer.push.apply(this.sendBuffer,a):this.sendBuffer.push(a),this.checkSend();return this},c.prototype.post=function(a){function c(){b.sendXHR.readyState==4&&(b.sendXHR.onreadystatechange=b.sendXHR.onload=d,b.posting=!1,b.sendXHR.status==200?b.checkSend():b.onClose())}var b=this;this.posting=!0,this.sendXHR=this.request("POST"),window.XDomainRequest&&this.xhr instanceof XDomainRequest?this.sendXHR.onload=c:this.sendXHR.onreadystatechange=c,this.sendXHR.send(a)},c.prototype.onClose=function(){if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=d;try{this.xhr.abort()}catch(a){}this.xhr=null}if(this.sendXHR){this.sendXHR.onreadystatechange=this.sendXHR.onload=d;try{this.sendXHR.abort()}catch(a){}this.sendXHR=null}this.sendBuffer=[],b.Transport.prototype.onClose.call(this)},c.prototype.request=function(a){var c=b.util.request(this.socket.isXDomain());c.open(a||"GET",this.prepareUrl()+"?t"+ +(new Date)),a=="POST"&&(c.setRequestHeader?c.setRequestHeader("Content-type","text/plain"):c.contentType="text/plain");return c},c.prototype.scheme=function(){return this.socket.options.secure?"https://":"http://"},c.check=function(a){try{if(b.util.request(a))return!0}catch(c){}return!1},c.xdomainCheck=function(){return c.check(!0)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport.XHR.apply(this,arguments),this.name="htmlfile"}a.htmlfile=c,b.util.inherit(c,b.Transport.XHR),c.prototype.get=function(){var a=this;this.open(),window.attachEvent("onunload",function(){a.destroy()})},c.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 a=this.doc.createElement("div");a.className="socketio",this.doc.body.appendChild(a),this.iframe=this.doc.createElement("iframe"),a.appendChild(this.iframe),this.iframe.src=this.prepareUrl()+"/?t="+ +(new Date),this.onOpen()},c.prototype._=function(a,b){this.onData(a);var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,CollectGarbage()}},c.prototype.close=function(){this.destroy();return b.Transport.XHR.prototype.close.call(this)},c.check=function(){if("ActiveXObject"in window)try{var a=new ActiveXObject("htmlfile");return a&&b.Transport.XHR.check()}catch(c){}return!1},c.xdomainCheck=function(){return!1}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function d(){}function c(){b.Transport.XHR.apply(this,arguments),this.name="xhr-polling"}a["xhr-polling"]=c,b.util.inherit(c,b.Transport.XHR),c.prototype.open=function(){var a=this;b.util.defer(function(){b.Transport.XHR.prototype.open.call(a)});return!1},c.prototype.get=function(){function b(){a.xhr.readyState==4&&(a.xhr.onreadystatechange=a.xhr.onload=d,a.xhr.status==200?(a.onData(a.xhr.responseText),a.get()):a.onClose())}var a=this;this.xhr=this.request(),window.XDomainRequest&&this.xhr instanceof XDomainRequest?(this.xhr.onload=b,this.xhr.onerror=function(b){a.onError(b)}):this.xhr.onreadystatechange=b,this.xhr.send(null)}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){if(!!a){b.Transport["xhr-polling"].apply(this,arguments),this.name="jsonp-polling",this.insertAt=document.getElementsByTagName("script")[0],this.index=b.j.length;var c=this;b.j.push(function(a){c._(a)})}}a["jsonp-polling"]=c,b.util.inherit(c,b.Transport["xhr-polling"]),c.prototype.post=function(a){function h(){b.iframe&&b.form.removeChild(b.iframe);try{f=document.createElement('<iframe name="'+b.iframeId+'">')}catch(a){f=document.createElement("iframe"),f.name=b.iframeId}f.id=b.iframeId,b.form.appendChild(f),b.iframe=f}function g(){h(),b.posting=!1,b.checkSend()}var b=this;if(!this.form){var c=document.createElement("FORM"),d=document.createElement("TEXTAREA"),e=this.iframeId="socketio_iframe_"+this.index,f;c.className="socketio",c.style.position="absolute",c.style.top="-1000px",c.style.left="-1000px",c.target=e,c.method="POST",c.action=this.prepareUrl()+"?t="+ +(new Date)+"&i="+this.index,d.name="data",c.appendChild(d),this.insertAt.parentNode.insertBefore(c,this.insertAt),document.body.appendChild(c),this.form=c,this.area=d}h(),this.posting=!0,this.area.value=a;try{this.form.submit()}catch(i){}this.iframe.attachEvent?f.onreadystatechange=function(){b.iframe.readyState=="complete"&&g()}:this.iframe.onload=g},c.prototype.get=function(){var a=this,b=document.createElement("SCRIPT");this.script&&(this.script.parentNode.removeChild(this.script),this.script=null),b.async=!0,b.src=this.prepareUrl()+"/?t="+ +(new Date)+"&i="+this.index,b.onerror=function(){a.onClose()},this.insertAt.parentNode.insertBefore(b,this.insertAt),this.script=b},c.prototype._=function(a){this.onData(a),this.get();return this},c.check=function(){return!0},c.xdomainCheck=function(){return!0}}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports)