--- /dev/null
+/*! Socket.IO.js build:0.7.4, development. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports) {
+
+ /**
+ * IO namespace.
+ *
+ * @namespace
+ */
+
+ var io = exports;
+
+ /**
+ * Socket.IO version
+ *
+ * @api public
+ */
+
+ io.version = '0.7.4';
+
+ /**
+ * Protocol implemented.
+ *
+ * @api public
+ */
+
+ io.protocol = 1;
+
+ /**
+ * Available transports, these will be populated with the available transports
+ *
+ * @api public
+ */
+
+ io.transports = [];
+
+ /**
+ * Keep track of jsonp callbacks.
+ *
+ * @api private
+ */
+
+ io.j = [];
+
+ /**
+ * Keep track of our io.Sockets
+ *
+ * @api private
+ */
+ io.sockets = {};
+
+
+ /**
+ * Manages connections to hosts.
+ *
+ * @param {String} uri
+ * @Param {Boolean} force creation of new socket (defaults to false)
+ * @api public
+ */
+
+ io.connect = function (host, details) {
+ var uri = io.util.parseUri(host)
+ , uuri
+ , socket;
+
+ if ('undefined' != typeof document) {
+ uri.protocol = uri.protocol || document.location.protocol.slice(0, -1);
+ uri.host = uri.host || document.domain;
+ uri.port = uri.port || document.location.port;
+ }
+
+ uuri = io.util.uniqueUri(uri);
+
+ var options = {
+ host: uri.host
+ , secure: uri.protocol == 'https'
+ , port: uri.port || 80
+ };
+ io.util.merge(options, details);
+
+ if (options['force new connection'] || !io.sockets[uuri]) {
+ socket = new io.Socket(options);
+ }
+
+ if (!options['force new connection'] && socket) {
+ io.sockets[uuri] = socket;
+ }
+
+ socket = socket || io.sockets[uuri];
+
+ // if path is different from '' or /
+ return socket.of(uri.path.length > 1 ? uri.path : '');
+ };
+
+})('object' === typeof module ? module.exports : (window.io = {}));
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports) {
+
+ /**
+ * Utilities namespace.
+ *
+ * @namespace
+ */
+
+ var util = exports.util = {};
+
+ /**
+ * Parses an URI
+ *
+ * @author Steven Levithan <stevenlevithan.com> (MIT license)
+ * @api public
+ */
+
+ var re = /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/;
+
+ var parts = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password',
+ 'host', 'port', 'relative', 'path', 'directory', 'file', 'query',
+ 'anchor'];
+
+ util.parseUri = function (str) {
+ var m = re.exec(str || '')
+ , uri = {}
+ , i = 14;
+
+ while (i--) {
+ uri[parts[i]] = m[i] || '';
+ }
+
+ return uri;
+ };
+
+ /**
+ * Produces a unique url that identifies a Socket.IO connection.
+ *
+ * @param {Object} uri
+ * @api public
+ */
+
+ util.uniqueUri = function (uri) {
+ var protocol = uri.protocol
+ , host = uri.host
+ , port = uri.port;
+
+ if ('undefined' != typeof document) {
+ host = host || document.domain;
+ port = port || (protocol == 'https'
+ && document.location.protocol !== 'https:' ? 443 : document.location.port);
+ } else {
+ host = host || 'localhost';
+
+ if (!port && protocol == 'https') {
+ port = 443;
+ }
+ }
+
+ return (protocol || 'http') + '://' + host + ':' + (port || 80);
+ };
+
+ /**
+ * Executes the given function when the page is loaded.
+ *
+ * io.util.load(function () { console.log('page loaded'); });
+ *
+ * @param {Function} fn
+ * @api public
+ */
+
+ var pageLoaded = false;
+
+ util.load = function (fn) {
+ if (document.readyState === 'complete' || pageLoaded) {
+ return fn();
+ }
+
+ util.on(window, 'load', fn, false);
+ };
+
+ /**
+ * Adds an event.
+ *
+ * @api private
+ */
+
+ util.on = function (element, event, fn, capture) {
+ if (element.attachEvent) {
+ element.attachEvent('on' + event, fn);
+ } else {
+ element.addEventListener(event, fn, capture);
+ }
+ };
+
+ /**
+ * Generates the correct `XMLHttpRequest` for regular and cross domain requests.
+ *
+ * @param {Boolean} [xdomain] Create a request that can be used cross domain.
+ * @returns {XMLHttpRequest|false} If we can create a XMLHttpRequest.
+ * @api private
+ */
+
+ util.request = function (xdomain) {
+ if ('undefined' != typeof window) {
+ if (xdomain && window.XDomainRequest) {
+ return new XDomainRequest();
+ };
+
+ if (window.XMLHttpRequest && (!xdomain || util.ua.hasCORS)) {
+ return new XMLHttpRequest();
+ };
+
+ if (!xdomain) {
+ try {
+ return new window.ActiveXObject('Microsoft.XMLHTTP');
+ } catch(e) { }
+ }
+ }
+
+ return null;
+ };
+
+ /**
+ * XHR based transport constructor.
+ *
+ * @constructor
+ * @api public
+ */
+
+ /**
+ * Change the internal pageLoaded value.
+ */
+
+ if ('undefined' != typeof window) {
+ util.load(function () {
+ pageLoaded = true;
+ });
+ }
+
+ /**
+ * Defers a function to ensure a spinner is not displayed by the browser
+ *
+ * @param {Function} fn
+ * @api public
+ */
+
+ util.defer = function (fn) {
+ if (!util.ua.webkit) {
+ return fn();
+ }
+
+ util.load(function () {
+ setTimeout(fn, 100);
+ });
+ };
+
+ /**
+ * Merges two objects.
+ *
+ * @api public
+ */
+
+ util.merge = function merge (target, additional, deep, lastseen) {
+ var seen = lastseen || []
+ , depth = typeof deep == 'undefined' ? 2 : deep
+ , prop;
+
+ for (prop in additional) {
+ if (additional.hasOwnProperty(prop) && util.indexOf(seen, prop) < 0) {
+ if (typeof target[prop] !== 'object' || !depth) {
+ target[prop] = additional[prop];
+ seen.push(additional[prop]);
+ } else {
+ util.merge(target[prop], additional[prop], depth - 1, seen);
+ }
+ }
+ }
+
+ return target;
+ };
+
+ /**
+ * Merges prototypes from objects
+ *
+ * @api public
+ */
+
+ util.mixin = function (ctor, ctor2) {
+ util.merge(ctor.prototype, ctor2.prototype);
+ };
+
+ /**
+ * Shortcut for prototypical and static inheritance.
+ *
+ * @api private
+ */
+
+ util.inherit = function (ctor, ctor2) {
+ ctor.prototype = new ctor2;
+ util.merge(ctor, ctor2);
+ };
+
+ /**
+ * Checks if the given object is an Array.
+ *
+ * io.util.isArray([]); // true
+ * io.util.isArray({}); // false
+ *
+ * @param Object obj
+ * @api public
+ */
+
+ util.isArray = Array.isArray || function (obj) {
+ return Object.prototype.toString.call(obj) === '[object Array]';
+ };
+
+ /**
+ * Intersects values of two arrays into a third
+ *
+ * @api public
+ */
+
+ util.intersect = function (arr, arr2) {
+ var ret = []
+ , longest = arr.length > arr2.length ? arr : arr2
+ , shortest = arr.length > arr2.length ? arr2 : arr
+
+ for (var i = 0, l = shortest.length; i < l; i++) {
+ if (~util.indexOf(longest, shortest[i]))
+ ret.push(shortest[i]);
+ }
+
+ return ret;
+ }
+
+ /**
+ * Array indexOf compatibility.
+ *
+ * @see bit.ly/a5Dxa2
+ * @api public
+ */
+
+ util.indexOf = function (arr, o, i) {
+ if (Array.prototype.indexOf) {
+ return Array.prototype.indexOf.call(arr, o, i);
+ }
+
+ for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0
+ ; i < j && arr[i] !== o; i++);
+
+ return j <= i ? -1 : i;
+ };
+
+ /**
+ * Converts enumerables to array.
+ *
+ * @api public
+ */
+
+ util.toArray = function (enu) {
+ var arr = [];
+
+ for (var i = 0, l = enu.length; i < l; i++)
+ arr.push(enu[i]);
+
+ return arr;
+ };
+
+ /**
+ * UA / engines detection namespace.
+ *
+ * @namespace
+ */
+
+ util.ua = {};
+
+ /**
+ * Whether the UA supports CORS for XHR.
+ *
+ * @api public
+ */
+
+ util.ua.hasCORS = 'undefined' != typeof window && window.XMLHttpRequest &&
+ (function () {
+ try {
+ var a = new XMLHttpRequest();
+ } catch (e) {
+ return false;
+ }
+
+ return a.withCredentials != undefined;
+ })();
+
+ /**
+ * Detect webkit.
+ *
+ * @api public
+ */
+
+ util.ua.webkit = 'undefined' != typeof navigator
+ && /webkit/i.test(navigator.userAgent);
+
+})('undefined' != typeof window ? io : module.exports);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.EventEmitter = EventEmitter;
+
+ /**
+ * Event emitter constructor.
+ *
+ * @api public.
+ */
+
+ function EventEmitter () {};
+
+ /**
+ * Adds a listener
+ *
+ * @api public
+ */
+
+ EventEmitter.prototype.on = function (name, fn) {
+ if (!this.$events) {
+ this.$events = {};
+ }
+
+ if (!this.$events[name]) {
+ this.$events[name] = fn;
+ } else if (io.util.isArray(this.$events[name])) {
+ this.$events[name].push(fn);
+ } else {
+ this.$events[name] = [this.$events[name], fn];
+ }
+
+ return this;
+ };
+
+ EventEmitter.prototype.addListener = EventEmitter.prototype.on;
+
+ /**
+ * Adds a volatile listener.
+ *
+ * @api public
+ */
+
+ EventEmitter.prototype.once = function (name, fn) {
+ var self = this;
+
+ function on () {
+ self.removeListener(name, on);
+ fn.apply(this, arguments);
+ };
+
+ on.listener = fn;
+ this.on(name, on);
+
+ return this;
+ };
+
+ /**
+ * Removes a listener.
+ *
+ * @api public
+ */
+
+ EventEmitter.prototype.removeListener = function (name, fn) {
+ if (this.$events && this.$events[name]) {
+ var list = this.$events[name];
+
+ if (io.util.isArray(list)) {
+ var pos = -1;
+
+ for (var i = 0, l = list.length; i < l; i++) {
+ if (list[i] === fn || (list[i].listener && list[i].listener === fn)) {
+ pos = i;
+ break;
+ }
+ }
+
+ if (pos < 0) {
+ return this;
+ }
+
+ list.splice(pos, 1);
+
+ if (!list.length) {
+ delete this.$events[name];
+ }
+ } else if (list === fn || (list.listener && list.listener === fn)) {
+ delete this.$events[name];
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Removes all listeners for an event.
+ *
+ * @api public
+ */
+
+ EventEmitter.prototype.removeAllListeners = function (name) {
+ // TODO: enable this when node 0.5 is stable
+ //if (name === undefined) {
+ //this.$events = {};
+ //return this;
+ //}
+
+ if (this.$events && this.$events[name]) {
+ this.$events[name] = null;
+ }
+
+ return this;
+ };
+
+ /**
+ * Gets all listeners for a certain event.
+ *
+ * @api publci
+ */
+
+ EventEmitter.prototype.listeners = function (name) {
+ if (!this.$events) {
+ this.$events = {};
+ }
+
+ if (!this.$events[name]) {
+ this.$events[name] = [];
+ }
+
+ if (!io.util.isArray(this.$events[name])) {
+ this.$events[name] = [this.$events[name]];
+ }
+
+ return this.$events[name];
+ };
+
+ /**
+ * Emits an event.
+ *
+ * @api public
+ */
+
+ EventEmitter.prototype.emit = function (name) {
+ if (!this.$events) {
+ return false;
+ }
+
+ var handler = this.$events[name];
+
+ if (!handler) {
+ return false;
+ }
+
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ if ('function' == typeof handler) {
+ handler.apply(this, args);
+ } else if (io.util.isArray(handler)) {
+ var listeners = handler.slice();
+
+ for (var i = 0, l = listeners.length; i < l; i++) {
+ listeners[i].apply(this, args);
+ }
+ } else {
+ return false;
+ }
+
+ return true;
+ };
+
+})(
+ 'undefined' != typeof io ? io : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+/**
+ * Based on JSON2 (http://www.JSON.org/js.html).
+ */
+
+(function (exports, nativeJSON) {
+ "use strict";
+
+ // use native JSON if it's available
+ if (nativeJSON && nativeJSON.parse){
+ return exports.JSON = {
+ parse: nativeJSON.parse
+ , stringify: nativeJSON.stringify
+ }
+ }
+
+ var JSON = exports.JSON = {};
+
+ function f(n) {
+ // Format integers to have at least two digits.
+ return n < 10 ? '0' + n : n;
+ }
+
+ function date(d, key) {
+ return isFinite(d.valueOf()) ?
+ d.getUTCFullYear() + '-' +
+ f(d.getUTCMonth() + 1) + '-' +
+ f(d.getUTCDate()) + 'T' +
+ f(d.getUTCHours()) + ':' +
+ f(d.getUTCMinutes()) + ':' +
+ f(d.getUTCSeconds()) + 'Z' : null;
+ };
+
+ var 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 = { // table of character substitutions
+ '\b': '\\b',
+ '\t': '\\t',
+ '\n': '\\n',
+ '\f': '\\f',
+ '\r': '\\r',
+ '"' : '\\"',
+ '\\': '\\\\'
+ },
+ rep;
+
+
+ function quote(string) {
+
+// If the string contains no control characters, no quote characters, and no
+// backslash characters, then we can safely slap some quotes around it.
+// Otherwise we must also replace the offending characters with safe escape
+// sequences.
+
+ escapable.lastIndex = 0;
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
+ var c = meta[a];
+ return typeof c === 'string' ? c :
+ '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ }) + '"' : '"' + string + '"';
+ }
+
+
+ function str(key, holder) {
+
+// Produce a string from holder[key].
+
+ var i, // The loop counter.
+ k, // The member key.
+ v, // The member value.
+ length,
+ mind = gap,
+ partial,
+ value = holder[key];
+
+// If the value has a toJSON method, call it to obtain a replacement value.
+
+ if (value instanceof Date) {
+ value = date(key);
+ }
+
+// If we were called with a replacer function, then call the replacer to
+// obtain a replacement value.
+
+ if (typeof rep === 'function') {
+ value = rep.call(holder, key, value);
+ }
+
+// What happens next depends on the value's type.
+
+ switch (typeof value) {
+ case 'string':
+ return quote(value);
+
+ case 'number':
+
+// JSON numbers must be finite. Encode non-finite numbers as null.
+
+ return isFinite(value) ? String(value) : 'null';
+
+ case 'boolean':
+ case 'null':
+
+// If the value is a boolean or null, convert it to a string. Note:
+// typeof null does not produce 'null'. The case is included here in
+// the remote chance that this gets fixed someday.
+
+ return String(value);
+
+// If the type is 'object', we might be dealing with an object or an array or
+// null.
+
+ case 'object':
+
+// Due to a specification blunder in ECMAScript, typeof null is 'object',
+// so watch out for that case.
+
+ if (!value) {
+ return 'null';
+ }
+
+// Make an array to hold the partial results of stringifying this object value.
+
+ gap += indent;
+ partial = [];
+
+// Is the value an array?
+
+ if (Object.prototype.toString.apply(value) === '[object Array]') {
+
+// The value is an array. Stringify every element. Use null as a placeholder
+// for non-JSON values.
+
+ length = value.length;
+ for (i = 0; i < length; i += 1) {
+ partial[i] = str(i, value) || 'null';
+ }
+
+// Join all of the elements together, separated with commas, and wrap them in
+// brackets.
+
+ v = partial.length === 0 ? '[]' : gap ?
+ '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
+ '[' + partial.join(',') + ']';
+ gap = mind;
+ return v;
+ }
+
+// If the replacer is an array, use it to select the members to be stringified.
+
+ if (rep && typeof rep === 'object') {
+ length = rep.length;
+ for (i = 0; i < length; i += 1) {
+ if (typeof rep[i] === 'string') {
+ k = rep[i];
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ } else {
+
+// Otherwise, iterate through all of the keys in the object.
+
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = str(k, value);
+ if (v) {
+ partial.push(quote(k) + (gap ? ': ' : ':') + v);
+ }
+ }
+ }
+ }
+
+// Join all of the member texts together, separated with commas,
+// and wrap them in braces.
+
+ v = partial.length === 0 ? '{}' : gap ?
+ '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
+ '{' + partial.join(',') + '}';
+ gap = mind;
+ return v;
+ }
+ }
+
+// If the JSON object does not yet have a stringify method, give it one.
+
+ JSON.stringify = function (value, replacer, space) {
+
+// The stringify method takes a value and an optional replacer, and an optional
+// space parameter, and returns a JSON text. The replacer can be a function
+// that can replace values, or an array of strings that will select the keys.
+// A default replacer method can be provided. Use of the space parameter can
+// produce text that is more easily readable.
+
+ var i;
+ gap = '';
+ indent = '';
+
+// If the space parameter is a number, make an indent string containing that
+// many spaces.
+
+ if (typeof space === 'number') {
+ for (i = 0; i < space; i += 1) {
+ indent += ' ';
+ }
+
+// If the space parameter is a string, it will be used as the indent string.
+
+ } else if (typeof space === 'string') {
+ indent = space;
+ }
+
+// If there is a replacer, it must be a function or an array.
+// Otherwise, throw an error.
+
+ rep = replacer;
+ if (replacer && typeof replacer !== 'function' &&
+ (typeof replacer !== 'object' ||
+ typeof replacer.length !== 'number')) {
+ throw new Error('JSON.stringify');
+ }
+
+// Make a fake root object containing our value under the key of ''.
+// Return the result of stringifying the value.
+
+ return str('', {'': value});
+ };
+
+// If the JSON object does not yet have a parse method, give it one.
+
+ JSON.parse = function (text, reviver) {
+ // The parse method takes a text and an optional reviver function, and returns
+ // a JavaScript value if the text is a valid JSON text.
+
+ var j;
+
+ function walk(holder, key) {
+
+ // The walk method is used to recursively walk the resulting structure so
+ // that modifications can be made.
+
+ var k, v, value = holder[key];
+ if (value && typeof value === 'object') {
+ for (k in value) {
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
+ v = walk(value, k);
+ if (v !== undefined) {
+ value[k] = v;
+ } else {
+ delete value[k];
+ }
+ }
+ }
+ }
+ return reviver.call(holder, key, value);
+ }
+
+
+ // Parsing happens in four stages. In the first stage, we replace certain
+ // Unicode characters with escape sequences. JavaScript handles many characters
+ // incorrectly, either silently deleting them, or treating them as line endings.
+
+ text = String(text);
+ cx.lastIndex = 0;
+ if (cx.test(text)) {
+ text = text.replace(cx, function (a) {
+ return '\\u' +
+ ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
+ });
+ }
+
+ // In the second stage, we run the text against regular expressions that look
+ // for non-JSON patterns. We are especially concerned with '()' and 'new'
+ // because they can cause invocation, and '=' because it can cause mutation.
+ // But just to be safe, we want to reject all unexpected forms.
+
+ // We split the second stage into 4 regexp operations in order to work around
+ // crippling inefficiencies in IE's and Safari's regexp engines. First we
+ // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
+ // replace all simple value tokens with ']' characters. Third, we delete all
+ // open brackets that follow a colon or comma or that begin the text. Finally,
+ // we look to see that the remaining characters are only whitespace or ']' or
+ // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
+
+ 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, ''))) {
+
+ // In the third stage we use the eval function to compile the text into a
+ // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
+ // in JavaScript: it can begin a block or an object literal. We wrap the text
+ // in parens to eliminate the ambiguity.
+
+ j = eval('(' + text + ')');
+
+ // In the optional fourth stage, we recursively walk the new structure, passing
+ // each name/value pair to a reviver function for possible transformation.
+
+ return typeof reviver === 'function' ?
+ walk({'': j}, '') : j;
+ }
+
+ // If the text is not JSON parseable, then a SyntaxError is thrown.
+
+ throw new SyntaxError('JSON.parse');
+ };
+
+})(
+ 'undefined' != typeof io ? io : module.exports
+ , typeof JSON !== 'undefined' ? JSON : undefined
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Parser namespace.
+ *
+ * @namespace
+ */
+
+ var parser = exports.parser = {};
+
+ /**
+ * Packet types.
+ */
+
+ var packets = parser.packets = [
+ 'disconnect'
+ , 'connect'
+ , 'heartbeat'
+ , 'message'
+ , 'json'
+ , 'event'
+ , 'ack'
+ , 'error'
+ , 'noop'
+ ];
+
+ /**
+ * Errors reasons.
+ */
+
+ var reasons = parser.reasons = [
+ 'transport not supported'
+ , 'client not handshaken'
+ , 'unauthorized'
+ ];
+
+ /**
+ * Errors advice.
+ */
+
+ var advice = parser.advice = [
+ 'reconnect'
+ ];
+
+ /**
+ * Shortcuts.
+ */
+
+ var JSON = io.JSON
+ , indexOf = io.util.indexOf;
+
+ /**
+ * Encodes a packet.
+ *
+ * @api private
+ */
+
+ parser.encodePacket = function (packet) {
+ var type = indexOf(packets, packet.type)
+ , id = packet.id || ''
+ , endpoint = packet.endpoint || ''
+ , ack = packet.ack
+ , data = null;
+
+ switch (packet.type) {
+ case 'error':
+ var reason = packet.reason ? indexOf(reasons, packet.reason) : ''
+ , adv = packet.advice ? indexOf(advice, packet.advice) : ''
+
+ if (reason !== '' || adv !== '')
+ data = reason + (adv !== '' ? ('+' + adv) : '')
+
+ break;
+
+ case 'message':
+ if (packet.data !== '')
+ data = packet.data;
+ break;
+
+ case 'event':
+ var ev = { name: packet.name };
+
+ if (packet.args && packet.args.length) {
+ ev.args = packet.args;
+ }
+
+ data = JSON.stringify(ev);
+ break;
+
+ case 'json':
+ data = JSON.stringify(packet.data);
+ break;
+
+ case 'connect':
+ if (packet.qs)
+ data = packet.qs;
+ break;
+
+ case 'ack':
+ data = packet.ackId
+ + (packet.args && packet.args.length
+ ? '+' + JSON.stringify(packet.args) : '');
+ break;
+ }
+
+ // construct packet with required fragments
+ var encoded = [
+ type
+ , id + (ack == 'data' ? '+' : '')
+ , endpoint
+ ];
+
+ // data fragment is optional
+ if (data !== null && data !== undefined)
+ encoded.push(data);
+
+ return encoded.join(':');
+ };
+
+ /**
+ * Encodes multiple messages (payload).
+ *
+ * @param {Array} messages
+ * @api private
+ */
+
+ parser.encodePayload = function (packets) {
+ var decoded = '';
+
+ if (packets.length == 1)
+ return packets[0];
+
+ for (var i = 0, l = packets.length; i < l; i++) {
+ var packet = packets[i];
+ decoded += '\ufffd' + packet.length + '\ufffd' + packets[i]
+ }
+
+ return decoded;
+ };
+
+ /**
+ * Decodes a packet
+ *
+ * @api private
+ */
+
+ var regexp = /^([^:]+):([0-9]+)?(\+)?:([^:]+)?:?(.*)?$/;
+
+ parser.decodePacket = function (data) {
+ var pieces = data.match(regexp);
+
+ if (!pieces) return {};
+
+ var id = pieces[2] || ''
+ , data = pieces[5] || ''
+ , packet = {
+ type: packets[pieces[1]]
+ , endpoint: pieces[4] || ''
+ };
+
+ // whether we need to acknowledge the packet
+ if (id) {
+ packet.id = id;
+ if (pieces[3])
+ packet.ack = 'data';
+ else
+ packet.ack = true;
+ }
+
+ // handle different packet types
+ switch (packet.type) {
+ case 'error':
+ var pieces = data.split('+');
+ packet.reason = reasons[pieces[0]] || '';
+ packet.advice = advice[pieces[1]] || '';
+ break;
+
+ case 'message':
+ packet.data = data || '';
+ break;
+
+ case 'event':
+ try {
+ var opts = JSON.parse(data);
+ packet.name = opts.name;
+ packet.args = opts.args;
+ } catch (e) { }
+
+ packet.args = packet.args || [];
+ break;
+
+ case 'json':
+ try {
+ packet.data = JSON.parse(data);
+ } catch (e) { }
+ break;
+
+ case 'connect':
+ packet.qs = data || '';
+ break;
+
+ case 'ack':
+ var pieces = data.match(/^([0-9]+)(\+)?(.*)/);
+ if (pieces) {
+ packet.ackId = pieces[1];
+ packet.args = [];
+
+ if (pieces[3]) {
+ try {
+ packet.args = pieces[3] ? JSON.parse(pieces[3]) : [];
+ } catch (e) { }
+ }
+ }
+ break;
+
+ case 'disconnect':
+ case 'heartbeat':
+ break;
+ };
+
+ return packet;
+ };
+
+ /**
+ * Decodes data payload. Detects multiple messages
+ *
+ * @return {Array} messages
+ * @api public
+ */
+
+ parser.decodePayload = function (data) {
+ // IE doesn't like data[i] for unicode chars, charAt works fine
+ if (data.charAt(0) == '\ufffd') {
+ var ret = [];
+
+ for (var i = 1, length = ''; i < data.length; i++) {
+ if (data.charAt(i) == '\ufffd') {
+ ret.push(parser.decodePacket(data.substr(i + 1).substr(0, length)));
+ i += Number(length) + 1;
+ length = '';
+ } else {
+ length += data.charAt(i);
+ }
+ }
+
+ return ret;
+ } else {
+ return [parser.decodePacket(data)];
+ }
+ };
+
+})(
+ 'undefined' != typeof io ? io : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.Transport = Transport;
+
+ /**
+ * This is the transport template for all supported transport methods.
+ *
+ * @constructor
+ * @api public
+ */
+
+ function Transport (socket, sessid) {
+ this.socket = socket;
+ this.sessid = sessid;
+ };
+
+ /**
+ * Apply EventEmitter mixin.
+ */
+
+ io.util.mixin(Transport, io.EventEmitter);
+
+ /**
+ * Handles the response from the server. When a new response is received
+ * it will automatically update the timeout, decode the message and
+ * forwards the response to the onMessage function for further processing.
+ *
+ * @param {String} data Response from the server.
+ * @api private
+ */
+
+ Transport.prototype.onData = function (data) {
+ this.clearCloseTimeout();
+ this.setCloseTimeout();
+
+ if (data !== '') {
+ // todo: we should only do decodePayload for xhr transports
+ var msgs = io.parser.decodePayload(data);
+
+ if (msgs && msgs.length) {
+ for (var i = 0, l = msgs.length; i < l; i++) {
+ this.onPacket(msgs[i]);
+ }
+ }
+ }
+
+ return this;
+ };
+
+ /**
+ * Handles packets.
+ *
+ * @api private
+ */
+
+ Transport.prototype.onPacket = function (packet) {
+ if (packet.type == 'heartbeat') {
+ return this.onHeartbeat();
+ }
+
+ if (packet.type == 'connect' && packet.endpoint == '') {
+ this.onConnect();
+ }
+
+ this.socket.onPacket(packet);
+
+ return this;
+ };
+
+ /**
+ * Sets close timeout
+ *
+ * @api private
+ */
+
+ Transport.prototype.setCloseTimeout = function () {
+ if (!this.closeTimeout) {
+ var self = this;
+
+ this.closeTimeout = setTimeout(function () {
+ self.onDisconnect();
+ }, this.socket.closeTimeout);
+ }
+ };
+
+ /**
+ * Called when transport disconnects.
+ *
+ * @api private
+ */
+
+ Transport.prototype.onDisconnect = function () {
+ if (this.close) this.close();
+ this.clearTimeouts();
+ this.socket.onDisconnect();
+ return this;
+ };
+
+ /**
+ * Called when transport connects
+ *
+ * @api private
+ */
+
+ Transport.prototype.onConnect = function () {
+ this.socket.onConnect();
+ return this;
+ }
+
+ /**
+ * Clears close timeout
+ *
+ * @api private
+ */
+
+ Transport.prototype.clearCloseTimeout = function () {
+ if (this.closeTimeout) {
+ clearTimeout(this.closeTimeout);
+ this.closeTimeout = null;
+ }
+ };
+
+ /**
+ * Clear timeouts
+ *
+ * @api private
+ */
+
+ Transport.prototype.clearTimeouts = function () {
+ this.clearCloseTimeout();
+
+ if (this.reopenTimeout) {
+ clearTimeout(this.reopenTimeout);
+ }
+ };
+
+ /**
+ * Sends a packet
+ *
+ * @param {Object} packet object.
+ * @api private
+ */
+
+ Transport.prototype.packet = function (packet) {
+ this.send(io.parser.encodePacket(packet));
+ };
+
+ /**
+ * Send the received heartbeat message back to server. So the server
+ * knows we are still connected.
+ *
+ * @param {String} heartbeat Heartbeat response from the server.
+ * @api private
+ */
+
+ Transport.prototype.onHeartbeat = function (heartbeat) {
+ this.packet({ type: 'heartbeat' });
+ };
+
+ /**
+ * Called when the transport opens.
+ *
+ * @api private
+ */
+
+ Transport.prototype.onOpen = function () {
+ this.open = true;
+ this.clearCloseTimeout();
+ this.socket.onOpen();
+ };
+
+ /**
+ * Notifies the base when the connection with the Socket.IO server
+ * has been disconnected.
+ *
+ * @api private
+ */
+
+ Transport.prototype.onClose = function () {
+ var self = this;
+
+ /* FIXME: reopen delay causing a infinit loop
+ this.reopenTimeout = setTimeout(function () {
+ self.open();
+ }, this.socket.options['reopen delay']);*/
+
+ this.open = false;
+ this.setCloseTimeout();
+ this.socket.onClose();
+ };
+
+ /**
+ * Generates a connection url based on the Socket.IO URL Protocol.
+ * See <https://github.com/learnboost/socket.io-node/> for more details.
+ *
+ * @returns {String} Connection url
+ * @api private
+ */
+
+ Transport.prototype.prepareUrl = function () {
+ var options = this.socket.options;
+
+ return this.scheme() + '://'
+ + options.host + ':' + options.port + '/'
+ + options.resource + '/' + io.protocol
+ + '/' + this.name + '/' + this.sessid;
+ };
+})(
+ 'undefined' != typeof io ? io : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.Socket = Socket;
+
+ /**
+ * Create a new `Socket.IO client` which can establish a persisent
+ * connection with a Socket.IO enabled server.
+ *
+ * @api public
+ */
+
+ function Socket (options) {
+ this.options = {
+ port: 80
+ , secure: false
+ , document: document
+ , resource: 'socket.io'
+ , transports: io.transports
+ , 'connect timeout': 10000
+ , 'try multiple transports': true
+ , 'reconnect': true
+ , 'reconnection delay': 500
+ , 'reopen delay': 3000
+ , 'max reconnection attempts': 10
+ , 'sync disconnect on unload': true
+ , 'auto connect': true
+ };
+
+ io.util.merge(this.options, options);
+
+ this.connected = false;
+ this.open = false;
+ this.connecting = false;
+ this.reconnecting = false;
+ this.namespaces = {};
+ this.buffer = [];
+ this.doBuffer = false;
+
+ if (this.options['sync disconnect on unload'] &&
+ (!this.isXDomain() || io.util.ua.hasCORS)) {
+ var self = this;
+
+ io.util.on(window, 'beforeunload', function () {
+ self.disconnectSync();
+ }, false);
+ }
+
+ if (this.options['auto connect']) {
+ this.connect();
+ }
+};
+
+ /**
+ * Apply EventEmitter mixin.
+ */
+
+ io.util.mixin(Socket, io.EventEmitter);
+
+ /**
+ * Returns a namespace listener/emitter for this socket
+ *
+ * @api public
+ */
+
+ Socket.prototype.of = function (name) {
+ if (!this.namespaces[name]) {
+ this.namespaces[name] = new io.SocketNamespace(this, name);
+
+ if (name !== '') {
+ this.namespaces[name].packet({ type: 'connect' });
+ }
+ }
+
+ return this.namespaces[name];
+ };
+
+ /**
+ * Emits the given event to the Socket and all namespaces
+ *
+ * @api private
+ */
+
+ Socket.prototype.publish = function () {
+ this.emit.apply(this, arguments);
+
+ var nsp;
+
+ for (var i in this.namespaces) {
+ if (this.namespaces.hasOwnProperty(i)) {
+ nsp = this.of(i);
+ nsp.$emit.apply(nsp, arguments);
+ }
+ }
+ };
+
+ /**
+ * Performs the handshake
+ *
+ * @api private
+ */
+
+ function empty () { };
+
+ Socket.prototype.handshake = function (fn) {
+ var self = this
+ , options = this.options;
+
+ function complete (data) {
+ if (data instanceof Error) {
+ self.onError(data.message);
+ } else {
+ fn.apply(null, data.split(':'));
+ }
+ };
+
+ var url = [
+ 'http' + (options.secure ? 's' : '') + ':/'
+ , options.host + ':' + options.port
+ , this.options.resource
+ , io.protocol
+ , '?t=' + + new Date
+ ].join('/');
+
+ if (this.isXDomain()) {
+ var insertAt = document.getElementsByTagName('script')[0]
+ , script = document.createElement('SCRIPT');
+
+ script.src = url + '&jsonp=' + io.j.length;
+ insertAt.parentNode.insertBefore(script, insertAt);
+
+ io.j.push(function (data) {
+ complete(data);
+ script.parentNode.removeChild(script);
+ });
+ } else {
+ var xhr = io.util.request();
+
+ xhr.open('GET', url);
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState == 4) {
+ xhr.onreadystatechange = empty;
+
+ if (xhr.status == 200) {
+ complete(xhr.responseText);
+ } else {
+ !self.reconnecting && self.onError(xhr.responseText);
+ }
+ }
+ };
+ xhr.send(null);
+ }
+ };
+
+ /**
+ * Find an available transport based on the options supplied in the constructor.
+ *
+ * @api private
+ */
+
+ Socket.prototype.getTransport = function (override) {
+ var transports = override || this.transports, match;
+
+ for (var i = 0, transport; transport = transports[i]; i++) {
+ if (io.Transport[transport]
+ && io.Transport[transport].check(this)
+ && (!this.isXDomain() || io.Transport[transport].xdomainCheck())) {
+ return new io.Transport[transport](this, this.sessionid);
+ }
+ }
+
+ return null;
+ };
+
+ /**
+ * Connects to the server.
+ *
+ * @param {Function} [fn] Callback.
+ * @returns {io.Socket}
+ * @api public
+ */
+
+ Socket.prototype.connect = function (fn) {
+ if (this.connecting) {
+ return this;
+ }
+
+ var self = this;
+
+ this.handshake(function (sid, heartbeat, close, transports) {
+ self.sessionid = sid;
+ self.closeTimeout = close * 1000;
+ self.heartbeatTimeout = heartbeat * 1000;
+ self.transports = io.util.intersect(
+ transports.split(',')
+ , self.options.transports
+ );
+
+ function connect (transports){
+ self.transport = self.getTransport(transports);
+ if (!self.transport) return self.publish('connect_failed');
+
+ self.connecting = true;
+ self.publish('connecting', self.transport.name);
+ self.transport.open();
+
+ if (self.options['connect timeout']) {
+ self.connectTimeoutTimer = setTimeout(function () {
+ if (!self.connected) {
+ self.connecting = false;
+
+ if (self.options['try multiple transports']) {
+ if (!self.remainingTransports) {
+ self.remainingTransports = self.transports.slice(0);
+ }
+
+ var remaining = self.remainingTransports;
+
+ while (remaining.length > 0 && remaining.splice(0,1)[0] !=
+ self.transport.name) {}
+
+ if (remaining.length){
+ connect(remaining);
+ } else {
+ self.publish('connect_failed');
+ }
+ }
+ }
+ }, self.options['connect timeout']);
+ }
+ }
+
+ connect();
+
+ self.once('connect', function (){
+ clearTimeout(self.connectTimeoutTimer);
+
+ fn && typeof fn == 'function' && fn();
+ });
+ });
+
+ return this;
+ };
+
+ /**
+ * Sends a message.
+ *
+ * @param {Object} data packet.
+ * @returns {io.Socket}
+ * @api public
+ */
+
+ Socket.prototype.packet = function (data) {
+ if (this.connected && !this.doBuffer) {
+ this.transport.packet(data);
+ } else {
+ this.buffer.push(data);
+ }
+
+ return this;
+ };
+
+ /**
+ * Sets buffer state
+ *
+ * @api private
+ */
+
+ Socket.prototype.setBuffer = function (v) {
+ this.doBuffer = v;
+
+ if (!v && this.connected && this.buffer.length) {
+ this.transport.payload(this.buffer);
+ this.buffer = [];
+ }
+ };
+
+ /**
+ * Disconnect the established connect.
+ *
+ * @returns {io.Socket}
+ * @api public
+ */
+
+ Socket.prototype.disconnect = function () {
+ if (this.connected) {
+ if (this.open) {
+ this.of('').packet({ type: 'disconnect' });
+ }
+
+ // handle disconnection immediately
+ this.onDisconnect('booted');
+ }
+
+ return this;
+ };
+
+ /**
+ * Disconnects the socket with a sync XHR.
+ *
+ * @api private
+ */
+
+ Socket.prototype.disconnectSync = function () {
+ // ensure disconnection
+ var xhr = io.util.request()
+ , uri = this.resource + '/' + io.protocol + '/' + this.sessionid;
+
+ xhr.open('GET', uri, true);
+
+ // handle disconnection immediately
+ this.onDisconnect('booted');
+ };
+
+ /**
+ * Check if we need to use cross domain enabled transports. Cross domain would
+ * be a different port or different domain name.
+ *
+ * @returns {Boolean}
+ * @api private
+ */
+
+ Socket.prototype.isXDomain = function () {
+ var locPort = window.location.port || 80;
+ return this.options.host !== document.domain || this.options.port != locPort;
+ };
+
+ /**
+ * Called upon handshake.
+ *
+ * @api private
+ */
+
+ Socket.prototype.onConnect = function () {
+ this.connected = true;
+ this.connecting = false;
+ if (!this.doBuffer) {
+ // make sure to flush the buffer
+ this.setBuffer(false);
+ }
+ this.emit('connect');
+ };
+
+ /**
+ * Called when the transport opens
+ *
+ * @api private
+ */
+
+ Socket.prototype.onOpen = function () {
+ this.open = true;
+ };
+
+ /**
+ * Called when the transport closes.
+ *
+ * @api private
+ */
+
+ Socket.prototype.onClose = function () {
+ this.open = false;
+ };
+
+ /**
+ * Called when the transport first opens a connection
+ *
+ * @param text
+ */
+
+ Socket.prototype.onPacket = function (packet) {
+ this.of(packet.endpoint).onPacket(packet);
+ };
+
+ /**
+ * Handles an error.
+ *
+ * @api private
+ */
+
+ Socket.prototype.onError = function (err) {
+ if (err && err.advice) {
+ if (err.advice === 'reconnect' && this.connected) {
+ this.disconnect();
+ this.reconnect();
+ }
+ }
+
+ this.publish('error', err && err.reason ? err.reason : err);
+ };
+
+ /**
+ * Called when the transport disconnects.
+ *
+ * @api private
+ */
+
+ Socket.prototype.onDisconnect = function (reason) {
+ var wasConnected = this.connected;
+
+ this.connected = false;
+ this.connecting = false;
+ this.open = false;
+
+ if (wasConnected) {
+ this.transport.close();
+ this.transport.clearTimeouts();
+ this.publish('disconnect', reason);
+
+ if ('booted' != reason && this.options.reconnect && !this.reconnecting) {
+ this.reconnect();
+ }
+ }
+ };
+
+ /**
+ * Called upon reconnection.
+ *
+ * @api private
+ */
+
+ Socket.prototype.reconnect = function () {
+ this.reconnecting = true;
+ this.reconnectionAttempts = 0;
+ this.reconnectionDelay = this.options['reconnection delay'];
+
+ var self = this
+ , maxAttempts = this.options['max reconnection attempts']
+ , tryMultiple = this.options['try multiple transports']
+
+ function reset () {
+ if (self.connected) {
+ self.publish('reconnect', self.transport.name, self.reconnectionAttempts);
+ }
+
+ self.removeListener('connect_failed', maybeReconnect);
+ self.removeListener('connect', maybeReconnect);
+
+ self.reconnecting = false;
+
+ delete self.reconnectionAttempts;
+ delete self.reconnectionDelay;
+ delete self.reconnectionTimer;
+ delete self.redoTransports;
+
+ self.options['try multiple transports'] = tryMultiple;
+ };
+
+ function maybeReconnect () {
+ if (!self.reconnecting) {
+ return;
+ }
+
+ if (self.connected) {
+ return reset();
+ };
+
+ if (self.connecting && self.reconnecting) {
+ return self.reconnectionTimer = setTimeout(maybeReconnect, 1000);
+ }
+
+ if (self.reconnectionAttempts++ >= maxAttempts) {
+ if (!self.redoTransports) {
+ self.on('connect_failed', maybeReconnect);
+ self.options['try multiple transports'] = true;
+ self.transport = self.getTransport();
+ self.redoTransports = true;
+ self.connect();
+ } else {
+ self.publish('reconnect_failed');
+ reset();
+ }
+ } else {
+ self.reconnectionDelay *= 2; // exponential back off
+ self.connect();
+ self.publish('reconnecting', self.reconnectionDelay, self.reconnectionAttempts);
+ self.reconnectionTimer = setTimeout(maybeReconnect, self.reconnectionDelay);
+ }
+ };
+
+ this.options['try multiple transports'] = false;
+ this.reconnectionTimer = setTimeout(maybeReconnect, this.reconnectionDelay);
+
+ this.on('connect', maybeReconnect);
+ };
+
+})(
+ 'undefined' != typeof io ? io : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.SocketNamespace = SocketNamespace;
+
+ /**
+ * Socket namespace constructor.
+ *
+ * @constructor
+ * @api public
+ */
+
+ function SocketNamespace (socket, name) {
+ this.socket = socket;
+ this.name = name || '';
+ this.flags = {};
+ this.json = new Flag(this, 'json');
+ this.ackPackets = 0;
+ this.acks = {};
+ };
+
+ /**
+ * Apply EventEmitter mixin.
+ */
+
+ io.util.mixin(SocketNamespace, io.EventEmitter);
+
+ /**
+ * Copies emit since we override it
+ *
+ * @api private
+ */
+
+ SocketNamespace.prototype.$emit = io.EventEmitter.prototype.emit;
+
+ /**
+ * Creates a new namespace, by proxying the request to the socket. This
+ * allows us to use the synax as we do on the server.
+ *
+ * @api public
+ */
+
+ SocketNamespace.prototype.of = function () {
+ return this.socket.of.apply(this.socket, arguments);
+ };
+
+ /**
+ * Sends a packet.
+ *
+ * @api private
+ */
+
+ SocketNamespace.prototype.packet = function (packet) {
+ packet.endpoint = this.name;
+ this.socket.packet(packet);
+ this.flags = {};
+ return this;
+ };
+
+ /**
+ * Sends a message
+ *
+ * @api public
+ */
+
+ SocketNamespace.prototype.send = function (data, fn) {
+ var packet = {
+ type: this.flags.json ? 'json' : 'message'
+ , data: data
+ };
+
+ if ('function' == typeof fn) {
+ packet.id = ++this.ackPackets;
+ packet.ack = true;
+ this.acks[packet.id] = fn;
+ }
+
+ return this.packet(packet);
+ };
+
+ /**
+ * Emits an event
+ *
+ * @api public
+ */
+
+ SocketNamespace.prototype.emit = function (name) {
+ var args = Array.prototype.slice.call(arguments, 1)
+ , lastArg = args[args.length - 1]
+ , packet = {
+ type: 'event'
+ , name: name
+ };
+
+ if ('function' == typeof lastArg) {
+ packet.id = ++this.ackPackets;
+ packet.ack = 'data';
+ this.acks[packet.id] = lastArg;
+ args = args.slice(0, args.length - 1);
+ }
+
+ packet.args = args;
+
+ return this.packet(packet);
+ };
+
+ /**
+ * Disconnects the namespace
+ *
+ * @api private
+ */
+
+ SocketNamespace.prototype.disconnect = function () {
+ if (this.name === '') {
+ this.socket.disconnect();
+ } else {
+ this.packet({ type: 'disconnect' });
+ this.$emit('disconnect');
+ }
+
+ return this;
+ };
+
+ /**
+ * Handles a packet
+ *
+ * @api private
+ */
+
+ SocketNamespace.prototype.onPacket = function (packet) {
+ var self = this;
+
+ function ack () {
+ self.packet({
+ type: 'ack'
+ , args: io.util.toArray(arguments)
+ , ackId: packet.id
+ });
+ };
+
+ switch (packet.type) {
+ case 'connect':
+ this.$emit('connect');
+ break;
+
+ case 'disconnect':
+ if (this.name === '') {
+ this.socket.onDisconnect(packet.reason || 'booted');
+ } else {
+ this.$emit('disconnect', packet.reason);
+ }
+ break;
+
+ case 'message':
+ case 'json':
+ var params = ['message', packet.data];
+
+ if (packet.ack == 'data') {
+ params.push(ack);
+ } else if (packet.ack) {
+ this.packet({ type: 'ack', ackId: packet.id });
+ }
+
+ this.$emit.apply(this, params);
+ break;
+
+ case 'event':
+ var params = [packet.name].concat(packet.args);
+
+ if (packet.ack == 'data')
+ params.push(ack);
+
+ this.$emit.apply(this, params);
+ break;
+
+ case 'ack':
+ if (this.acks[packet.ackId]) {
+ this.acks[packet.ackId].apply(this, packet.args);
+ delete this.acks[packet.ackId];
+ }
+ break;
+
+ case 'error':
+ if (packet.advice){
+ this.socket.onError(packet);
+ } else {
+ if (packet.reason == 'unauthorized') {
+ this.$emit('connect_failed', packet.reason);
+ } else {
+ this.$emit('error', packet.reason);
+ }
+ }
+ break;
+ }
+ };
+
+ /**
+ * Flag interface.
+ *
+ * @api private
+ */
+
+ function Flag (nsp, name) {
+ this.namespace = nsp;
+ this.name = name;
+ };
+
+ /**
+ * Send a message
+ *
+ * @api public
+ */
+
+ Flag.prototype.send = function () {
+ this.namespace.flags[this.name] = true;
+ this.namespace.send.apply(this.namespace, arguments);
+ };
+
+ /**
+ * Emit an event
+ *
+ * @api public
+ */
+
+ Flag.prototype.emit = function () {
+ this.namespace.flags[this.name] = true;
+ this.namespace.emit.apply(this.namespace, arguments);
+ };
+
+})(
+ 'undefined' != typeof io ? io : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.websocket = WS;
+
+ /**
+ * The WebSocket transport uses the HTML5 WebSocket API to establish an
+ * persistent connection with the Socket.IO server. This transport will also
+ * be inherited by the FlashSocket fallback as it provides a API compatible
+ * polyfill for the WebSockets.
+ *
+ * @constructor
+ * @extends {io.Transport}
+ * @api public
+ */
+
+ function WS (socket) {
+ io.Transport.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from Transport.
+ */
+
+ io.util.inherit(WS, io.Transport);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ WS.prototype.name = 'websocket';
+
+ /**
+ * Initializes a new `WebSocket` connection with the Socket.IO server. We attach
+ * all the appropriate listeners to handle the responses from the server.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ WS.prototype.open = function () {
+ this.websocket = new WebSocket(this.prepareUrl());
+
+ var self = this;
+ this.websocket.onopen = function () {
+ self.onOpen();
+ self.socket.setBuffer(false);
+ };
+ this.websocket.onmessage = function (ev) {
+ self.onData(ev.data);
+ };
+ this.websocket.onclose = function () {
+ self.onClose();
+ self.socket.setBuffer(true);
+ };
+ this.websocket.onerror = function (e) {
+ self.onError(e);
+ };
+
+ return this;
+ };
+
+ /**
+ * Send a message to the Socket.IO server. The message will automatically be
+ * encoded in the correct message format.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ WS.prototype.send = function (data) {
+ this.websocket.send(data);
+ return this;
+ };
+
+ /**
+ * Payload
+ *
+ * @api private
+ */
+
+ WS.prototype.payload = function (arr) {
+ for (var i = 0, l = arr.length; i < l; i++) {
+ this.packet(arr[i]);
+ }
+ return this;
+ };
+
+ /**
+ * Disconnect the established `WebSocket` connection.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ WS.prototype.close = function () {
+ this.websocket.close();
+ return this;
+ };
+
+ /**
+ * Handle the errors that `WebSocket` might be giving when we
+ * are attempting to connect or send messages.
+ *
+ * @param {Error} e The error.
+ * @api private
+ */
+
+ WS.prototype.onError = function (e) {
+ this.socket.onError(e);
+ };
+
+ /**
+ * Returns the appropriate scheme for the URI generation.
+ *
+ * @api private
+ */
+ WS.prototype.scheme = function () {
+ return this.socket.options.secure ? 'wss' : 'ws';
+ };
+
+ /**
+ * Checks if the browser has support for native `WebSockets` and that
+ * it's not the polyfill created for the FlashSocket transport.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+ WS.check = function () {
+ return 'WebSocket' in window && !('__addTask' in WebSocket);
+ };
+
+ /**
+ * Check if the `WebSocket` transport support cross domain communications.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ WS.xdomainCheck = function () {
+ return true;
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('websocket');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.flashsocket = Flashsocket;
+
+ /**
+ * The Flashsocket transport. This is a API wrapper for the HTML5 WebSocket
+ * specification. It uses a .swf file to communicate with the server. If you want
+ * to serve the .swf file from a other server than where the Socket.IO script is
+ * coming from you need to use the insecure version of the .swf. More information
+ * about this can be found on the github page.
+ *
+ * @constructor
+ * @extends {io.Transport.websocket}
+ * @api public
+ */
+
+ function Flashsocket () {
+ io.Transport.websocket.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from Transport.
+ */
+
+ io.util.inherit(Flashsocket, io.Transport.websocket);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ Flashsocket.prototype.name = 'flashsocket';
+
+ /**
+ *Disconnect the established `Flashsocket` connection. This is done by adding a
+ * new task to the Flashsocket. The rest will be handled off by the `WebSocket`
+ * transport.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ Flashsocket.prototype.open = function () {
+ var self = this, args = arguments;
+ WebSocket.__addTask(function () {
+ io.Transport.websocket.prototype.open.apply(self, args);
+ });
+ return this;
+ };
+
+ /**
+ * Sends a message to the Socket.IO server. This is done by adding a new
+ * task to the Flashsocket. The rest will be handled off by the `WebSocket`
+ * transport.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ Flashsocket.prototype.send = function () {
+ var self = this, args = arguments;
+ WebSocket.__addTask(function () {
+ io.Transport.websocket.prototype.send.apply(self, args);
+ });
+ return this;
+ };
+
+ /**
+ * Disconnects the established `Flashsocket` connection.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ Flashsocket.prototype.close = function () {
+ WebSocket.__tasks.length = 0;
+ io.Transport.websocket.prototype.close.call(this);
+ return this;
+ };
+
+ /**
+ * Check if the Flashsocket transport is supported as it requires that the Adobe
+ * Flash Player plugin version `10.0.0` or greater is installed. And also check if
+ * the polyfill is correctly loaded.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ Flashsocket.check = function (socket) {
+ if (
+ typeof WebSocket == 'undefined'
+ || !('__initialize' in WebSocket) || !swfobject
+ ) return false;
+
+ var supported = swfobject.getFlashPlayerVersion().major >= 10
+ , options = socket.options
+ , path = [
+ 'http' + (options.secure ? 's' : '') + ':/'
+ , options.host + ':' + options.port
+ , options.resource
+ , 'static/flashsocket'
+ , 'WebSocketMain' + (socket.isXDomain() ? 'Insecure' : '') + '.swf'
+ ];
+
+ // Only start downloading the swf file when the checked that this browser
+ // actually supports it
+ if (supported && !Flashsocket.loaded) {
+ if (typeof WEB_SOCKET_SWF_LOCATION === 'undefined') {
+ // Set the correct file based on the XDomain settings
+ WEB_SOCKET_SWF_LOCATION = path.join('/');
+ }
+
+ WebSocket.__initialize();
+ Flashsocket.loaded = true;
+ }
+
+ return supported;
+ };
+
+ /**
+ * Check if the Flashsocket transport can be used as cross domain / cross origin
+ * transport. Because we can't see which type (secure or insecure) of .swf is used
+ * we will just return true.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ Flashsocket.xdomainCheck = function () {
+ return true;
+ };
+
+ /**
+ * Disable AUTO_INITIALIZATION
+ */
+
+ if (typeof window != 'undefined') {
+ WEB_SOCKET_DISABLE_AUTO_INITIALIZATION = true;
+ }
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('flashsocket');
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+/* SWFObject v2.2 <http://code.google.com/p/swfobject/>
+ is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
+*/
+var swfobject=function(){var D="undefined",r="object",S="Shockwave Flash",W="ShockwaveFlash.ShockwaveFlash",q="application/x-shockwave-flash",R="SWFObjectExprInst",x="onreadystatechange",O=window,j=document,t=navigator,T=false,U=[h],o=[],N=[],I=[],l,Q,E,B,J=false,a=false,n,G,m=true,M=function(){var aa=typeof j.getElementById!=D&&typeof j.getElementsByTagName!=D&&typeof j.createElement!=D,ah=t.userAgent.toLowerCase(),Y=t.platform.toLowerCase(),ae=Y?/win/.test(Y):/win/.test(ah),ac=Y?/mac/.test(Y):/mac/.test(ah),af=/webkit/.test(ah)?parseFloat(ah.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,X=!+"\v1",ag=[0,0,0],ab=null;if(typeof t.plugins!=D&&typeof t.plugins[S]==r){ab=t.plugins[S].description;if(ab&&!(typeof t.mimeTypes!=D&&t.mimeTypes[q]&&!t.mimeTypes[q].enabledPlugin)){T=true;X=false;ab=ab.replace(/^.*\s+(\S+\s+\S+$)/,"$1");ag[0]=parseInt(ab.replace(/^(.*)\..*$/,"$1"),10);ag[1]=parseInt(ab.replace(/^.*\.(.*)\s.*$/,"$1"),10);ag[2]=/[a-zA-Z]/.test(ab)?parseInt(ab.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0}}else{if(typeof O.ActiveXObject!=D){try{var ad=new ActiveXObject(W);if(ad){ab=ad.GetVariable("$version");if(ab){X=true;ab=ab.split(" ")[1].split(",");ag=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}}catch(Z){}}}return{w3:aa,pv:ag,wk:af,ie:X,win:ae,mac:ac}}(),k=function(){if(!M.w3){return}if((typeof j.readyState!=D&&j.readyState=="complete")||(typeof j.readyState==D&&(j.getElementsByTagName("body")[0]||j.body))){f()}if(!J){if(typeof j.addEventListener!=D){j.addEventListener("DOMContentLoaded",f,false)}if(M.ie&&M.win){j.attachEvent(x,function(){if(j.readyState=="complete"){j.detachEvent(x,arguments.callee);f()}});if(O==top){(function(){if(J){return}try{j.documentElement.doScroll("left")}catch(X){setTimeout(arguments.callee,0);return}f()})()}}if(M.wk){(function(){if(J){return}if(!/loaded|complete/.test(j.readyState)){setTimeout(arguments.callee,0);return}f()})()}s(f)}}();function f(){if(J){return}try{var Z=j.getElementsByTagName("body")[0].appendChild(C("span"));Z.parentNode.removeChild(Z)}catch(aa){return}J=true;var X=U.length;for(var Y=0;Y<X;Y++){U[Y]()}}function K(X){if(J){X()}else{U[U.length]=X}}function s(Y){if(typeof O.addEventListener!=D){O.addEventListener("load",Y,false)}else{if(typeof j.addEventListener!=D){j.addEventListener("load",Y,false)}else{if(typeof O.attachEvent!=D){i(O,"onload",Y)}else{if(typeof O.onload=="function"){var X=O.onload;O.onload=function(){X();Y()}}else{O.onload=Y}}}}}function h(){if(T){V()}else{H()}}function V(){var X=j.getElementsByTagName("body")[0];var aa=C(r);aa.setAttribute("type",q);var Z=X.appendChild(aa);if(Z){var Y=0;(function(){if(typeof Z.GetVariable!=D){var ab=Z.GetVariable("$version");if(ab){ab=ab.split(" ")[1].split(",");M.pv=[parseInt(ab[0],10),parseInt(ab[1],10),parseInt(ab[2],10)]}}else{if(Y<10){Y++;setTimeout(arguments.callee,10);return}}X.removeChild(aa);Z=null;H()})()}else{H()}}function H(){var ag=o.length;if(ag>0){for(var af=0;af<ag;af++){var Y=o[af].id;var ab=o[af].callbackFn;var aa={success:false,id:Y};if(M.pv[0]>0){var ae=c(Y);if(ae){if(F(o[af].swfVersion)&&!(M.wk&&M.wk<312)){w(Y,true);if(ab){aa.success=true;aa.ref=z(Y);ab(aa)}}else{if(o[af].expressInstall&&A()){var ai={};ai.data=o[af].expressInstall;ai.width=ae.getAttribute("width")||"0";ai.height=ae.getAttribute("height")||"0";if(ae.getAttribute("class")){ai.styleclass=ae.getAttribute("class")}if(ae.getAttribute("align")){ai.align=ae.getAttribute("align")}var ah={};var X=ae.getElementsByTagName("param");var ac=X.length;for(var ad=0;ad<ac;ad++){if(X[ad].getAttribute("name").toLowerCase()!="movie"){ah[X[ad].getAttribute("name")]=X[ad].getAttribute("value")}}P(ai,ah,Y,ab)}else{p(ae);if(ab){ab(aa)}}}}}else{w(Y,true);if(ab){var Z=z(Y);if(Z&&typeof Z.SetVariable!=D){aa.success=true;aa.ref=Z}ab(aa)}}}}}function z(aa){var X=null;var Y=c(aa);if(Y&&Y.nodeName=="OBJECT"){if(typeof Y.SetVariable!=D){X=Y}else{var Z=Y.getElementsByTagName(r)[0];if(Z){X=Z}}}return X}function A(){return !a&&F("6.0.65")&&(M.win||M.mac)&&!(M.wk&&M.wk<312)}function P(aa,ab,X,Z){a=true;E=Z||null;B={success:false,id:X};var ae=c(X);if(ae){if(ae.nodeName=="OBJECT"){l=g(ae);Q=null}else{l=ae;Q=X}aa.id=R;if(typeof aa.width==D||(!/%$/.test(aa.width)&&parseInt(aa.width,10)<310)){aa.width="310"}if(typeof aa.height==D||(!/%$/.test(aa.height)&&parseInt(aa.height,10)<137)){aa.height="137"}j.title=j.title.slice(0,47)+" - Flash Player Installation";var ad=M.ie&&M.win?"ActiveX":"PlugIn",ac="MMredirectURL="+O.location.toString().replace(/&/g,"%26")+"&MMplayerType="+ad+"&MMdoctitle="+j.title;if(typeof ab.flashvars!=D){ab.flashvars+="&"+ac}else{ab.flashvars=ac}if(M.ie&&M.win&&ae.readyState!=4){var Y=C("div");X+="SWFObjectNew";Y.setAttribute("id",X);ae.parentNode.insertBefore(Y,ae);ae.style.display="none";(function(){if(ae.readyState==4){ae.parentNode.removeChild(ae)}else{setTimeout(arguments.callee,10)}})()}u(aa,ab,X)}}function p(Y){if(M.ie&&M.win&&Y.readyState!=4){var X=C("div");Y.parentNode.insertBefore(X,Y);X.parentNode.replaceChild(g(Y),X);Y.style.display="none";(function(){if(Y.readyState==4){Y.parentNode.removeChild(Y)}else{setTimeout(arguments.callee,10)}})()}else{Y.parentNode.replaceChild(g(Y),Y)}}function g(ab){var aa=C("div");if(M.win&&M.ie){aa.innerHTML=ab.innerHTML}else{var Y=ab.getElementsByTagName(r)[0];if(Y){var ad=Y.childNodes;if(ad){var X=ad.length;for(var Z=0;Z<X;Z++){if(!(ad[Z].nodeType==1&&ad[Z].nodeName=="PARAM")&&!(ad[Z].nodeType==8)){aa.appendChild(ad[Z].cloneNode(true))}}}}}return aa}function u(ai,ag,Y){var X,aa=c(Y);if(M.wk&&M.wk<312){return X}if(aa){if(typeof ai.id==D){ai.id=Y}if(M.ie&&M.win){var ah="";for(var ae in ai){if(ai[ae]!=Object.prototype[ae]){if(ae.toLowerCase()=="data"){ag.movie=ai[ae]}else{if(ae.toLowerCase()=="styleclass"){ah+=' class="'+ai[ae]+'"'}else{if(ae.toLowerCase()!="classid"){ah+=" "+ae+'="'+ai[ae]+'"'}}}}}var af="";for(var ad in ag){if(ag[ad]!=Object.prototype[ad]){af+='<param name="'+ad+'" value="'+ag[ad]+'" />'}}aa.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+ah+">"+af+"</object>";N[N.length]=ai.id;X=c(ai.id)}else{var Z=C(r);Z.setAttribute("type",q);for(var ac in ai){if(ai[ac]!=Object.prototype[ac]){if(ac.toLowerCase()=="styleclass"){Z.setAttribute("class",ai[ac])}else{if(ac.toLowerCase()!="classid"){Z.setAttribute(ac,ai[ac])}}}}for(var ab in ag){if(ag[ab]!=Object.prototype[ab]&&ab.toLowerCase()!="movie"){e(Z,ab,ag[ab])}}aa.parentNode.replaceChild(Z,aa);X=Z}}return X}function e(Z,X,Y){var aa=C("param");aa.setAttribute("name",X);aa.setAttribute("value",Y);Z.appendChild(aa)}function y(Y){var X=c(Y);if(X&&X.nodeName=="OBJECT"){if(M.ie&&M.win){X.style.display="none";(function(){if(X.readyState==4){b(Y)}else{setTimeout(arguments.callee,10)}})()}else{X.parentNode.removeChild(X)}}}function b(Z){var Y=c(Z);if(Y){for(var X in Y){if(typeof Y[X]=="function"){Y[X]=null}}Y.parentNode.removeChild(Y)}}function c(Z){var X=null;try{X=j.getElementById(Z)}catch(Y){}return X}function C(X){return j.createElement(X)}function i(Z,X,Y){Z.attachEvent(X,Y);I[I.length]=[Z,X,Y]}function F(Z){var Y=M.pv,X=Z.split(".");X[0]=parseInt(X[0],10);X[1]=parseInt(X[1],10)||0;X[2]=parseInt(X[2],10)||0;return(Y[0]>X[0]||(Y[0]==X[0]&&Y[1]>X[1])||(Y[0]==X[0]&&Y[1]==X[1]&&Y[2]>=X[2]))?true:false}function v(ac,Y,ad,ab){if(M.ie&&M.mac){return}var aa=j.getElementsByTagName("head")[0];if(!aa){return}var X=(ad&&typeof ad=="string")?ad:"screen";if(ab){n=null;G=null}if(!n||G!=X){var Z=C("style");Z.setAttribute("type","text/css");Z.setAttribute("media",X);n=aa.appendChild(Z);if(M.ie&&M.win&&typeof j.styleSheets!=D&&j.styleSheets.length>0){n=j.styleSheets[j.styleSheets.length-1]}G=X}if(M.ie&&M.win){if(n&&typeof n.addRule==r){n.addRule(ac,Y)}}else{if(n&&typeof j.createTextNode!=D){n.appendChild(j.createTextNode(ac+" {"+Y+"}"))}}}function w(Z,X){if(!m){return}var Y=X?"visible":"hidden";if(J&&c(Z)){c(Z).style.visibility=Y}else{v("#"+Z,"visibility:"+Y)}}function L(Y){var Z=/[\\\"<>\.;]/;var X=Z.exec(Y)!=null;return X&&typeof encodeURIComponent!=D?encodeURIComponent(Y):Y}var d=function(){if(M.ie&&M.win){window.attachEvent("onunload",function(){var ac=I.length;for(var ab=0;ab<ac;ab++){I[ab][0].detachEvent(I[ab][1],I[ab][2])}var Z=N.length;for(var aa=0;aa<Z;aa++){y(N[aa])}for(var Y in M){M[Y]=null}M=null;for(var X in swfobject){swfobject[X]=null}swfobject=null})}}();return{registerObject:function(ab,X,aa,Z){if(M.w3&&ab&&X){var Y={};Y.id=ab;Y.swfVersion=X;Y.expressInstall=aa;Y.callbackFn=Z;o[o.length]=Y;w(ab,false)}else{if(Z){Z({success:false,id:ab})}}},getObjectById:function(X){if(M.w3){return z(X)}},embedSWF:function(ab,ah,ae,ag,Y,aa,Z,ad,af,ac){var X={success:false,id:ah};if(M.w3&&!(M.wk&&M.wk<312)&&ab&&ah&&ae&&ag&&Y){w(ah,false);K(function(){ae+="";ag+="";var aj={};if(af&&typeof af===r){for(var al in af){aj[al]=af[al]}}aj.data=ab;aj.width=ae;aj.height=ag;var am={};if(ad&&typeof ad===r){for(var ak in ad){am[ak]=ad[ak]}}if(Z&&typeof Z===r){for(var ai in Z){if(typeof am.flashvars!=D){am.flashvars+="&"+ai+"="+Z[ai]}else{am.flashvars=ai+"="+Z[ai]}}}if(F(Y)){var an=u(aj,am,ah);if(aj.id==ah){w(ah,true)}X.success=true;X.ref=an}else{if(aa&&A()){aj.data=aa;P(aj,am,ah,ac);return}else{w(ah,true)}}if(ac){ac(X)}})}else{if(ac){ac(X)}}},switchOffAutoHideShow:function(){m=false},ua:M,getFlashPlayerVersion:function(){return{major:M.pv[0],minor:M.pv[1],release:M.pv[2]}},hasFlashPlayerVersion:F,createSWF:function(Z,Y,X){if(M.w3){return u(Z,Y,X)}else{return undefined}},showExpressInstall:function(Z,aa,X,Y){if(M.w3&&A()){P(Z,aa,X,Y)}},removeSWF:function(X){if(M.w3){y(X)}},createCSS:function(aa,Z,Y,X){if(M.w3){v(aa,Z,Y,X)}},addDomLoadEvent:K,addLoadEvent:s,getQueryParamValue:function(aa){var Z=j.location.search||j.location.hash;if(Z){if(/\?/.test(Z)){Z=Z.split("?")[1]}if(aa==null){return L(Z)}var Y=Z.split("&");for(var X=0;X<Y.length;X++){if(Y[X].substring(0,Y[X].indexOf("="))==aa){return L(Y[X].substring((Y[X].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(a){var X=c(R);if(X&&l){X.parentNode.replaceChild(l,X);if(Q){w(Q,true);if(M.ie&&M.win){l.style.display="block"}}if(E){E(B)}}a=false}}}}();// Copyright: Hiroshi Ichikawa <http://gimite.net/en/>
+// License: New BSD License
+// Reference: http://dev.w3.org/html5/websockets/
+// Reference: http://tools.ietf.org/html/draft-hixie-thewebsocketprotocol
+
+(function() {
+
+ if (window.WebSocket) return;
+
+ var console = window.console;
+ if (!console || !console.log || !console.error) {
+ console = {log: function(){ }, error: function(){ }};
+ }
+
+ if (!swfobject.hasFlashPlayerVersion("10.0.0")) {
+ console.error("Flash Player >= 10.0.0 is required.");
+ return;
+ }
+ if (location.protocol == "file:") {
+ console.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://...");
+ }
+
+ /**
+ * This class represents a faux web socket.
+ * @param {string} url
+ * @param {array or string} protocols
+ * @param {string} proxyHost
+ * @param {int} proxyPort
+ * @param {string} headers
+ */
+ WebSocket = function(url, protocols, proxyHost, proxyPort, headers) {
+ var self = this;
+ self.__id = WebSocket.__nextId++;
+ WebSocket.__instances[self.__id] = self;
+ self.readyState = WebSocket.CONNECTING;
+ self.bufferedAmount = 0;
+ self.__events = {};
+ if (!protocols) {
+ protocols = [];
+ } else if (typeof protocols == "string") {
+ protocols = [protocols];
+ }
+ // Uses setTimeout() to make sure __createFlash() runs after the caller sets ws.onopen etc.
+ // Otherwise, when onopen fires immediately, onopen is called before it is set.
+ setTimeout(function() {
+ WebSocket.__addTask(function() {
+ WebSocket.__flash.create(
+ self.__id, url, protocols, proxyHost || null, proxyPort || 0, headers || null);
+ });
+ }, 0);
+ };
+
+ /**
+ * Send data to the web socket.
+ * @param {string} data The data to send to the socket.
+ * @return {boolean} True for success, false for failure.
+ */
+ WebSocket.prototype.send = function(data) {
+ if (this.readyState == WebSocket.CONNECTING) {
+ throw "INVALID_STATE_ERR: Web Socket connection has not been established";
+ }
+ // We use encodeURIComponent() here, because FABridge doesn't work if
+ // the argument includes some characters. We don't use escape() here
+ // because of this:
+ // https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Functions#escape_and_unescape_Functions
+ // But it looks decodeURIComponent(encodeURIComponent(s)) doesn't
+ // preserve all Unicode characters either e.g. "\uffff" in Firefox.
+ // Note by wtritch: Hopefully this will not be necessary using ExternalInterface. Will require
+ // additional testing.
+ var result = WebSocket.__flash.send(this.__id, encodeURIComponent(data));
+ if (result < 0) { // success
+ return true;
+ } else {
+ this.bufferedAmount += result;
+ return false;
+ }
+ };
+
+ /**
+ * Close this web socket gracefully.
+ */
+ WebSocket.prototype.close = function() {
+ if (this.readyState == WebSocket.CLOSED || this.readyState == WebSocket.CLOSING) {
+ return;
+ }
+ this.readyState = WebSocket.CLOSING;
+ WebSocket.__flash.close(this.__id);
+ };
+
+ /**
+ * Implementation of {@link <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">DOM 2 EventTarget Interface</a>}
+ *
+ * @param {string} type
+ * @param {function} listener
+ * @param {boolean} useCapture
+ * @return void
+ */
+ WebSocket.prototype.addEventListener = function(type, listener, useCapture) {
+ if (!(type in this.__events)) {
+ this.__events[type] = [];
+ }
+ this.__events[type].push(listener);
+ };
+
+ /**
+ * Implementation of {@link <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">DOM 2 EventTarget Interface</a>}
+ *
+ * @param {string} type
+ * @param {function} listener
+ * @param {boolean} useCapture
+ * @return void
+ */
+ WebSocket.prototype.removeEventListener = function(type, listener, useCapture) {
+ if (!(type in this.__events)) return;
+ var events = this.__events[type];
+ for (var i = events.length - 1; i >= 0; --i) {
+ if (events[i] === listener) {
+ events.splice(i, 1);
+ break;
+ }
+ }
+ };
+
+ /**
+ * Implementation of {@link <a href="http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-registration">DOM 2 EventTarget Interface</a>}
+ *
+ * @param {Event} event
+ * @return void
+ */
+ WebSocket.prototype.dispatchEvent = function(event) {
+ var events = this.__events[event.type] || [];
+ for (var i = 0; i < events.length; ++i) {
+ events[i](event);
+ }
+ var handler = this["on" + event.type];
+ if (handler) handler(event);
+ };
+
+ /**
+ * Handles an event from Flash.
+ * @param {Object} flashEvent
+ */
+ WebSocket.prototype.__handleEvent = function(flashEvent) {
+ if ("readyState" in flashEvent) {
+ this.readyState = flashEvent.readyState;
+ }
+ if ("protocol" in flashEvent) {
+ this.protocol = flashEvent.protocol;
+ }
+
+ var jsEvent;
+ if (flashEvent.type == "open" || flashEvent.type == "error") {
+ jsEvent = this.__createSimpleEvent(flashEvent.type);
+ } else if (flashEvent.type == "close") {
+ // TODO implement jsEvent.wasClean
+ jsEvent = this.__createSimpleEvent("close");
+ } else if (flashEvent.type == "message") {
+ var data = decodeURIComponent(flashEvent.message);
+ jsEvent = this.__createMessageEvent("message", data);
+ } else {
+ throw "unknown event type: " + flashEvent.type;
+ }
+
+ this.dispatchEvent(jsEvent);
+ };
+
+ WebSocket.prototype.__createSimpleEvent = function(type) {
+ if (document.createEvent && window.Event) {
+ var event = document.createEvent("Event");
+ event.initEvent(type, false, false);
+ return event;
+ } else {
+ return {type: type, bubbles: false, cancelable: false};
+ }
+ };
+
+ WebSocket.prototype.__createMessageEvent = function(type, data) {
+ if (document.createEvent && window.MessageEvent && !window.opera) {
+ var event = document.createEvent("MessageEvent");
+ event.initMessageEvent("message", false, false, data, null, null, window, null);
+ return event;
+ } else {
+ // IE and Opera, the latter one truncates the data parameter after any 0x00 bytes.
+ return {type: type, data: data, bubbles: false, cancelable: false};
+ }
+ };
+
+ /**
+ * Define the WebSocket readyState enumeration.
+ */
+ WebSocket.CONNECTING = 0;
+ WebSocket.OPEN = 1;
+ WebSocket.CLOSING = 2;
+ WebSocket.CLOSED = 3;
+
+ WebSocket.__flash = null;
+ WebSocket.__instances = {};
+ WebSocket.__tasks = [];
+ WebSocket.__nextId = 0;
+
+ /**
+ * Load a new flash security policy file.
+ * @param {string} url
+ */
+ WebSocket.loadFlashPolicyFile = function(url){
+ WebSocket.__addTask(function() {
+ WebSocket.__flash.loadManualPolicyFile(url);
+ });
+ };
+
+ /**
+ * Loads WebSocketMain.swf and creates WebSocketMain object in Flash.
+ */
+ WebSocket.__initialize = function() {
+ if (WebSocket.__flash) return;
+
+ if (WebSocket.__swfLocation) {
+ // For backword compatibility.
+ window.WEB_SOCKET_SWF_LOCATION = WebSocket.__swfLocation;
+ }
+ if (!window.WEB_SOCKET_SWF_LOCATION) {
+ console.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf");
+ return;
+ }
+ var container = document.createElement("div");
+ container.id = "webSocketContainer";
+ // Hides Flash box. We cannot use display: none or visibility: hidden because it prevents
+ // Flash from loading at least in IE. So we move it out of the screen at (-100, -100).
+ // But this even doesn't work with Flash Lite (e.g. in Droid Incredible). So with Flash
+ // Lite, we put it at (0, 0). This shows 1x1 box visible at left-top corner but this is
+ // the best we can do as far as we know now.
+ container.style.position = "absolute";
+ if (WebSocket.__isFlashLite()) {
+ container.style.left = "0px";
+ container.style.top = "0px";
+ } else {
+ container.style.left = "-100px";
+ container.style.top = "-100px";
+ }
+ var holder = document.createElement("div");
+ holder.id = "webSocketFlash";
+ container.appendChild(holder);
+ document.body.appendChild(container);
+ // See this article for hasPriority:
+ // http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c36cfb8137124318eebc6-7ffd.html
+ swfobject.embedSWF(
+ WEB_SOCKET_SWF_LOCATION,
+ "webSocketFlash",
+ "1" /* width */,
+ "1" /* height */,
+ "10.0.0" /* SWF version */,
+ null,
+ null,
+ {hasPriority: true, swliveconnect : true, allowScriptAccess: "always"},
+ null,
+ function(e) {
+ if (!e.success) {
+ console.error("[WebSocket] swfobject.embedSWF failed");
+ }
+ });
+ };
+
+ /**
+ * Called by Flash to notify JS that it's fully loaded and ready
+ * for communication.
+ */
+ WebSocket.__onFlashInitialized = function() {
+ // We need to set a timeout here to avoid round-trip calls
+ // to flash during the initialization process.
+ setTimeout(function() {
+ WebSocket.__flash = document.getElementById("webSocketFlash");
+ WebSocket.__flash.setCallerUrl(location.href);
+ WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);
+ for (var i = 0; i < WebSocket.__tasks.length; ++i) {
+ WebSocket.__tasks[i]();
+ }
+ WebSocket.__tasks = [];
+ }, 0);
+ };
+
+ /**
+ * Called by Flash to notify WebSockets events are fired.
+ */
+ WebSocket.__onFlashEvent = function() {
+ setTimeout(function() {
+ try {
+ // Gets events using receiveEvents() instead of getting it from event object
+ // of Flash event. This is to make sure to keep message order.
+ // It seems sometimes Flash events don't arrive in the same order as they are sent.
+ var events = WebSocket.__flash.receiveEvents();
+ for (var i = 0; i < events.length; ++i) {
+ WebSocket.__instances[events[i].webSocketId].__handleEvent(events[i]);
+ }
+ } catch (e) {
+ console.error(e);
+ }
+ }, 0);
+ return true;
+ };
+
+ // Called by Flash.
+ WebSocket.__log = function(message) {
+ console.log(decodeURIComponent(message));
+ };
+
+ // Called by Flash.
+ WebSocket.__error = function(message) {
+ console.error(decodeURIComponent(message));
+ };
+
+ WebSocket.__addTask = function(task) {
+ if (WebSocket.__flash) {
+ task();
+ } else {
+ WebSocket.__tasks.push(task);
+ }
+ };
+
+ /**
+ * Test if the browser is running flash lite.
+ * @return {boolean} True if flash lite is running, false otherwise.
+ */
+ WebSocket.__isFlashLite = function() {
+ if (!window.navigator || !window.navigator.mimeTypes) {
+ return false;
+ }
+ var mimeType = window.navigator.mimeTypes["application/x-shockwave-flash"];
+ if (!mimeType || !mimeType.enabledPlugin || !mimeType.enabledPlugin.filename) {
+ return false;
+ }
+ return mimeType.enabledPlugin.filename.match(/flashlite/i) ? true : false;
+ };
+
+ if (!window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION) {
+ if (window.addEventListener) {
+ window.addEventListener("load", function(){
+ WebSocket.__initialize();
+ }, false);
+ } else {
+ window.attachEvent("onload", function(){
+ WebSocket.__initialize();
+ });
+ }
+ }
+
+})();
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ *
+ * @api public
+ */
+
+ exports.XHR = XHR;
+
+ /**
+ * XHR constructor
+ *
+ * @costructor
+ * @api public
+ */
+
+ function XHR (socket) {
+ if (!socket) return;
+
+ io.Transport.apply(this, arguments);
+ this.sendBuffer = [];
+ };
+
+ /**
+ * Inherits from Transport.
+ */
+
+ io.util.inherit(XHR, io.Transport);
+
+ /**
+ * Establish a connection
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ XHR.prototype.open = function () {
+ this.socket.setBuffer(false);
+ this.onOpen();
+ this.get();
+
+ // we need to make sure the request succeeds since we have no indication
+ // whether the request opened or not until it succeeded.
+ this.setCloseTimeout();
+
+ return this;
+ };
+
+ /**
+ * Check if we need to send data to the Socket.IO server, if we have data in our
+ * buffer we encode it and forward it to the `post` method.
+ *
+ * @api private
+ */
+
+ XHR.prototype.payload = function (payload) {
+ var msgs = [];
+
+ for (var i = 0, l = payload.length; i < l; i++) {
+ msgs.push(io.parser.encodePacket(payload[i]));
+ }
+
+ this.send(io.parser.encodePayload(msgs));
+ };
+
+ /**
+ * Send data to the Socket.IO server.
+ *
+ * @param data The message
+ * @returns {Transport}
+ * @api public
+ */
+
+ XHR.prototype.send = function (data) {
+ this.post(data);
+ return this;
+ };
+
+ /**
+ * Posts a encoded message to the Socket.IO server.
+ *
+ * @param {String} data A encoded message.
+ * @api private
+ */
+
+ function empty () { };
+
+ XHR.prototype.post = function (data) {
+ var self = this;
+ this.socket.setBuffer(true);
+
+ function stateChange () {
+ if (this.readyState == 4) {
+ this.onreadystatechange = empty;
+ self.posting = false;
+
+ if (this.status == 200){
+ self.socket.setBuffer(false);
+ } else {
+ self.onClose();
+ }
+ }
+ }
+
+ function onload () {
+ this.onload = empty;
+ self.socket.setBuffer(false);
+ };
+
+ this.sendXHR = this.request('POST');
+
+ if (window.XDomainRequest && this.sendXHR instanceof XDomainRequest) {
+ this.sendXHR.onload = this.sendXHR.onerror = onload;
+ } else {
+ this.sendXHR.onreadystatechange = stateChange;
+ }
+
+ this.sendXHR.send(data);
+ };
+
+ /**
+ * Disconnects the established `XHR` connection.
+ *
+ * @returns {Transport}
+ * @api public
+ */
+
+ XHR.prototype.close = function () {
+ this.onClose();
+ return this;
+ };
+
+ /**
+ * Generates a configured XHR request
+ *
+ * @param {String} url The url that needs to be requested.
+ * @param {String} method The method the request should use.
+ * @returns {XMLHttpRequest}
+ * @api private
+ */
+
+ XHR.prototype.request = function (method) {
+ var req = io.util.request(this.socket.isXDomain());
+ req.open(method || 'GET', this.prepareUrl() + '?t' + (+ new Date));
+
+ if (method == 'POST') {
+ try {
+ if (req.setRequestHeader) {
+ req.setRequestHeader('Content-type', 'text/plain;charset=UTF-8');
+ } else {
+ // XDomainRequest
+ req.contentType = 'text/plain';
+ }
+ } catch (e) {}
+ }
+
+ return req;
+ };
+
+ /**
+ * Returns the scheme to use for the transport URLs.
+ *
+ * @api private
+ */
+
+ XHR.prototype.scheme = function () {
+ return this.socket.options.secure ? 'https' : 'http';
+ };
+
+ /**
+ * Check if the XHR transports are supported
+ *
+ * @param {Boolean} xdomain Check if we support cross domain requests.
+ * @returns {Boolean}
+ * @api public
+ */
+
+ XHR.check = function (socket, xdomain) {
+ try {
+ if (io.util.request(xdomain)) {
+ return true;
+ }
+ } catch(e) {}
+
+ return false;
+ };
+
+ /**
+ * Check if the XHR transport supports corss domain requests.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ XHR.xdomainCheck = function () {
+ return XHR.check(null, true);
+ };
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports.htmlfile = HTMLFile;
+
+ /**
+ * The HTMLFile transport creates a `forever iframe` based transport
+ * for Internet Explorer. Regular forever iframe implementations will
+ * continuously trigger the browsers buzy indicators. If the forever iframe
+ * is created inside a `htmlfile` these indicators will not be trigged.
+ *
+ * @constructor
+ * @extends {io.Transport.XHR}
+ * @api public
+ */
+
+ function HTMLFile (socket) {
+ io.Transport.XHR.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from XHR transport.
+ */
+
+ io.util.inherit(HTMLFile, io.Transport.XHR);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ HTMLFile.prototype.name = 'htmlfile';
+
+ /**
+ * Creates a new ActiveX `htmlfile` with a forever loading iframe
+ * that can be used to listen to messages. Inside the generated
+ * `htmlfile` a reference will be made to the HTMLFile transport.
+ *
+ * @api private
+ */
+
+ HTMLFile.prototype.get = function () {
+ this.doc = new ActiveXObject('htmlfile');
+ this.doc.open();
+ this.doc.write('<html></html>');
+ this.doc.close();
+ this.doc.parentWindow.s = this;
+
+ var iframeC = this.doc.createElement('div');
+ iframeC.className = 'socketio';
+
+ this.doc.body.appendChild(iframeC);
+ this.iframe = this.doc.createElement('iframe');
+
+ iframeC.appendChild(this.iframe);
+
+ this.iframe.src = this.prepareUrl() + '/?t=' + (+ new Date);
+
+ var self = this;
+
+ io.util.on(window, 'unload', function () {
+ self.destroy();
+ });
+ };
+
+ /**
+ * The Socket.IO server will write script tags inside the forever
+ * iframe, this function will be used as callback for the incoming
+ * information.
+ *
+ * @param {String} data The message
+ * @param {document} doc Reference to the context
+ * @api private
+ */
+
+ HTMLFile.prototype._ = function (data, doc) {
+ this.onData(data);
+ try {
+ var script = doc.getElementsByTagName('script')[0];
+ script.parentNode.removeChild(script);
+ } catch (e) { }
+ };
+
+ /**
+ * Destroy the established connection, iframe and `htmlfile`.
+ * And calls the `CollectGarbage` function of Internet Explorer
+ * to release the memory.
+ *
+ * @api private
+ */
+
+ HTMLFile.prototype.destroy = function () {
+ if (this.iframe){
+ try {
+ this.iframe.src = 'about:blank';
+ } catch(e){}
+
+ this.doc = null;
+ this.iframe.parentNode.removeChild(this.iframe);
+ this.iframe = null;
+
+ CollectGarbage();
+ }
+ };
+
+ /**
+ * Disconnects the established connection.
+ *
+ * @returns {Transport} Chaining.
+ * @api public
+ */
+
+ HTMLFile.prototype.close = function () {
+ this.destroy();
+ return io.Transport.XHR.prototype.close.call(this);
+ };
+
+ /**
+ * Checks if the browser supports this transport. The browser
+ * must have an `ActiveXObject` implementation.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+ HTMLFile.check = function () {
+ if ('ActiveXObject' in window){
+ try {
+ var a = new ActiveXObject('htmlfile');
+ return a && io.Transport.XHR.check();
+ } catch(e){}
+ }
+ return false;
+ };
+
+ /**
+ * Check if cross domain requests are supported.
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ HTMLFile.xdomainCheck = function () {
+ // we can probably do handling for sub-domains, we should
+ // test that it's cross domain but a subdomain here
+ return false;
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('htmlfile');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports['xhr-polling'] = XHRPolling;
+
+ /**
+ * The XHR-polling transport uses long polling XHR requests to create a
+ * "persistent" connection with the server.
+ *
+ * @constructor
+ * @api public
+ */
+
+ function XHRPolling () {
+ io.Transport.XHR.apply(this, arguments);
+ };
+
+ /**
+ * Inherits from XHR transport.
+ */
+
+ io.util.inherit(XHRPolling, io.Transport.XHR);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ XHRPolling.prototype.name = 'xhr-polling';
+
+ /**
+ * Establish a connection, for iPhone and Android this will be done once the page
+ * is loaded.
+ *
+ * @returns {Transport} Chaining.
+ * @api public
+ */
+
+ XHRPolling.prototype.open = function () {
+ var self = this;
+
+ io.util.defer(function () {
+ io.Transport.XHR.prototype.open.call(self);
+ });
+
+ return false;
+ };
+
+ /**
+ * Starts a XHR request to wait for incoming messages.
+ *
+ * @api private
+ */
+
+ function empty () {};
+
+ XHRPolling.prototype.get = function () {
+ if (!this.open) return;
+
+ var self = this;
+
+ function stateChange () {
+ if (this.readyState == 4) {
+ this.onreadystatechange = empty;
+
+ if (this.status == 200) {
+ self.onData(this.responseText);
+ self.get();
+ } else {
+ self.onClose();
+ }
+ }
+ };
+
+ function onload () {
+ this.onload = empty;
+ self.onData(this.responseText);
+ self.get();
+ };
+
+ this.xhr = this.request();
+
+ if (window.XDomainRequest && this.xhr instanceof XDomainRequest) {
+ this.xhr.onload = this.xhr.onerror = onload;
+ } else {
+ this.xhr.onreadystatechange = stateChange;
+ }
+
+ this.xhr.send(null);
+ };
+
+ /**
+ * Handle the unclean close behavior.
+ *
+ * @api private
+ */
+
+ XHRPolling.prototype.onClose = function () {
+ io.Transport.XHR.prototype.onClose.call(this);
+
+ if (this.xhr) {
+ this.xhr.onreadystatechange = this.xhr.onload = empty;
+ try {
+ this.xhr.abort();
+ } catch(e){}
+ this.xhr = null;
+ }
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('xhr-polling');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
+
+/**
+ * socket.io
+ * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
+ * MIT Licensed
+ */
+
+(function (exports, io) {
+
+ /**
+ * Expose constructor.
+ */
+
+ exports['jsonp-polling'] = JSONPPolling;
+
+ /**
+ * The JSONP transport creates an persistent connection by dynamically
+ * inserting a script tag in the page. This script tag will receive the
+ * information of the Socket.IO server. When new information is received
+ * it creates a new script tag for the new data stream.
+ *
+ * @constructor
+ * @extends {io.Transport.xhr-polling}
+ * @api public
+ */
+
+ function JSONPPolling (socket) {
+ io.Transport['xhr-polling'].apply(this, arguments);
+
+ this.index = io.j.length;
+
+ var self = this;
+
+ io.j.push(function (msg) {
+ self._(msg);
+ });
+ };
+
+ /**
+ * Inherits from XHR polling transport.
+ */
+
+ io.util.inherit(JSONPPolling, io.Transport['xhr-polling']);
+
+ /**
+ * Transport name
+ *
+ * @api public
+ */
+
+ JSONPPolling.prototype.name = 'jsonp-polling';
+
+ /**
+ * Posts a encoded message to the Socket.IO server using an iframe.
+ * The iframe is used because script tags can create POST based requests.
+ * The iframe is positioned outside of the view so the user does not
+ * notice it's existence.
+ *
+ * @param {String} data A encoded message.
+ * @api private
+ */
+
+ JSONPPolling.prototype.post = function (data) {
+ var self = this;
+
+ if (!this.form) {
+ var form = document.createElement('FORM')
+ , area = document.createElement('TEXTAREA')
+ , id = this.iframeId = 'socketio_iframe_' + this.index
+ , iframe;
+
+ form.className = 'socketio';
+ form.style.position = 'absolute';
+ form.style.top = '-1000px';
+ form.style.left = '-1000px';
+ form.target = id;
+ form.method = 'POST';
+ area.name = 'd';
+ form.appendChild(area);
+ document.body.appendChild(form);
+
+ this.form = form;
+ this.area = area;
+ }
+
+ this.form.action = this.prepareUrl() + '?t=' + (+new Date) + '&i=' + this.index;
+
+ function complete () {
+ initIframe();
+ self.socket.setBuffer(false);
+ };
+
+ function initIframe () {
+ if (self.iframe) {
+ self.form.removeChild(self.iframe);
+ }
+
+ try {
+ // ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
+ iframe = document.createElement('<iframe name="'+ self.iframeId +'">');
+ } catch (e) {
+ iframe = document.createElement('iframe');
+ iframe.name = self.iframeId;
+ }
+
+ iframe.id = self.iframeId;
+
+ self.form.appendChild(iframe);
+ self.iframe = iframe;
+ };
+
+ initIframe();
+
+ this.area.value = data;
+
+ try {
+ this.form.submit();
+ } catch(e) {}
+
+ if (this.iframe.attachEvent) {
+ iframe.onreadystatechange = function () {
+ if (self.iframe.readyState == 'complete') {
+ complete();
+ }
+ };
+ } else {
+ this.iframe.onload = complete;
+ }
+ };
+
+ /**
+ * Creates a new JSONP poll that can be used to listen
+ * for messages from the Socket.IO server.
+ *
+ * @api private
+ */
+
+ JSONPPolling.prototype.get = function () {
+ var self = this
+ , script = document.createElement('SCRIPT');
+
+ if (this.script) {
+ this.script.parentNode.removeChild(this.script);
+ this.script = null;
+ }
+
+ script.async = true;
+ script.src = this.prepareUrl() + '/?t=' + (+new Date) + '&i=' + this.index;
+ script.onerror = function () {
+ self.onClose();
+ };
+
+ var insertAt = document.getElementsByTagName('script')[0]
+ insertAt.parentNode.insertBefore(script, insertAt);
+ this.script = script;
+ };
+
+ /**
+ * Callback function for the incoming message stream from the Socket.IO server.
+ *
+ * @param {String} data The message
+ * @api private
+ */
+
+ JSONPPolling.prototype._ = function (msg) {
+ this.onData(msg);
+ if (this.open) {
+ this.get();
+ }
+ return this;
+ };
+
+ /**
+ * Checks if browser supports this transport.
+ *
+ * @return {Boolean}
+ * @api public
+ */
+
+ JSONPPolling.check = function () {
+ return true;
+ };
+
+ /**
+ * Check if cross domain requests are supported
+ *
+ * @returns {Boolean}
+ * @api public
+ */
+
+ JSONPPolling.xdomainCheck = function () {
+ return true;
+ };
+
+ /**
+ * Add the transport to your public io.transports array.
+ *
+ * @api private
+ */
+
+ io.transports.push('jsonp-polling');
+
+})(
+ 'undefined' != typeof io ? io.Transport : module.exports
+ , 'undefined' != typeof io ? io : module.parent.exports
+);
--- /dev/null
+/*! Socket.IO.min.js build:0.7.4, production. Copyright(c) 2011 LearnBoost <dev@learnboost.com> MIT Licensed */
+(function(a){var b=a;b.version="0.7.4",b.protocol=1,b.transports=[],b.j=[],b.sockets={},b.connect=function(a,c){var d=b.util.parseUri(a),e,f;"undefined"!=typeof document&&(d.protocol=d.protocol||document.location.protocol.slice(0,-1),d.host=d.host||document.domain,d.port=d.port||document.location.port),e=b.util.uniqueUri(d);var g={host:d.host,secure:d.protocol=="https",port:d.port||80};b.util.merge(g,c);if(g["force new connection"]||!b.sockets[e])f=new b.Socket(g);!g["force new connection"]&&f&&(b.sockets[e]=f),f=f||b.sockets[e];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||(b=="https"&&document.location.protocol!=="https:"?443:document.location.port)):(c=c||"localhost",!d&&b=="https"&&(d=443));return(b||"http")+"://"+c+":"+(d||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)},b.request=function(a){if("undefined"!=typeof window){if(a&&window.XDomainRequest)return new XDomainRequest;if(window.XMLHttpRequest&&(!a||b.ua.hasCORS))return new XMLHttpRequest;if(!a)try{return new window.ActiveXObject("Microsoft.XMLHTTP")}catch(c){}}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 f(c,d,e,f){var g=f||[],h=typeof e=="undefined"?2:e,i;for(i in d)d.hasOwnProperty(i)&&b.indexOf(g,i)<0&&(typeof c[i]!="object"||!h?(c[i]=d[i],g.push(d[i])):b.merge(c[i],d[i],h-1,g));return c},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.toArray=function(a){var b=[];for(var c=0,d=a.length;c<d;c++)b.push(a[c]);return b},b.ua={},b.ua.hasCORS="undefined"!=typeof window&&window.XMLHttpRequest&&function(){try{var a=new XMLHttpRequest}catch(b){return!1}return a.withCredentials!=undefined}(),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){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,typeof JSON!="undefined"?JSON:undefined),function(a,b){var c=a.parser={},d=c.packets=["disconnect","connect","heartbeat","message","json","event","ack","error","noop"],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=h(d,a.type),c=a.id||"",i=a.endpoint||"",j=a.ack,k=null;switch(a.type){case"error":var l=a.reason?h(e,a.reason):"",m=a.advice?h(f,a.advice):"";if(l!==""||m!=="")k=l+(m!==""?"+"+m:"");break;case"message":a.data!==""&&(k=a.data);break;case"event":var n={name:a.name};a.args&&a.args.length&&(n.args=a.args),k=g.stringify(n);break;case"json":k=g.stringify(a.data);break;case"connect":a.qs&&(k=a.qs);break;case"ack":k=a.ackId+(a.args&&a.args.length?"+"+g.stringify(a.args):"")}var o=[b,c+(j=="data"?"+":""),i];k!==null&&k!==undefined&&o.push(k);return o.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+="�"+e.length+"�"+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":try{var j=g.parse(a);h.name=j.name,h.args=j.args}catch(k){}h.args=h.args||[];break;case"json":try{h.data=g.parse(a)}catch(k){}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(k){}}break;case"disconnect":case"heartbeat":}return h},c.decodePayload=function(a){if(a.charAt(0)=="�"){var b=[];for(var d=1,e="";d<a.length;d++)a.charAt(d)=="�"?(b.push(c.decodePacket(a.substr(d+1).substr(0,e))),d+=Number(e)+1,e=""):e+=a.charAt(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(),this.setCloseTimeout();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();a.type=="connect"&&a.endpoint==""&&this.onConnect(),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.onConnect=function(){this.socket.onConnect();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.open=!0,this.clearCloseTimeout(),this.socket.onOpen()},c.prototype.onClose=function(){var a=this;this.open=!1,this.setCloseTimeout(),this.socket.onClose()},c.prototype.prepareUrl=function(){var a=this.socket.options;return this.scheme()+"://"+a.host+":"+a.port+"/"+a.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,this.namespaces={},this.buffer=[],this.doBuffer=!1;if(this.options["sync disconnect on unload"]&&(!this.isXDomain()||b.util.ua.hasCORS)){var c=this;b.util.on(window,"beforeunload",function(){c.disconnectSync()},!1)}this.options["auto connect"]&&this.connect()}a.Socket=c,b.util.mixin(c,b.EventEmitter),c.prototype.of=function(a){this.namespaces[a]||(this.namespaces[a]=new b.SocketNamespace(this,a),a!==""&&this.namespaces[a].packet({type:"connect"}));return this.namespaces[a]},c.prototype.publish=function(){this.emit.apply(this,arguments);var a;for(var b in this.namespaces)this.namespaces.hasOwnProperty(b)&&(a=this.of(b),a.$emit.apply(a,arguments))},c.prototype.handshake=function(a){function f(b){b instanceof Error?c.onError(b.message):a.apply(null,b.split(":"))}var c=this,e=this.options,g=["http"+(e.secure?"s":"")+":/",e.host+":"+e.port,this.options.resource,b.protocol,"?t="+ +(new Date)].join("/");if(this.isXDomain()){var h=document.getElementsByTagName("script")[0],i=document.createElement("SCRIPT");i.src=g+"&jsonp="+b.j.length,h.parentNode.insertBefore(i,h),b.j.push(function(a){f(a),i.parentNode.removeChild(i)})}else{var j=b.util.request();j.open("GET",g),j.onreadystatechange=function(){j.readyState==4&&(j.onreadystatechange=d,j.status==200?f(j.responseText):!c.reconnecting&&c.onError(j.responseText))},j.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)&&(!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){function h(a){c.transport=c.getTransport(a);if(!c.transport)return c.publish("connect_failed");c.connecting=!0,c.publish("connecting",c.transport.name),c.transport.open(),c.options["connect timeout"]&&(c.connectTimeoutTimer=setTimeout(function(){if(!c.connected){c.connecting=!1;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?h(a):c.publish("connect_failed")}}},c.options["connect timeout"]))}c.sessionid=d,c.closeTimeout=f*1e3,c.heartbeatTimeout=e*1e3,c.transports=b.util.intersect(g.split(","),c.options.transports),h(),c.once("connect",function(){clearTimeout(c.connectTimeoutTimer),a&&typeof a=="function"&&a()})});return this},c.prototype.packet=function(a){this.connected&&!this.doBuffer?this.transport.packet(a):this.buffer.push(a);return this},c.prototype.setBuffer=function(a){this.doBuffer=a,!a&&this.connected&&this.buffer.length&&(this.transport.payload(this.buffer),this.buffer=[])},c.prototype.disconnect=function(){this.connected&&(this.open&&this.of("").packet({type:"disconnect"}),this.onDisconnect("booted"));return this},c.prototype.disconnectSync=function(){var a=b.util.request(),c=this.resource+"/"+b.protocol+"/"+this.sessionid;a.open("GET",c,!0),this.onDisconnect("booted")},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.doBuffer||this.setBuffer(!1),this.emit("connect")},c.prototype.onOpen=function(){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){a&&a.advice&&a.advice==="reconnect"&&this.connected&&(this.disconnect(),this.reconnect()),this.publish("error",a&&a.reason?a.reason:a)},c.prototype.onDisconnect=function(a){var b=this.connected;this.connected=!1,this.connecting=!1,this.open=!1,b&&(this.transport.close(),this.transport.clearTimeouts(),this.publish("disconnect",a),"booted"!=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.publish("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.publish("reconnecting",a.reconnectionDelay,a.reconnectionAttempts),a.reconnectionTimer=setTimeout(e,a.reconnectionDelay))}}function d(){a.connected&&a.publish("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,b){this.socket=a,this.name=b||"",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.of=function(){return this.socket.of.apply(this.socket,arguments)},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=!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="data",this.acks[d.id]=c,b=b.slice(0,b.length-1)),d.args=b;return this.packet(d)},c.prototype.disconnect=function(){this.name===""?this.socket.disconnect():(this.packet({type:"disconnect"}),this.$emit("disconnect"));return this},c.prototype.onPacket=function(a){function d(){c.packet({type:"ack",args:b.util.toArray(arguments),ackId:a.id})}var c=this;switch(a.type){case"connect":this.$emit("connect");break;case"disconnect":this.name===""?this.socket.onDisconnect(a.reason||"booted"):this.$emit("disconnect",a.reason);break;case"message":case"json":var e=["message",a.data];a.ack=="data"?e.push(d):a.ack&&this.packet({type:"ack",ackId:a.id}),this.$emit.apply(this,e);break;case"event":var e=[a.name].concat(a.args);a.ack=="data"&&e.push(d),this.$emit.apply(this,e);break;case"ack":this.acks[a.ackId]&&(this.acks[a.ackId].apply(this,a.args),delete this.acks[a.ackId]);break;case"error":a.advice?this.socket.onError(a):a.reason=="unauthorized"?this.$emit("connect_failed",a.reason):this.$emit("error",a.reason)}},d.prototype.send=function(){this.namespace.flags[this.name]=!0,this.namespace.send.apply(this.namespace,arguments)},d.prototype.emit=function(){this.namespace.flags[this.name]=!0,this.namespace.emit.apply(this.namespace,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)}a.websocket=c,b.util.inherit(c,b.Transport),c.prototype.name="websocket",c.prototype.open=function(){this.websocket=new WebSocket(this.prepareUrl());var a=this;this.websocket.onopen=function(){a.onOpen(),a.socket.setBuffer(!1)},this.websocket.onmessage=function(b){a.onData(b.data)},this.websocket.onclose=function(){a.onClose(),a.socket.setBuffer(!0)},this.websocket.onerror=function(b){a.onError(b)};return this},c.prototype.send=function(a){this.websocket.send(a);return this},c.prototype.payload=function(a){for(var b=0,c=a.length;b<c;b++)this.packet(a[b]);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.check=function(){return"WebSocket"in window&&!("__addTask"in WebSocket)},c.xdomainCheck=function(){return!0},b.transports.push("websocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(){b.Transport.websocket.apply(this,arguments)}a.flashsocket=c,b.util.inherit(c,b.Transport.websocket),c.prototype.name="flashsocket",c.prototype.open=function(){var a=this,c=arguments;WebSocket.__addTask(function(){b.Transport.websocket.prototype.open.apply(a,c)});return this},c.prototype.send=function(){var a=this,c=arguments;WebSocket.__addTask(function(){b.Transport.websocket.prototype.send.apply(a,c)});return this},c.prototype.close=function(){WebSocket.__tasks.length=0,b.Transport.websocket.prototype.close.call(this);return this},c.check=function(a){if(typeof WebSocket=="undefined"||!("__initialize"in WebSocket)||!swfobject)return!1;var b=swfobject.getFlashPlayerVersion().major>=10,d=a.options,e=["http"+(d.secure?"s":"")+":/",d.host+":"+d.port,d.resource,"static/flashsocket","WebSocketMain"+(a.isXDomain()?"Insecure":"")+".swf"];b&&!c.loaded&&(typeof WEB_SOCKET_SWF_LOCATION=="undefined"&&(WEB_SOCKET_SWF_LOCATION=e.join("/")),WebSocket.__initialize(),c.loaded=!0);return b},c.xdomainCheck=function(){return!0},typeof window!="undefined"&&(WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0),b.transports.push("flashsocket")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports);var swfobject=function(){function V(b){var c=/[\\\"<>\.;]/,d=c.exec(b)!=null;return d&&typeof encodeURIComponent!=a?encodeURIComponent(b):b}function U(a,b){if(!!x){var c=b?"visible":"hidden";t&&P(a)?P(a).style.visibility=c:T("#"+a,"visibility:"+c)}}function T(c,d,e,f){if(!y.ie||!y.mac){var g=i.getElementsByTagName("head")[0];if(!g)return;var h=e&&typeof e=="string"?e:"screen";f&&(v=null,w=null);if(!v||w!=h){var j=Q("style");j.setAttribute("type","text/css"),j.setAttribute("media",h),v=g.appendChild(j),y.ie&&y.win&&typeof i.styleSheets!=a&&i.styleSheets.length>0&&(v=i.styleSheets[i.styleSheets.length-1]),w=h}y.ie&&y.win?v&&typeof v.addRule==b&&v.addRule(c,d):v&&typeof i.createTextNode!=a&&v.appendChild(i.createTextNode(c+" {"+d+"}"))}}function S(a){var b=y.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]?!0:!1}function R(a,b,c){a.attachEvent(b,c),o[o.length]=[a,b,c]}function Q(a){return i.createElement(a)}function P(a){var b=null;try{b=i.getElementById(a)}catch(c){}return b}function O(a){var b=P(a);if(b){for(var c in b)typeof b[c]=="function"&&(b[c]=null);b.parentNode.removeChild(b)}}function N(a){var b=P(a);b&&b.nodeName=="OBJECT"&&(y.ie&&y.win?(b.style.display="none",function(){b.readyState==4?O(a):setTimeout(arguments.callee,10)}()):b.parentNode.removeChild(b))}function M(a,b,c){var d=Q("param");d.setAttribute("name",b),d.setAttribute("value",c),a.appendChild(d)}function L(c,d,f){var g,h=P(f);if(y.wk&&y.wk<312)return g;if(h){typeof c.id==a&&(c.id=f);if(y.ie&&y.win){var i="";for(var j in c)c[j]!=Object.prototype[j]&&(j.toLowerCase()=="data"?d.movie=c[j]:j.toLowerCase()=="styleclass"?i+=' class="'+c[j]+'"':j.toLowerCase()!="classid"&&(i+=" "+j+'="'+c[j]+'"'));var k="";for(var l in d)d[l]!=Object.prototype[l]&&(k+='<param name="'+l+'" value="'+d[l]+'" />');h.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+i+">"+k+"</object>",n[n.length]=c.id,g=P(c.id)}else{var m=Q(b);m.setAttribute("type",e);for(var o in c)c[o]!=Object.prototype[o]&&(o.toLowerCase()=="styleclass"?m.setAttribute("class",c[o]):o.toLowerCase()!="classid"&&m.setAttribute(o,c[o]));for(var p in d)d[p]!=Object.prototype[p]&&p.toLowerCase()!="movie"&&M(m,p,d[p]);h.parentNode.replaceChild(m,h),g=m}}return g}function K(a){var c=Q("div");if(y.win&&y.ie)c.innerHTML=a.innerHTML;else{var d=a.getElementsByTagName(b)[0];if(d){var e=d.childNodes;if(e){var f=e.length;for(var g=0;g<f;g++)(e[g].nodeType!=1||e[g].nodeName!="PARAM")&&e[g].nodeType!=8&&c.appendChild(e[g].cloneNode(!0))}}}return c}function J(a){if(y.ie&&y.win&&a.readyState!=4){var b=Q("div");a.parentNode.insertBefore(b,a),b.parentNode.replaceChild(K(a),b),a.style.display="none",function(){a.readyState==4?a.parentNode.removeChild(a):setTimeout(arguments.callee,10)}()}else a.parentNode.replaceChild(K(a),a)}function I(b,c,d,e){u=!0,r=e||null,s={success:!1,id:d};var g=P(d);if(g){g.nodeName=="OBJECT"?(p=K(g),q=null):(p=g,q=d),b.id=f;if(typeof b.width==a||!/%$/.test(b.width)&&parseInt(b.width,10)<310)b.width="310";if(typeof b.height==a||!/%$/.test(b.height)&&parseInt(b.height,10)<137)b.height="137";i.title=i.title.slice(0,47)+" - Flash Player Installation";var j=y.ie&&y.win?"ActiveX":"PlugIn",k="MMredirectURL="+h.location.toString().replace(/&/g,"%26")+"&MMplayerType="+j+"&MMdoctitle="+i.title;typeof c.flashvars!=a?c.flashvars+="&"+k:c.flashvars=k;if(y.ie&&y.win&&g.readyState!=4){var l=Q("div");d+="SWFObjectNew",l.setAttribute("id",d),g.parentNode.insertBefore(l,g),g.style.display="none",function(){g.readyState==4?g.parentNode.removeChild(g):setTimeout(arguments.callee,10)}()}L(b,c,d)}}function H(){return!u&&S("6.0.65")&&(y.win||y.mac)&&!(y.wk&&y.wk<312)}function G(c){var d=null,e=P(c);if(e&&e.nodeName=="OBJECT")if(typeof e.SetVariable!=a)d=e;else{var f=e.getElementsByTagName(b)[0];f&&(d=f)}return d}function F(){var b=m.length;if(b>0)for(var c=0;c<b;c++){var d=m[c].id,e=m[c].callbackFn,f={success:!1,id:d};if(y.pv[0]>0){var g=P(d);if(g)if(S(m[c].swfVersion)&&!(y.wk&&y.wk<312))U(d,!0),e&&(f.success=!0,f.ref=G(d),e(f));else if(m[c].expressInstall&&H()){var h={};h.data=m[c].expressInstall,h.width=g.getAttribute("width")||"0",h.height=g.getAttribute("height")||"0",g.getAttribute("class")&&(h.styleclass=g.getAttribute("class")),g.getAttribute("align")&&(h.align=g.getAttribute("align"));var i={},j=g.getElementsByTagName("param"),k=j.length;for(var l=0;l<k;l++)j[l].getAttribute("name").toLowerCase()!="movie"&&(i[j[l].getAttribute("name")]=j[l].getAttribute("value"));I(h,i,d,e)}else J(g),e&&e(f)}else{U(d,!0);if(e){var n=G(d);n&&typeof n.SetVariable!=a&&(f.success=!0,f.ref=n),e(f)}}}}function E(){var c=i.getElementsByTagName("body")[0],d=Q(b);d.setAttribute("type",e);var f=c.appendChild(d);if(f){var g=0;(function(){if(typeof f.GetVariable!=a){var b=f.GetVariable("$version");b&&(b=b.split(" ")[1].split(","),y.pv=[parseInt(b[0],10),parseInt(b[1],10),parseInt(b[2],10)])}else if(g<10){g++,setTimeout(arguments.callee,10);return}c.removeChild(d),f=null,F()})()}else F()}function D(){k?E():F()}function C(b){if(typeof h.addEventListener!=a)h.addEventListener("load",b,!1);else if(typeof i.addEventListener!=a)i.addEventListener("load",b,!1);else if(typeof h.attachEvent!=a)R(h,"onload",b);else if(typeof h.onload=="function"){var c=h.onload;h.onload=function(){c(),b()}}else h.onload=b}function B(a){t?a():l[l.length]=a}function A(){if(!t){try{var a=i.getElementsByTagName("body")[0].appendChild(Q("span"));a.parentNode.removeChild(a)}catch(b){return}t=!0;var c=l.length;for(var d=0;d<c;d++)l[d]()}}var a="undefined",b="object",c="Shockwave Flash",d="ShockwaveFlash.ShockwaveFlash",e="application/x-shockwave-flash",f="SWFObjectExprInst",g="onreadystatechange",h=window,i=document,j=navigator,k=!1,l=[D],m=[],n=[],o=[],p,q,r,s,t=!1,u=!1,v,w,x=!0,y=function(){var f=typeof i.getElementById!=a&&typeof i.getElementsByTagName!=a&&typeof i.createElement!=a,g=j.userAgent.toLowerCase(),l=j.platform.toLowerCase(),m=l?/win/.test(l):/win/.test(g),n=l?/mac/.test(l):/mac/.test(g),o=/webkit/.test(g)?parseFloat(g.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):!1,p=!1,q=[0,0,0],r=null;if(typeof j.plugins!=a&&typeof j.plugins[c]==b)r=j.plugins[c].description,r&&(typeof j.mimeTypes==a||!j.mimeTypes[e]||!!j.mimeTypes[e].enabledPlugin)&&(k=!0,p=!1,r=r.replace(/^.*\s+(\S+\s+\S+$)/,"$1"),q[0]=parseInt(r.replace(/^(.*)\..*$/,"$1"),10),q[1]=parseInt(r.replace(/^.*\.(.*)\s.*$/,"$1"),10),q[2]=/[a-zA-Z]/.test(r)?parseInt(r.replace(/^.*[a-zA-Z]+(.*)$/,"$1"),10):0);else if(typeof h.ActiveXObject!=a)try{var s=new ActiveXObject(d);s&&(r=s.GetVariable("$version"),r&&(p=!0,r=r.split(" ")[1].split(","),q=[parseInt(r[0],10),parseInt(r[1],10),parseInt(r[2],10)]))}catch(t){}return{w3:f,pv:q,wk:o,ie:p,win:m,mac:n}}(),z=function(){!y.w3||((typeof i.readyState!=a&&i.readyState=="complete"||typeof i.readyState==a&&(i.getElementsByTagName("body")[0]||i.body))&&A(),t||(typeof i.addEventListener!=a&&i.addEventListener("DOMContentLoaded",A,!1),y.ie&&y.win&&(i.attachEvent(g,function(){i.readyState=="complete"&&(i.detachEvent(g,arguments.callee),A())}),h==top&&function(){if(!t){try{i.documentElement.doScroll("left")}catch(a){setTimeout(arguments.callee,0);return}A()}}()),y.wk&&function(){if(!t){if(!/loaded|complete/.test(i.readyState)){setTimeout(arguments.callee,0);return}A()}}(),C(A)))}(),W=function(){y.ie&&y.win&&window.attachEvent("onunload",function(){var a=o.length;for(var b=0;b<a;b++)o[b][0].detachEvent(o[b][1],o[b][2]);var c=n.length;for(var d=0;d<c;d++)N(n[d]);for(var e in y)y[e]=null;y=null;for(var f in swfobject)swfobject[f]=null;swfobject=null})}();return{registerObject:function(a,b,c,d){if(y.w3&&a&&b){var e={};e.id=a,e.swfVersion=b,e.expressInstall=c,e.callbackFn=d,m[m.length]=e,U(a,!1)}else d&&d({success:!1,id:a})},getObjectById:function(a){if(y.w3)return G(a)},embedSWF:function(c,d,e,f,g,h,i,j,k,l){var m={success:!1,id:d};y.w3&&!(y.wk&&y.wk<312)&&c&&d&&e&&f&&g?(U(d,!1),B(function(){e+="",f+="";var n={};if(k&&typeof k===b)for(var o in k)n[o]=k[o];n.data=c,n.width=e,n.height=f;var p={};if(j&&typeof j===b)for(var q in j)p[q]=j[q];if(i&&typeof i===b)for(var r in i)typeof p.flashvars!=a?p.flashvars+="&"+r+"="+i[r]:p.flashvars=r+"="+i[r];if(S(g)){var s=L(n,p,d);n.id==d&&U(d,!0),m.success=!0,m.ref=s}else{if(h&&H()){n.data=h,I(n,p,d,l);return}U(d,!0)}l&&l(m)})):l&&l(m)},switchOffAutoHideShow:function(){x=!1},ua:y,getFlashPlayerVersion:function(){return{major:y.pv[0],minor:y.pv[1],release:y.pv[2]}},hasFlashPlayerVersion:S,createSWF:function(a,b,c){return y.w3?L(a,b,c):undefined},showExpressInstall:function(a,b,c,d){y.w3&&H()&&I(a,b,c,d)},removeSWF:function(a){y.w3&&N(a)},createCSS:function(a,b,c,d){y.w3&&T(a,b,c,d)},addDomLoadEvent:B,addLoadEvent:C,getQueryParamValue:function(a){var b=i.location.search||i.location.hash;if(b){/\?/.test(b)&&(b=b.split("?")[1]);if(a==null)return V(b);var c=b.split("&");for(var d=0;d<c.length;d++)if(c[d].substring(0,c[d].indexOf("="))==a)return V(c[d].substring(c[d].indexOf("=")+1))}return""},expressInstallCallback:function(){if(u){var a=P(f);a&&p&&(a.parentNode.replaceChild(p,a),q&&(U(q,!0),y.ie&&y.win&&(p.style.display="block")),r&&r(s)),u=!1}}}}();(function(){if(!window.WebSocket){var a=window.console;if(!a||!a.log||!a.error)a={log:function(){},error:function(){}};if(!swfobject.hasFlashPlayerVersion("10.0.0")){a.error("Flash Player >= 10.0.0 is required.");return}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(a,b,c,d,e){var f=this;f.__id=WebSocket.__nextId++,WebSocket.__instances[f.__id]=f,f.readyState=WebSocket.CONNECTING,f.bufferedAmount=0,f.__events={},b?typeof b=="string"&&(b=[b]):b=[],setTimeout(function(){WebSocket.__addTask(function(){WebSocket.__flash.create(f.__id,a,b,c||null,d||0,e||null)})},0)},WebSocket.prototype.send=function(a){if(this.readyState==WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";var b=WebSocket.__flash.send(this.__id,encodeURIComponent(a));if(b<0)return!0;this.bufferedAmount+=b;return!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(a,b,c){a in this.__events||(this.__events[a]=[]),this.__events[a].push(b)},WebSocket.prototype.removeEventListener=function(a,b,c){if(a in this.__events){var d=this.__events[a];for(var e=d.length-1;e>=0;--e)if(d[e]===b){d.splice(e,1);break}}},WebSocket.prototype.dispatchEvent=function(a){var b=this.__events[a.type]||[];for(var c=0;c<b.length;++c)b[c](a);var d=this["on"+a.type];d&&d(a)},WebSocket.prototype.__handleEvent=function(a){"readyState"in a&&(this.readyState=a.readyState),"protocol"in a&&(this.protocol=a.protocol);var b;if(a.type=="open"||a.type=="error")b=this.__createSimpleEvent(a.type);else if(a.type=="close")b=this.__createSimpleEvent("close");else{if(a.type!="message")throw"unknown event type: "+a.type;var c=decodeURIComponent(a.message);b=this.__createMessageEvent("message",c)}this.dispatchEvent(b)},WebSocket.prototype.__createSimpleEvent=function(a){if(document.createEvent&&window.Event){var b=document.createEvent("Event");b.initEvent(a,!1,!1);return b}return{type:a,bubbles:!1,cancelable:!1}},WebSocket.prototype.__createMessageEvent=function(a,b){if(document.createEvent&&window.MessageEvent&&!window.opera){var c=document.createEvent("MessageEvent");c.initMessageEvent("message",!1,!1,b,null,null,window,null);return c}return{type:a,data:b,bubbles:!1,cancelable:!1}},WebSocket.CONNECTING=0,WebSocket.OPEN=1,WebSocket.CLOSING=2,WebSocket.CLOSED=3,WebSocket.__flash=null,WebSocket.__instances={},WebSocket.__tasks=[],WebSocket.__nextId=0,WebSocket.loadFlashPolicyFile=function(a){WebSocket.__addTask(function(){WebSocket.__flash.loadManualPolicyFile(a)})},WebSocket.__initialize=function(){if(!WebSocket.__flash){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 b=document.createElement("div");b.id="webSocketContainer",b.style.position="absolute",WebSocket.__isFlashLite()?(b.style.left="0px",b.style.top="0px"):(b.style.left="-100px",b.style.top="-100px");var c=document.createElement("div");c.id="webSocketFlash",b.appendChild(c),document.body.appendChild(b),swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION,"webSocketFlash","1","1","10.0.0",null,null,{hasPriority:!0,swliveconnect:!0,allowScriptAccess:"always"},null,function(b){b.success||a.error("[WebSocket] swfobject.embedSWF failed")})}},WebSocket.__onFlashInitialized=function(){setTimeout(function(){WebSocket.__flash=document.getElementById("webSocketFlash"),WebSocket.__flash.setCallerUrl(location.href),WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);for(var a=0;a<WebSocket.__tasks.length;++a)WebSocket.__tasks[a]();WebSocket.__tasks=[]},0)},WebSocket.__onFlashEvent=function(){setTimeout(function(){try{var b=WebSocket.__flash.receiveEvents();for(var c=0;c<b.length;++c)WebSocket.__instances[b[c].webSocketId].__handleEvent(b[c])}catch(d){a.error(d)}},0);return!0},WebSocket.__log=function(b){a.log(decodeURIComponent(b))},WebSocket.__error=function(b){a.error(decodeURIComponent(b))},WebSocket.__addTask=function(a){WebSocket.__flash?a():WebSocket.__tasks.push(a)},WebSocket.__isFlashLite=function(){if(!window.navigator||!window.navigator.mimeTypes)return!1;var a=window.navigator.mimeTypes["application/x-shockwave-flash"];if(!a||!a.enabledPlugin||!a.enabledPlugin.filename)return!1;return a.enabledPlugin.filename.match(/flashlite/i)?!0:!1},window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION||(window.addEventListener?window.addEventListener("load",function(){WebSocket.__initialize()},!1):window.attachEvent("onload",function(){WebSocket.__initialize()}))}})(),function(a,b){function d(){}function c(a){!a||(b.Transport.apply(this,arguments),this.sendBuffer=[])}a.XHR=c,b.util.inherit(c,b.Transport),c.prototype.open=function(){this.socket.setBuffer(!1),this.onOpen(),this.get(),this.setCloseTimeout();return this},c.prototype.payload=function(a){var c=[];for(var d=0,e=a.length;d<e;d++)c.push(b.parser.encodePacket(a[d]));this.send(b.parser.encodePayload(c))},c.prototype.send=function(a){this.post(a);return this},c.prototype.post=function(a){function e(){this.onload=d,b.socket.setBuffer(!1)}function c(){this.readyState==4&&(this.onreadystatechange=d,b.posting=!1,this.status==200?b.socket.setBuffer(!1):b.onClose())}var b=this;this.socket.setBuffer(!0),this.sendXHR=this.request("POST"),window.XDomainRequest&&this.sendXHR instanceof XDomainRequest?this.sendXHR.onload=this.sendXHR.onerror=e:this.sendXHR.onreadystatechange=c,this.sendXHR.send(a)},c.prototype.close=function(){this.onClose();return this},c.prototype.request=function(a){var c=b.util.request(this.socket.isXDomain());c.open(a||"GET",this.prepareUrl()+"?t"+ +(new Date));if(a=="POST")try{c.setRequestHeader?c.setRequestHeader("Content-type","text/plain;charset=UTF-8"):c.contentType="text/plain"}catch(d){}return c},c.prototype.scheme=function(){return this.socket.options.secure?"https":"http"},c.check=function(a,c){try{if(b.util.request(c))return!0}catch(d){}return!1},c.xdomainCheck=function(){return c.check(null,!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)}a.htmlfile=c,b.util.inherit(c,b.Transport.XHR),c.prototype.name="htmlfile",c.prototype.get=function(){this.doc=new ActiveXObject("htmlfile"),this.doc.open(),this.doc.write("<html></html>"),this.doc.close(),this.doc.parentWindow.s=this;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);var c=this;b.util.on(window,"unload",function(){c.destroy()})},c.prototype._=function(a,b){this.onData(a);try{var c=b.getElementsByTagName("script")[0];c.parentNode.removeChild(c)}catch(d){}},c.prototype.destroy=function(){if(this.iframe){try{this.iframe.src="about:blank"}catch(a){}this.doc=null,this.iframe.parentNode.removeChild(this.iframe),this.iframe=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},b.transports.push("htmlfile")}("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)}a["xhr-polling"]=c,b.util.inherit(c,b.Transport.XHR),c.prototype.name="xhr-polling",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 c(){this.onload=d,a.onData(this.responseText),a.get()}function b(){this.readyState==4&&(this.onreadystatechange=d,this.status==200?(a.onData(this.responseText),a.get()):a.onClose())}if(!!this.open){var a=this;this.xhr=this.request(),window.XDomainRequest&&this.xhr instanceof XDomainRequest?this.xhr.onload=this.xhr.onerror=c:this.xhr.onreadystatechange=b,this.xhr.send(null)}},c.prototype.onClose=function(){b.Transport.XHR.prototype.onClose.call(this);if(this.xhr){this.xhr.onreadystatechange=this.xhr.onload=d;try{this.xhr.abort()}catch(a){}this.xhr=null}},b.transports.push("xhr-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports),function(a,b){function c(a){b.Transport["xhr-polling"].apply(this,arguments),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.name="jsonp-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.socket.setBuffer(!1)}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",d.name="d",c.appendChild(d),document.body.appendChild(c),this.form=c,this.area=d}this.form.action=this.prepareUrl()+"?t="+ +(new Date)+"&i="+this.index,h(),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()};var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c),this.script=b},c.prototype._=function(a){this.onData(a),this.open&&this.get();return this},c.check=function(){return!0},c.xdomainCheck=function(){return!0},b.transports.push("jsonp-polling")}("undefined"!=typeof io?io.Transport:module.exports,"undefined"!=typeof io?io:module.parent.exports)
\ No newline at end of file