diff --git a/assets/scripts/vendor/pusher.js b/assets/scripts/vendor/pusher.js index 39c055dc..08e561ed 100644 --- a/assets/scripts/vendor/pusher.js +++ b/assets/scripts/vendor/pusher.js @@ -1,5 +1,5 @@ /*! - * Pusher JavaScript Library v2.0.0 + * Pusher JavaScript Library v2.0.4 * http://pusherapp.com/ * * Copyright 2013, Pusher @@ -17,81 +17,83 @@ arrayIndexOf:function(b,c){var a=Array.prototype.indexOf;if(b===null)return-1;if d,b,a));return a},mapObject:function(b,c){var a={},d;for(d in b)Object.prototype.hasOwnProperty.call(b,d)&&(a[d]=c(b[d]));return a},filter:function(b,c){for(var c=c||function(a){return!!a},a=[],d=0;d0)for(c=0;c1||a(this.getPath(d),function(){for(var a=0;a1||a(this.getPath(b),function(){for(var a=0;a>>6)+b(128|d&63):b(224|d>>>12&15)+b(128|d>>>6&63)+b(128|d&63)},d=function(a){var d=[0,2,1][a.length%3],a=a.charCodeAt(0)<<16|(a.length>1?a.charCodeAt(1):0)<<8|(a.length>2?a.charCodeAt(2):0);return["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>18),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>> -12&63),d>=2?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6&63),d>=1?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a&63)].join("")},h=window.btoa||function(a){return a.replace(/[\s\S]{1,3}/g,d)};Pusher.Base64={encode:function(d){return h(d.replace(/[^\x00-\x7F]/g,a))}}}).call(this); +(function(){function b(a,b){var c=this;this.timeout=setTimeout(function(){if(c.timeout!==null)b(),c.timeout=null},a)}var c=b.prototype;c.isRunning=function(){return this.timeout!==null};c.ensureAborted=function(){if(this.timeout)clearTimeout(this.timeout),this.timeout=null};Pusher.Timer=b}).call(this); +(function(){for(var b=String.fromCharCode,c=0;c<64;c++)"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(c);var a=function(a){var d=a.charCodeAt(0);return d<128?a:d<2048?b(192|d>>>6)+b(128|d&63):b(224|d>>>12&15)+b(128|d>>>6&63)+b(128|d&63)},d=function(a){var b=[0,2,1][a.length%3],a=a.charCodeAt(0)<<16|(a.length>1?a.charCodeAt(1):0)<<8|(a.length>2?a.charCodeAt(2):0);return["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>18),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>> +12&63),b>=2?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a>>>6&63),b>=1?"=":"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(a&63)].join("")},h=window.btoa||function(a){return a.replace(/[\s\S]{1,3}/g,d)};Pusher.Base64={encode:function(b){return h(b.replace(/[^\x00-\x7F]/g,a))}}}).call(this); (function(){function b(a){this.options=a}function c(a){return Pusher.Util.mapObject(a,function(a){typeof a==="object"&&(a=JSON.stringify(a));return encodeURIComponent(Pusher.Base64.encode(a.toString()))})}b.send=function(a,b){var c=new Pusher.JSONPRequest({url:a.url,receiver:a.receiverName,tagPrefix:a.tagPrefix}),f=a.receiver.register(function(a,d){c.cleanup();b(a,d)});return c.send(f,a.data,function(b){var c=a.receiver.unregister(f);c&&c(b)})};var a=b.prototype;a.send=function(a,b,e){if(this.script)return!1; var f=this.options.tagPrefix||"_pusher_jsonp_",b=Pusher.Util.extend({},b,{receiver:this.options.receiver}),b=Pusher.Util.map(Pusher.Util.flatten(c(Pusher.Util.filterObject(b,function(a){return a!==void 0}))),Pusher.Util.method("join","=")).join("&");this.script=document.createElement("script");this.script.id=f+a;this.script.src=this.options.url+"/"+a+"?"+b;this.script.type="text/javascript";this.script.charset="UTF-8";this.script.onerror=this.script.onload=e;if(this.script.async===void 0&&document.attachEvent&& /opera/i.test(navigator.userAgent))f=this.options.receiver||"Pusher.JSONP.receive",this.errorScript=document.createElement("script"),this.errorScript.text=f+"("+a+", true);",this.script.async=this.errorScript.async=!1;var g=this;this.script.onreadystatechange=function(){g.script&&/loaded|complete/.test(g.script.readyState)&&e(!0)};a=document.getElementsByTagName("head")[0];a.insertBefore(this.script,a.firstChild);this.errorScript&&a.insertBefore(this.errorScript,this.script.nextSibling);return!0}; a.cleanup=function(){if(this.script&&this.script.parentNode)this.script.parentNode.removeChild(this.script),this.script=null;if(this.errorScript&&this.errorScript.parentNode)this.errorScript.parentNode.removeChild(this.errorScript),this.errorScript=null};Pusher.JSONPRequest=b}).call(this); (function(){function b(){this.lastId=0;this.callbacks={}}var c=b.prototype;c.register=function(a){this.lastId++;var b=this.lastId;this.callbacks[b]=a;return b};c.unregister=function(a){if(this.callbacks[a]){var b=this.callbacks[a];delete this.callbacks[a];return b}else return null};c.receive=function(a,b,c){(a=this.unregister(a))&&a(b,c)};Pusher.JSONPReceiver=b;Pusher.JSONP=new b}).call(this); (function(){function b(a,b,c){this.key=a;this.session=b;this.events=[];this.options=c||{};this.uniqueID=this.sent=0}var c=b.prototype;b.ERROR=3;b.INFO=6;b.DEBUG=7;c.log=function(a,b){if(this.options.level===void 0||a<=this.options.level)this.events.push(Pusher.Util.extend({},b,{timestamp:Pusher.Util.now(),level:a})),this.options.limit&&this.events.length>this.options.limit&&this.events.shift()};c.error=function(a){this.log(b.ERROR,a)};c.info=function(a){this.log(b.INFO,a)};c.debug=function(a){this.log(b.DEBUG, -a)};c.isEmpty=function(){return this.events.length===0};c.send=function(a,b){var c=this,e={};this.sent===0&&(e=Pusher.Util.extend({key:this.key,features:this.options.features,version:this.options.version},this.options.params||{}));e.session=this.session;e.timeline=this.events;e=Pusher.Util.filterObject(e,function(a){return a!==void 0});this.events=[];a(e,function(a,e){a||c.sent++;b(a,e)});return!0};c.generateUniqueID=function(){this.uniqueID++;return this.uniqueID};Pusher.Timeline=b}).call(this); +a)};c.isEmpty=function(){return this.events.length===0};c.send=function(a,b){var c=this,e={};this.sent===0&&(e=Pusher.Util.extend({key:this.key,features:this.options.features,version:this.options.version},this.options.params||{}));e.session=this.session;e.timeline=this.events;e=Pusher.Util.filterObject(e,function(a){return a!==void 0});this.events=[];a(e,function(a,g){a||c.sent++;b(a,g)});return!0};c.generateUniqueID=function(){this.uniqueID++;return this.uniqueID};Pusher.Timeline=b}).call(this); (function(){function b(a,b){this.timeline=a;this.options=b||{}}var c=b.prototype;c.send=function(a){if(!this.timeline.isEmpty()){var b=this.options,c="http"+(this.isEncrypted()?"s":"")+"://";this.timeline.send(function(a,f){return Pusher.JSONPRequest.send({data:a,url:c+b.host+b.path,receiver:Pusher.JSONP},f)},a)}};c.isEncrypted=function(){return!!this.options.encrypted};Pusher.TimelineSender=b}).call(this); (function(){function b(a){this.strategies=a}function c(a,b,c){var h=Pusher.Util.map(a,function(a,d,h,e){return a.connect(b,c(d,e))});return{abort:function(){Pusher.Util.apply(h,d)},forceMinPriority:function(a){Pusher.Util.apply(h,function(b){b.forceMinPriority(a)})}}}function a(a){return Pusher.Util.all(a,function(a){return Boolean(a.error)})}function d(a){if(!a.error&&!a.aborted)a.abort(),a.aborted=!0}var h=b.prototype;h.isSupported=function(){return Pusher.Util.any(this.strategies,Pusher.Util.method("isSupported"))}; -h.connect=function(b,d){return c(this.strategies,b,function(b,c){return function(h,e){(c[b].error=h)?a(c)&&d(!0):(Pusher.Util.apply(c,function(a){a.forceMinPriority(e.priority)}),d(null,e))}})};Pusher.BestConnectedEverStrategy=b}).call(this); +h.connect=function(b,d){return c(this.strategies,b,function(b,c){return function(h,e){(c[b].error=h)?a(c)&&d(!0):(Pusher.Util.apply(c,function(a){a.forceMinPriority(e.transport.priority)}),d(null,e))}})};Pusher.BestConnectedEverStrategy=b}).call(this); (function(){function b(a,b,c){this.strategy=a;this.transports=b;this.ttl=c.ttl||18E5;this.timeline=c.timeline}function c(){var a=Pusher.Util.getLocalStorage();return a&&a.pusherTransport?JSON.parse(a.pusherTransport):null}var a=b.prototype;a.isSupported=function(){return this.strategy.isSupported()};a.connect=function(a,b){var e=c(),f=[this.strategy];if(e&&e.timestamp+this.ttl>=Pusher.Util.now()){var g=this.transports[e.transport];g&&(this.timeline.info({cached:!0,transport:e.transport}),f.push(new Pusher.SequentialStrategy([g], -{timeout:e.latency*2,failFast:!0})))}var i=Pusher.Util.now(),j=f.pop().connect(a,function k(c,e){if(c){var g=Pusher.Util.getLocalStorage();g&&delete g.pusherTransport;f.length>0?(i=Pusher.Util.now(),j=f.pop().connect(a,k)):b(c)}else{var g=Pusher.Util.now()-i,o=e.name,n=Pusher.Util.getLocalStorage();if(n)n.pusherTransport=JSON.stringify({timestamp:Pusher.Util.now(),transport:o,latency:g});b(null,e)}});return{abort:function(){j.abort()},forceMinPriority:function(b){a=b;j&&j.forceMinPriority(b)}}};Pusher.CachedStrategy= -b}).call(this);(function(){function b(a,b){this.strategy=a;this.options={delay:b.delay}}var c=b.prototype;c.isSupported=function(){return this.strategy.isSupported()};c.connect=function(a,b){var c=this.strategy,e,f=new Pusher.Timer(this.options.delay,function(){e=c.connect(a,b)});return{abort:function(){f.ensureAborted();e&&e.abort()},forceMinPriority:function(b){a=b;e&&e.forceMinPriority(b)}}};Pusher.DelayedStrategy=b}).call(this); +{timeout:e.latency*2,failFast:!0})))}var j=Pusher.Util.now(),k=f.pop().connect(a,function i(c,g){if(c){var e=Pusher.Util.getLocalStorage();e&&e.pusherTransport&&delete e.pusherTransport;f.length>0?(j=Pusher.Util.now(),k=f.pop().connect(a,i)):b(c)}else{var e=Pusher.Util.now()-j,o=g.transport.name,n=Pusher.Util.getLocalStorage();if(n)try{n.pusherTransport=JSON.stringify({timestamp:Pusher.Util.now(),transport:o,latency:e})}catch(p){}b(null,g)}});return{abort:function(){k.abort()},forceMinPriority:function(b){a= +b;k&&k.forceMinPriority(b)}}};Pusher.CachedStrategy=b}).call(this);(function(){function b(a,b){this.strategy=a;this.options={delay:b.delay}}var c=b.prototype;c.isSupported=function(){return this.strategy.isSupported()};c.connect=function(a,b){var c=this.strategy,e,f=new Pusher.Timer(this.options.delay,function(){e=c.connect(a,b)});return{abort:function(){f.ensureAborted();e&&e.abort()},forceMinPriority:function(b){a=b;e&&e.forceMinPriority(b)}}};Pusher.DelayedStrategy=b}).call(this); (function(){function b(a){this.strategy=a}var c=b.prototype;c.isSupported=function(){return this.strategy.isSupported()};c.connect=function(a,b){var c=this.strategy.connect(a,function(a,f){f&&c.abort();b(a,f)});return c};Pusher.FirstConnectedStrategy=b}).call(this); (function(){function b(a,b,c){this.test=a;this.trueBranch=b;this.falseBranch=c}var c=b.prototype;c.isSupported=function(){return(this.test()?this.trueBranch:this.falseBranch).isSupported()};c.connect=function(a,b){return(this.test()?this.trueBranch:this.falseBranch).connect(a,b)};Pusher.IfStrategy=b}).call(this); -(function(){function b(a,b){this.strategies=a;this.loop=Boolean(b.loop);this.failFast=Boolean(b.failFast);this.timeout=b.timeout;this.timeoutLimit=b.timeoutLimit}var c=b.prototype;c.isSupported=function(){return Pusher.Util.any(this.strategies,Pusher.Util.method("isSupported"))};c.connect=function(a,b){var c=this,e=this.strategies,f=0,g=this.timeout,i=null,j=function(l,k){k?b(null,k):(f+=1,c.loop&&(f%=e.length),f0&&(f=new Pusher.Timer(c.timeout,function(){g.abort();e(!0)}));return{abort:function(){f&&f.ensureAborted();g.abort()},forceMinPriority:function(a){g.forceMinPriority(a)}}}; +(function(){function b(a,b){this.strategies=a;this.loop=Boolean(b.loop);this.failFast=Boolean(b.failFast);this.timeout=b.timeout;this.timeoutLimit=b.timeoutLimit}var c=b.prototype;c.isSupported=function(){return Pusher.Util.any(this.strategies,Pusher.Util.method("isSupported"))};c.connect=function(a,b){var c=this,e=this.strategies,f=0,g=this.timeout,j=null,k=function(m,i){i?b(null,i):(f+=1,c.loop&&(f%=e.length),f0&&(f=new Pusher.Timer(c.timeout,function(){g.abort();e(!0)}));return{abort:function(){f&&f.ensureAborted();g.abort()},forceMinPriority:function(a){g.forceMinPriority(a)}}}; Pusher.SequentialStrategy=b}).call(this); (function(){function b(a,b,c,f){this.name=a;this.priority=b;this.transport=c;this.options=f||{}}function c(a,b){new Pusher.Timer(0,function(){b(a)});return{abort:function(){},forceMinPriority:function(){}}}var a=b.prototype;a.isSupported=function(){return this.transport.isSupported({disableFlash:!!this.options.disableFlash})};a.connect=function(a,b){if(this.transport.isSupported()){if(this.priority0};c.reportDeath=function(){this.livesLeft-=1};Pusher.TransportManager=b}).call(this); (function(){function b(a){return function(b){return[a.apply(this,arguments),b]}}function c(a,b){if(a.length===0)return[[],b];var e=d(a[0],b),h=c(a.slice(1),e[1]);return[[e[0]].concat(h[0]),h[1]]}function a(a,b){if(typeof a[0]==="string"&&a[0].charAt(0)===":"){var e=b[a[0].slice(1)];if(a.length>1){if(typeof e!=="function")throw"Calling non-function "+a[0];var h=[Pusher.Util.extend({},b)].concat(Pusher.Util.map(a.slice(1),function(a){return d(a,Pusher.Util.extend({},b))[0]}));return e.apply(this,h)}else return[e, -b]}else return c(a,b)}function d(b,c){if(typeof b==="string"){var d;if(typeof b==="string"&&b.charAt(0)===":"){d=c[b.slice(1)];if(d===void 0)throw"Undefined symbol "+b;d=[d,c]}else d=[b,c];return d}else if(typeof b==="object"&&b instanceof Array&&b.length>0)return a(b,c);return[b,c]}var h={ws:Pusher.WSTransport,flash:Pusher.FlashTransport,sockjs:Pusher.SockJSTransport},e={def:function(a,b,c){if(a[b]!==void 0)throw"Redefining symbol "+b;a[b]=c;return[void 0,a]},def_transport:function(a,b,c,d,e,k){var m= -h[c];if(!m)throw new Pusher.Errors.UnsupportedTransport(c);c=Pusher.Util.extend({},{key:a.key,encrypted:a.encrypted,timeline:a.timeline,disableFlash:a.disableFlash},e);k&&(m=k.getAssistant(m));d=new Pusher.TransportStrategy(b,d,m,c);k=a.def(a,b,d)[1];k.transports=a.transports||{};k.transports[b]=d;return[void 0,k]},transport_manager:b(function(a,b){return new Pusher.TransportManager(b)}),sequential:b(function(a,b){var c=Array.prototype.slice.call(arguments,2);return new Pusher.SequentialStrategy(c, +b]}else return c(a,b)}function d(b,c){if(typeof b==="string"){var d;if(typeof b==="string"&&b.charAt(0)===":"){d=c[b.slice(1)];if(d===void 0)throw"Undefined symbol "+b;d=[d,c]}else d=[b,c];return d}else if(typeof b==="object"&&b instanceof Array&&b.length>0)return a(b,c);return[b,c]}var h={ws:Pusher.WSTransport,flash:Pusher.FlashTransport,sockjs:Pusher.SockJSTransport},e={def:function(a,b,c){if(a[b]!==void 0)throw"Redefining symbol "+b;a[b]=c;return[void 0,a]},def_transport:function(a,b,c,d,e,i){var l= +h[c];if(!l)throw new Pusher.Errors.UnsupportedTransport(c);c=Pusher.Util.extend({},{key:a.key,encrypted:a.encrypted,timeline:a.timeline,disableFlash:a.disableFlash,ignoreNullOrigin:a.ignoreNullOrigin},e);i&&(l=i.getAssistant(l));d=new Pusher.TransportStrategy(b,d,l,c);i=a.def(a,b,d)[1];i.transports=a.transports||{};i.transports[b]=d;return[void 0,i]},transport_manager:b(function(a,b){return new Pusher.TransportManager(b)}),sequential:b(function(a,b){var c=Array.prototype.slice.call(arguments,2);return new Pusher.SequentialStrategy(c, b)}),cached:b(function(a,b,c){return new Pusher.CachedStrategy(c,a.transports,{ttl:b,timeline:a.timeline})}),first_connected:b(function(a,b){return new Pusher.FirstConnectedStrategy(b)}),best_connected_ever:b(function(){var a=Array.prototype.slice.call(arguments,1);return new Pusher.BestConnectedEverStrategy(a)}),delayed:b(function(a,b,c){return new Pusher.DelayedStrategy(c,{delay:b})}),"if":b(function(a,b,c,d){return new Pusher.IfStrategy(b,c,d)}),is_supported:b(function(a,b){return function(){return b.isSupported()}})}; Pusher.StrategyBuilder={build:function(a,b){var c=Pusher.Util.extend({},e,b);return d(a,c)[1].strategy}}}).call(this); -(function(){function b(a){Pusher.EventsDispatcher.call(this);this.transport=a;this.bindListeners()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.supportsPing=function(){return this.transport.supportsPing()};c.send=function(a){return this.transport.send(a)};c.send_event=function(a,b,c){a={event:a,data:b};if(c)a.channel=c;Pusher.debug("Event sent",a);return this.send(JSON.stringify(a))};c.close=function(){this.transport.close()};c.bindListeners=function(){var a=this,b= -function(f){f=a.parseMessage(f);if(f!==void 0)f.event==="pusher:connection_established"?(a.id=f.data.socket_id,a.transport.unbind("message",b),a.transport.bind("message",c),a.transport.bind("ping_request",e),a.emit("connected",a.id)):f.event==="pusher:error"&&(a.handleCloseCode(f.data.code,f.data.message),a.transport.close())},c=function(b){b=a.parseMessage(b);if(b!==void 0){Pusher.debug("Event recd",b);switch(b.event){case "pusher:error":a.emit("error",{type:"PusherError",data:b.data});break;case "pusher:ping":a.emit("ping"); -break;case "pusher:pong":a.emit("pong")}a.emit("message",b)}},e=function(){a.emit("ping_request")},f=function(b){a.emit("error",{type:"WebSocketError",error:b})},g=function(i){i&&i.code&&a.handleCloseCode(i.code,i.reason);a.transport.unbind("message",b);a.transport.unbind("message",c);a.transport.unbind("ping_request",e);a.transport.unbind("error",f);a.transport.unbind("closed",g);a.transport=null;a.emit("closed")};this.transport.bind("message",b);this.transport.bind("error",f);this.transport.bind("closed", -g)};c.parseMessage=function(a){try{var b=JSON.parse(a.data);if(typeof b.data==="string")try{b.data=JSON.parse(b.data)}catch(c){if(!(c instanceof SyntaxError))throw c;}return b}catch(e){this.emit("error",{type:"MessageParseError",error:e,data:a.data})}};c.handleCloseCode=function(a,b){this.emit("error",{type:"PusherError",data:{code:a,message:b}});a<4E3?a>=1002&&a<=1004&&this.emit("backoff"):a===4E3?this.emit("ssl_only"):a<4100?this.emit("refused"):a<4200?this.emit("backoff"):a<4300?this.emit("retry"): -this.emit("refused")};Pusher.ProtocolWrapper=b}).call(this); -(function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.key=a;this.options=b||{};this.state="initialized";this.connection=null;this.encrypted=!!b.encrypted;this.timeline=this.options.getTimeline();var c=this;Pusher.Network.bind("online",function(){c.state==="unavailable"&&c.connect()});Pusher.Network.bind("offline",function(){c.shouldRetry()&&(c.disconnect(),c.updateState("unavailable"))});var e=function(){c.timelineSender&&c.timelineSender.send(function(){})};this.bind("connected",e); -setInterval(e,6E4)}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.connect=function(){if(!this.connection&&this.state!=="connecting"){var a=this.options.getStrategy({key:this.key,timeline:this.timeline,encrypted:this.encrypted});if(a.isSupported())if(Pusher.Network.isOnline()===!1)this.updateState("unavailable");else{this.updateState("connecting");this.timelineSender=this.options.getTimelineSender(this.timeline,{encrypted:this.encrypted},this);var b=this,c=function(e,f){e? -b.runner=a.connect(0,c):(b.runner.abort(),b.setConnection(b.wrapTransport(f)))};this.runner=a.connect(0,c);this.setUnavailableTimer()}else this.updateState("failed")}};c.send=function(a){return this.connection?this.connection.send(a):!1};c.send_event=function(a,b,c){return this.connection?this.connection.send_event(a,b,c):!1};c.disconnect=function(){this.runner&&this.runner.abort();this.clearRetryTimer();this.clearUnavailableTimer();this.stopActivityCheck();this.updateState("disconnected");if(this.connection)this.connection.close(), -this.connection=null};c.retryIn=function(a){var b=this;this.retryTimer=setTimeout(function(){if(b.retryTimer!==null)b.retryTimer=null,b.disconnect(),b.connect()},a||0)};c.clearRetryTimer=function(){if(this.retryTimer)clearTimeout(this.retryTimer),this.retryTimer=null};c.setUnavailableTimer=function(){var a=this;this.unavailableTimer=setTimeout(function(){if(a.unavailableTimer)a.updateState("unavailable"),a.unavailableTimer=null},this.options.unavailableTimeout)};c.clearUnavailableTimer=function(){if(this.unavailableTimer)clearTimeout(this.unavailableTimer), -this.unavailableTimer=null};c.resetActivityCheck=function(){this.stopActivityCheck();if(!this.connection.supportsPing()){var a=this;this.activityTimer=setTimeout(function(){a.send_event("pusher:ping",{});a.activityTimer=setTimeout(function(){a.connection.close()},a.options.pongTimeout)},this.options.activityTimeout)}};c.stopActivityCheck=function(){if(this.activityTimer)clearTimeout(this.activityTimer),this.activityTimer=null};c.setConnection=function(a){this.connection=a;var b=this,c=function(a){b.clearUnavailableTimer(); -b.socket_id=a;b.updateState("connected");b.resetActivityCheck()},e=function(a){b.resetActivityCheck();b.emit("message",a)},f=function(){b.send_event("pusher:pong",{})},g=function(){b.send_event("pusher:ping",{})},i=function(a){b.emit("error",{type:"WebSocketError",error:a})},j=function(){a.unbind("connected",c);a.unbind("message",e);a.unbind("ping",f);a.unbind("ping_request",g);a.unbind("error",i);a.unbind("closed",j);b.connection=null;b.shouldRetry()&&b.retryIn(1E3)};a.bind("connected",c);a.bind("message", -e);a.bind("ping",f);a.bind("ping_request",g);a.bind("error",i);a.bind("closed",j);a.bind("ssl_only",function(){b.encrypted=!0;b.retryIn(0)});a.bind("refused",function(){b.disconnect()});a.bind("backoff",function(){b.retryIn(1E3)});a.bind("retry",function(){b.retryIn(0)});this.resetActivityCheck()};c.updateState=function(a,b){var c=this.state;this.state=a;c!==a&&(Pusher.debug("State changed",c+" -> "+a),this.emit("state_change",{previous:c,current:a}),this.emit(a,b))};c.shouldRetry=function(){return this.state=== -"connecting"||this.state==="connected"};c.wrapTransport=function(a){return new Pusher.ProtocolWrapper(a)};Pusher.ConnectionManager=b}).call(this); +(function(){Protocol={decodeMessage:function(b){try{var c=JSON.parse(b.data);if(typeof c.data==="string")try{c.data=JSON.parse(c.data)}catch(a){if(!(a instanceof SyntaxError))throw a;}return c}catch(d){throw{type:"MessageParseError",error:d,data:b.data};}},encodeMessage:function(b){return JSON.stringify(b)},processHandshake:function(b){b=this.decodeMessage(b);if(b.event==="pusher:connection_established")return{action:"connected",id:b.data.socket_id};else if(b.event==="pusher:error")return{action:this.getCloseAction(b.data), +error:this.getCloseError(b.data)};else throw"Invalid handshake";},getCloseAction:function(b){return b.code<4E3?b.code>=1002&&b.code<=1004?"backoff":null:b.code===4E3?"ssl_only":b.code<4100?"refused":b.code<4200?"backoff":b.code<4300?"retry":"refused"},getCloseError:function(b){return b.code!==1E3&&b.code!==1001?{type:"PusherError",data:{code:b.code,message:b.reason||b.message}}:null}};Pusher.Protocol=Protocol}).call(this); +(function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.id=a;this.transport=b;this.bindListeners()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.supportsPing=function(){return this.transport.supportsPing()};c.send=function(a){return this.transport.send(a)};c.send_event=function(a,b,c){a={event:a,data:b};if(c)a.channel=c;return this.send(Pusher.Protocol.encodeMessage(a))};c.close=function(){this.transport.close()};c.bindListeners=function(){var a=this,b=function(b){var c; +try{c=Pusher.Protocol.decodeMessage(b)}catch(d){a.emit("error",{type:"MessageParseError",error:d,data:b.data})}if(c!==void 0){Pusher.debug("Event recd",c);switch(c.event){case "pusher:error":a.emit("error",{type:"PusherError",data:c.data});break;case "pusher:ping":a.emit("ping");break;case "pusher:pong":a.emit("pong")}a.emit("message",c)}},c=function(){a.emit("ping_request")},e=function(b){a.emit("error",{type:"WebSocketError",error:b})},f=function(g){a.transport.unbind("closed",f);a.transport.unbind("error", +e);a.transport.unbind("ping_request",c);a.transport.unbind("message",b);g&&g.code&&a.handleCloseEvent(g);a.transport=null;a.emit("closed")};a.transport.bind("message",b);a.transport.bind("ping_request",c);a.transport.bind("error",e);a.transport.bind("closed",f)};c.handleCloseEvent=function(a){var b=Pusher.Protocol.getCloseAction(a);(a=Pusher.Protocol.getCloseError(a))&&this.emit("error",a);b&&this.emit(b)};Pusher.Connection=b}).call(this); +(function(){function b(a,b){this.transport=a;this.callback=b;this.bindListeners()}var c=b.prototype;c.bindListeners=function(){var a=this,b=function(){a.transport.unbind("message",c);a.transport.unbind("closed",e)},c=function(c){b();try{var e=Pusher.Protocol.processHandshake(c);e.action==="connected"?a.finish("connected",{connection:new Pusher.Connection(e.id,a.transport)}):(a.finish(e.action,{error:e.error}),a.transport.close())}catch(h){a.finish("error",{error:h}),a.transport.close()}},e=function(c){b(); +var e=Pusher.Protocol.getCloseAction(c)||"backoff",c=Pusher.Protocol.getCloseError(c);a.finish(e,{error:c})};a.transport.bind("message",c);a.transport.bind("closed",e)};c.finish=function(a,b){this.callback(Pusher.Util.extend({transport:this.transport,action:a},b))};Pusher.Handshake=b}).call(this); +(function(){function b(a,b){Pusher.EventsDispatcher.call(this);this.key=a;this.options=b||{};this.state="initialized";this.connection=null;this.encrypted=!!b.encrypted;this.timeline=this.options.getTimeline();this.connectionCallbacks=this.buildConnectionCallbacks();this.errorCallbacks=this.buildErrorCallbacks();this.handshakeCallbacks=this.buildHandshakeCallbacks(this.errorCallbacks);var c=this;Pusher.Network.bind("online",function(){c.state==="unavailable"&&c.connect()});Pusher.Network.bind("offline", +function(){c.shouldRetry()&&(c.disconnect(),c.updateState("unavailable"))});var e=function(){c.timelineSender&&c.timelineSender.send(function(){})};this.bind("connected",e);setInterval(e,6E4);this.updateStrategy()}var c=b.prototype;Pusher.Util.extend(c,Pusher.EventsDispatcher.prototype);c.connect=function(){var a=this;if(!a.connection&&a.state!=="connecting")if(a.strategy.isSupported())if(Pusher.Network.isOnline()===!1)a.updateState("unavailable");else{a.updateState("connecting");a.timelineSender= +a.options.getTimelineSender(a.timeline,{encrypted:a.encrypted},a);var b=function(c,e){c?a.runner=a.strategy.connect(0,b):(a.runner.abort(),a.handshakeCallbacks[e.action](e))};a.runner=a.strategy.connect(0,b);a.setUnavailableTimer()}else a.updateState("failed")};c.send=function(a){return this.connection?this.connection.send(a):!1};c.send_event=function(a,b,c){return this.connection?this.connection.send_event(a,b,c):!1};c.disconnect=function(){this.runner&&this.runner.abort();this.clearRetryTimer(); +this.clearUnavailableTimer();this.stopActivityCheck();this.updateState("disconnected");this.connection&&(this.connection.close(),this.abandonConnection())};c.updateStrategy=function(){this.strategy=this.options.getStrategy({key:this.key,timeline:this.timeline,encrypted:this.encrypted})};c.retryIn=function(a){var b=this;this.retryTimer=new Pusher.Timer(a||0,function(){b.disconnect();b.connect()})};c.clearRetryTimer=function(){this.retryTimer&&this.retryTimer.ensureAborted()};c.setUnavailableTimer= +function(){var a=this;a.unavailableTimer=new Pusher.Timer(a.options.unavailableTimeout,function(){a.updateState("unavailable")})};c.clearUnavailableTimer=function(){this.unavailableTimer&&this.unavailableTimer.ensureAborted()};c.resetActivityCheck=function(){this.stopActivityCheck();if(!this.connection.supportsPing()){var a=this;a.activityTimer=new Pusher.Timer(a.options.activityTimeout,function(){a.send_event("pusher:ping",{});a.activityTimer=new Pusher.Timer(a.options.pongTimeout,function(){a.connection.close()})})}}; +c.stopActivityCheck=function(){this.activityTimer&&this.activityTimer.ensureAborted()};c.buildConnectionCallbacks=function(){var a=this;return{message:function(b){a.resetActivityCheck();a.emit("message",b)},ping:function(){a.send_event("pusher:pong",{})},ping_request:function(){a.send_event("pusher:ping",{})},error:function(b){a.emit("error",{type:"WebSocketError",error:b})},closed:function(){a.abandonConnection();a.shouldRetry()&&a.retryIn(1E3)}}};c.buildHandshakeCallbacks=function(a){var b=this; +return Pusher.Util.extend({},a,{connected:function(a){b.clearUnavailableTimer();b.setConnection(a.connection);b.socket_id=b.connection.id;b.updateState("connected")}})};c.buildErrorCallbacks=function(){var a=this;return{ssl_only:function(){a.encrypted=!0;a.updateStrategy();a.retryIn(0)},refused:function(){a.disconnect()},backoff:function(){a.retryIn(1E3)},retry:function(){a.retryIn(0)}}};c.setConnection=function(a){this.connection=a;for(var b in this.connectionCallbacks)this.connection.bind(b,this.connectionCallbacks[b]); +this.resetActivityCheck()};c.abandonConnection=function(){if(this.connection){for(var a in this.connectionCallbacks)this.connection.unbind(a,this.connectionCallbacks[a]);this.connection=null}};c.updateState=function(a,b){var c=this.state;this.state=a;c!==a&&(Pusher.debug("State changed",c+" -> "+a),this.emit("state_change",{previous:c,current:a}),this.emit(a,b))};c.shouldRetry=function(){return this.state==="connecting"||this.state==="connected"};Pusher.ConnectionManager=b}).call(this); (function(){function b(){Pusher.EventsDispatcher.call(this);var b=this;window.addEventListener!==void 0&&(window.addEventListener("online",function(){b.emit("online")},!1),window.addEventListener("offline",function(){b.emit("offline")},!1))}Pusher.Util.extend(b.prototype,Pusher.EventsDispatcher.prototype);b.prototype.isOnline=function(){return window.navigator.onLine===void 0?!0:window.navigator.onLine};Pusher.NetInfo=b;Pusher.Network=new b}).call(this); (function(){Pusher.Channels=function(){this.channels={}};Pusher.Channels.prototype={add:function(b,a){var d=this.find(b);d||(d=Pusher.Channel.factory(b,a),this.channels[b]=d);return d},find:function(b){return this.channels[b]},remove:function(b){delete this.channels[b]},disconnect:function(){for(var b in this.channels)this.channels[b].disconnect()}};Pusher.Channel=function(b,a){var d=this;Pusher.EventsDispatcher.call(this,function(a){Pusher.debug("No callbacks on "+b+" for "+a)});this.pusher=a;this.name= b;this.subscribed=!1;this.bind("pusher_internal:subscription_succeeded",function(a){d.onSubscriptionSucceeded(a)})};Pusher.Channel.prototype={init:function(){},disconnect:function(){this.subscribed=!1;this.emit("pusher_internal:disconnected")},onSubscriptionSucceeded:function(){this.subscribed=!0;this.emit("pusher:subscription_succeeded")},authorize:function(b,a,d){return d(!1,{})},trigger:function(b,a){return this.pusher.send_event(b,a,this.name)}};Pusher.Util.extend(Pusher.Channel.prototype,Pusher.EventsDispatcher.prototype); -Pusher.Channel.PrivateChannel={authorize:function(b,a,d){var h=this;return(new Pusher.Channel.Authorizer(this,Pusher.channel_auth_transport,a)).authorize(b,function(a,b){a||h.emit("pusher_internal:authorized",b);d(a,b)})}};Pusher.Channel.PresenceChannel={init:function(){this.members=new b(this)},onSubscriptionSucceeded:function(){this.subscribed=!0}};var b=function(b){var a=this,d=null,h=function(){a._members_map={};a.count=0;d=a.me=null};h();var e=function(f){a._members_map=f.presence.hash;a.count= -f.presence.count;a.me=a.get(d.user_id);b.emit("pusher:subscription_succeeded",a)};b.bind("pusher_internal:authorized",function(a){d=JSON.parse(a.channel_data);b.bind("pusher_internal:subscription_succeeded",e)});b.bind("pusher_internal:member_added",function(d){a.get(d.user_id)===null&&a.count++;a._members_map[d.user_id]=d.user_info;b.emit("pusher:member_added",a.get(d.user_id))});b.bind("pusher_internal:member_removed",function(d){var e=a.get(d.user_id);e&&(delete a._members_map[d.user_id],a.count--, +Pusher.Channel.PrivateChannel={authorize:function(b,a,d){var h=this;return(new Pusher.Channel.Authorizer(this,Pusher.channel_auth_transport,a)).authorize(b,function(a,b){a||h.emit("pusher_internal:authorized",b);d(a,b)})}};Pusher.Channel.PresenceChannel={init:function(){this.members=new b(this)},onSubscriptionSucceeded:function(){this.subscribed=!0}};var b=function(b){var a=this,d=null,h=function(){a._members_map={};a.count=0;d=a.me=null};h();var e=function(e){a._members_map=e.presence.hash;a.count= +e.presence.count;a.me=a.get(d.user_id);b.emit("pusher:subscription_succeeded",a)};b.bind("pusher_internal:authorized",function(a){d=JSON.parse(a.channel_data);b.bind("pusher_internal:subscription_succeeded",e)});b.bind("pusher_internal:member_added",function(d){a.get(d.user_id)===null&&a.count++;a._members_map[d.user_id]=d.user_info;b.emit("pusher:member_added",a.get(d.user_id))});b.bind("pusher_internal:member_removed",function(d){var e=a.get(d.user_id);e&&(delete a._members_map[d.user_id],a.count--, b.emit("pusher:member_removed",e))});b.bind("pusher_internal:disconnected",function(){h();b.unbind("pusher_internal:subscription_succeeded",e)})};b.prototype={each:function(b){for(var a in this._members_map)b(this.get(a))},get:function(b){return this._members_map.hasOwnProperty(b)?{id:b,info:this._members_map[b]}:null}};Pusher.Channel.factory=function(b,a){var d=new Pusher.Channel(b,a);b.indexOf("private-")===0?Pusher.Util.extend(d,Pusher.Channel.PrivateChannel):b.indexOf("presence-")===0&&(Pusher.Util.extend(d, Pusher.Channel.PrivateChannel),Pusher.Util.extend(d,Pusher.Channel.PresenceChannel));d.init();return d}}).call(this); (function(){Pusher.Channel.Authorizer=function(b,c,a){this.channel=b;this.type=c;this.authOptions=(a||{}).auth||{}};Pusher.Channel.Authorizer.prototype={composeQuery:function(b){var b="&socket_id="+encodeURIComponent(b)+"&channel_name="+encodeURIComponent(this.channel.name),c;for(c in this.authOptions.params)b+="&"+encodeURIComponent(c)+"="+encodeURIComponent(this.authOptions.params[c]);return b},authorize:function(b,c){return Pusher.authorizers[this.type].call(this,b,c)}};Pusher.auth_callbacks={};