fix hooks, sync and try fixing locale
This commit is contained in:
parent
be40b8e45a
commit
af02f2b2f3
3
Gemfile
3
Gemfile
|
@ -1,5 +1,7 @@
|
|||
source :rubygems
|
||||
|
||||
gem 'debugger'
|
||||
|
||||
gem 'travis-api', github: 'travis-ci/travis-api'
|
||||
gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-more-services'
|
||||
gem 'travis-support', github: 'travis-ci/travis-support'
|
||||
|
@ -8,6 +10,7 @@ gem 'gh', github: 'rkh/gh'
|
|||
gem 'unicorn'
|
||||
gem 'sinatra'
|
||||
gem 'sinatra-contrib'
|
||||
gem 'rack-contrib', github: 'rack/rack-contrib'
|
||||
gem 'yard-sinatra', github: 'rkh/yard-sinatra'
|
||||
|
||||
gem 'bunny'
|
||||
|
|
23
Gemfile.lock
23
Gemfile.lock
|
@ -6,6 +6,13 @@ GIT
|
|||
rake (~> 0.9.0)
|
||||
thor
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rack/rack-contrib.git
|
||||
revision: b7e7c38fd02c3b5da91aa57af78b3f571c6ebcd0
|
||||
specs:
|
||||
rack-contrib (1.1.0)
|
||||
rack (>= 0.9.1)
|
||||
|
||||
GIT
|
||||
remote: git://github.com/rkh/gh.git
|
||||
revision: affde20a4fecb1023f2e7031734b9386a76d22c2
|
||||
|
@ -35,7 +42,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-api.git
|
||||
revision: f09cb3cac0290dcb745ae6a913b73188c375199b
|
||||
revision: 6dc28f0c49cef93dd24ee980b018719af02180df
|
||||
specs:
|
||||
travis-api (0.0.1)
|
||||
backports (~> 2.5)
|
||||
|
@ -53,7 +60,7 @@ GIT
|
|||
|
||||
GIT
|
||||
remote: git://github.com/travis-ci/travis-core.git
|
||||
revision: ea7a1678a0388e586ac4778a9b6ee56a11dfb0aa
|
||||
revision: a4b1446e3746a5ff59a5438a34f7b2471e33a731
|
||||
branch: sf-more-services
|
||||
specs:
|
||||
travis-core (0.0.1)
|
||||
|
@ -126,6 +133,7 @@ GEM
|
|||
coffee-script-source
|
||||
execjs
|
||||
coffee-script-source (1.3.3)
|
||||
columnize (0.3.6)
|
||||
compass (0.12.2)
|
||||
chunky_png (~> 1.2)
|
||||
fssm (>= 0.2.7)
|
||||
|
@ -134,6 +142,13 @@ GEM
|
|||
data_migrations (0.0.1)
|
||||
activerecord
|
||||
rake
|
||||
debugger (1.2.0)
|
||||
columnize (>= 0.3.1)
|
||||
debugger-linecache (~> 1.1.1)
|
||||
debugger-ruby_core_source (~> 1.1.3)
|
||||
debugger-linecache (1.1.2)
|
||||
debugger-ruby_core_source (>= 1.1.1)
|
||||
debugger-ruby_core_source (1.1.3)
|
||||
erubis (2.7.0)
|
||||
eventmachine (1.0.0)
|
||||
execjs (1.4.0)
|
||||
|
@ -181,8 +196,6 @@ GEM
|
|||
rack (1.4.1)
|
||||
rack-cache (1.2)
|
||||
rack (>= 0.4)
|
||||
rack-contrib (1.1.0)
|
||||
rack (>= 0.9.1)
|
||||
rack-protection (1.2.0)
|
||||
rack
|
||||
rack-ssl (1.3.2)
|
||||
|
@ -246,11 +259,13 @@ DEPENDENCIES
|
|||
bunny
|
||||
coffee-script
|
||||
compass
|
||||
debugger
|
||||
gh!
|
||||
guard
|
||||
hubble!
|
||||
newrelic_rpm (~> 3.3.0)
|
||||
pg (~> 0.13.2)
|
||||
rack-contrib!
|
||||
rake-pipeline!
|
||||
rake-pipeline-web-filters!
|
||||
sinatra
|
||||
|
|
|
@ -22,7 +22,7 @@ require 'travis/model'
|
|||
).property()
|
||||
|
||||
updateLocale: (locale) ->
|
||||
@set('locale', locale)
|
||||
@setWithSession('locale', locale)
|
||||
Travis.app.store.commit()
|
||||
|
||||
type: (->
|
||||
|
@ -38,7 +38,19 @@ require 'travis/model'
|
|||
@ajax '/profile', 'get', success: (data) =>
|
||||
if data.user.is_syncing
|
||||
Ember.run.later(this, this.poll.bind(this), 3000)
|
||||
else if this.get('isSyncing')
|
||||
# TODO this doesn't seem to work properly
|
||||
Travis.app.store.load(Travis.User, data.user)
|
||||
Travis.app.store.loadMany(Travis.Account, data.accounts)
|
||||
else
|
||||
@set('isSyncing', false)
|
||||
@setWithSession('syncedAt', data.user.synced_at)
|
||||
|
||||
# # TODO this doesn't work properly
|
||||
# Travis.app.store.loadMany(Travis.Account, data.accounts)
|
||||
|
||||
setWithSession: (name, value) ->
|
||||
@set(name, value)
|
||||
data = JSON.parse(sessionStorage?.getItem('travis.user'))
|
||||
data.user[$.underscore(name)] = @get(name)
|
||||
sessionStorage?.setItem('travis.user', JSON.stringify(data))
|
||||
|
||||
|
||||
@Travis.User.reopenClass
|
||||
url: 'profile'
|
||||
|
|
|
@ -25,8 +25,8 @@ $.extend Travis.Pusher.prototype,
|
|||
"#{Travis.Pusher.CHANNEL_PREFIX}#{channel}"
|
||||
|
||||
receive: (event, data) ->
|
||||
if data.id
|
||||
data = @normalize(event, data)
|
||||
return if event.substr(0, 6) == 'pusher'
|
||||
data = @normalize(event, data) if data.id
|
||||
Ember.run.next ->
|
||||
Travis.app.store.receive(event, data)
|
||||
|
||||
|
|
|
@ -22,3 +22,4 @@ require 'models'
|
|||
branch: 'branches'
|
||||
job: 'jobs'
|
||||
worker: 'workers'
|
||||
profile: 'profile'
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
</dl>
|
||||
|
||||
<form>
|
||||
{{view Ember.Select
|
||||
{{view Ember.Select id="locale"
|
||||
contentBinding="view.locales"
|
||||
selectionBinding="user.locale"
|
||||
valueBinding="Travis.app.currentUser.locale"
|
||||
optionLabelPath="content.name"
|
||||
optionValuePath="content.key"}}
|
||||
|
||||
|
|
|
@ -81,8 +81,13 @@
|
|||
"#{location.protocol}//www.gravatar.com/avatar/#{@get('user.gravatarId')}?s=48&d=mm"
|
||||
).property('user.gravatarId')
|
||||
|
||||
# locale: (->
|
||||
# @get('user.locale')
|
||||
# ).property('user.locale')
|
||||
|
||||
locales: (->
|
||||
[
|
||||
{ key: null, name: '' }
|
||||
{ key: 'en', name: 'English' }
|
||||
{ key: 'ca', name: 'Catalan' }
|
||||
{ key: 'cs', name: 'Čeština' }
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -27534,36 +27534,52 @@ I18n.l = I18n.localize;
|
|||
I18n.p = I18n.pluralize;
|
||||
|
||||
/*!
|
||||
* Pusher JavaScript Library v1.6.4
|
||||
* Pusher JavaScript Library v1.12.2
|
||||
* http://pusherapp.com/
|
||||
*
|
||||
* Copyright 2010, New Bamboo
|
||||
* Copyright 2011, Pusher
|
||||
* Released under the MIT licence.
|
||||
*/
|
||||
if(typeof Function.prototype.scopedTo=="undefined")Function.prototype.scopedTo=function(a,b){var c=this;return function(){return c.apply(a,Array.prototype.slice.call(b||[]).concat(Array.prototype.slice.call(arguments)))}};
|
||||
var Pusher=function(a,b){this.path="/app/"+a+"?client=js&version="+Pusher.VERSION;this.key=a;this.channels=new Pusher.Channels;this.global_channel=new Pusher.Channel("pusher_global_channel");this.global_channel.global=true;this.connected=this.secure=false;this.retry_counter=0;Pusher.isReady&&this.connect();Pusher.instances.push(this);b&&this.subscribe(b);this.bind("pusher:connection_established",function(c){this.connected=true;this.retry_counter=0;this.socket_id=c.socket_id;this.subscribeAll()}.scopedTo(this));
|
||||
this.bind("pusher:connection_disconnected",function(){for(var c in this.channels.channels)this.channels.channels[c].disconnect()}.scopedTo(this));this.bind("pusher:error",function(c){Pusher.log("Pusher : error : "+c.message)})};Pusher.instances=[];
|
||||
Pusher.prototype={channel:function(a){return this.channels.find(a)},connect:function(){var a="ws://"+Pusher.host+":"+Pusher.ws_port+this.path;if(this.secure==true)a="wss://"+Pusher.host+":"+Pusher.wss_port+this.path;Pusher.allow_reconnect=true;Pusher.log("Pusher : connecting : "+a);var b=this;if(window.WebSocket){this.connection=new WebSocket(a);this.connection.onmessage=function(){b.onmessage.apply(b,arguments)};this.connection.onclose=function(){b.onclose.apply(b,arguments)};this.connection.onopen=
|
||||
function(){b.onopen.apply(b,arguments)}}else{this.connection={};setTimeout(function(){b.send_local_event("pusher:connection_failed",{})},3E3)}},toggle_secure:function(){if(this.secure==false){this.secure=true;Pusher.log("Pusher: switching to wss:// connection")}else{this.secure=false;Pusher.log("Pusher: switching to ws:// connection")}},disconnect:function(){Pusher.log("Pusher : disconnecting");Pusher.allow_reconnect=false;Pusher.retry_count=0;this.connection.close()},bind:function(a,b){this.global_channel.bind(a,
|
||||
b);return this},bind_all:function(a){this.global_channel.bind_all(a);return this},subscribeAll:function(){for(var a in this.channels.channels)this.channels.channels.hasOwnProperty(a)&&this.subscribe(a)},subscribe:function(a){var b=this.channels.add(a);this.connected&&b.authorize(this,function(c){this.send_event("pusher:subscribe",{channel:a,auth:c.auth,channel_data:c.channel_data})}.scopedTo(this));return b},unsubscribe:function(a){this.channels.remove(a);this.connected&&this.send_event("pusher:unsubscribe",
|
||||
{channel:a})},send_event:function(a,b){var c=JSON.stringify({event:a,data:b});Pusher.log("Pusher : sending event : ",c);this.connection.send(c);return this},send_local_event:function(a,b,c){b=Pusher.data_decorator(a,b);if(c){var d=this.channel(c);d&&d.dispatch_with_all(a,b)}this.global_channel.dispatch_with_all(a,b);Pusher.log("Pusher : event received : channel: "+c+"; event: "+a,b)},onmessage:function(a){a=Pusher.parser(a.data);if(!(a.socket_id&&a.socket_id==this.socket_id)){var b=a.event,c=Pusher.parser(a.data);
|
||||
this.send_local_event(b,c,a.channel)}},wait_and_reconnect:function(a,b){setTimeout(function(){a();this.connect()}.scopedTo(this),b)},onclose:function(){var a=this;this.global_channel.dispatch("close",null);Pusher.log("Pusher: Socket closed");var b=5E3;if(this.connected==true){this.send_local_event("pusher:connection_disconnected",{});if(Pusher.allow_reconnect){Pusher.log("Pusher : Reconnecting in 5 seconds...");this.wait_and_reconnect(function(){},b)}}else{a.send_local_event("pusher:connection_failed",
|
||||
{});if(this.retry_counter==0)b=100;this.retry_counter+=1;this.wait_and_reconnect(function(){a.toggle_secure()},b)}this.connected=false},onopen:function(){this.global_channel.dispatch("open",null)}};Pusher.Util={extend:function(a,b){for(var c in b)a[c]=b[c];return a}};Pusher.VERSION="1.6.4";Pusher.host="ws.pusherapp.com";Pusher.ws_port=80;Pusher.wss_port=443;Pusher.channel_auth_endpoint="/pusher/auth";Pusher.log=function(){};Pusher.data_decorator=function(a,b){return b};Pusher.allow_reconnect=true;
|
||||
Pusher.channel_auth_transport="ajax";Pusher.parser=function(a){try{return JSON.parse(a)}catch(b){Pusher.log("Pusher : data attribute not valid JSON - you may wish to implement your own Pusher.parser");return a}};Pusher.isReady=false;Pusher.ready=function(){Pusher.isReady=true;for(var a=0;a<Pusher.instances.length;a++)Pusher.instances[a].connected||Pusher.instances[a].connect()};Pusher.Channels=function(){this.channels={}};
|
||||
Pusher.Channels.prototype={add:function(a){var b=this.find(a);if(b)return b;else{b=Pusher.Channel.factory(a);return this.channels[a]=b}},find:function(a){return this.channels[a]},remove:function(a){delete this.channels[a]}};Pusher.Channel=function(a){this.name=a;this.callbacks={};this.global_callbacks=[];this.subscribed=false};
|
||||
Pusher.Channel.prototype={init:function(){},disconnect:function(){},acknowledge_subscription:function(){this.subscribed=true},bind:function(a,b){this.callbacks[a]=this.callbacks[a]||[];this.callbacks[a].push(b);return this},bind_all:function(a){this.global_callbacks.push(a);return this},dispatch_with_all:function(a,b){this.dispatch(a,b);this.dispatch_global_callbacks(a,b)},dispatch:function(a,b){var c=this.callbacks[a];if(c)for(var d=0;d<c.length;d++)c[d](b);else this.global||Pusher.log("Pusher : No callbacks for "+
|
||||
a)},dispatch_global_callbacks:function(a,b){for(var c=0;c<this.global_callbacks.length;c++)this.global_callbacks[c](a,b)},is_private:function(){return false},is_presence:function(){return false},authorize:function(a,b){b({})}};Pusher.auth_callbacks={};
|
||||
Pusher.authorizers={ajax:function(a,b){var c=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");c.open("POST",Pusher.channel_auth_endpoint,true);c.setRequestHeader("Content-Type","application/x-www-form-urlencoded");c.onreadystatechange=function(){if(c.readyState==4)if(c.status==200){var d=Pusher.parser(c.responseText);b(d)}else Pusher.log("Couldn't get auth info from your webapp"+status)};c.send("socket_id="+encodeURIComponent(a.socket_id)+"&channel_name="+encodeURIComponent(this.name))},
|
||||
jsonp:function(a,b){var c="socket_id="+encodeURIComponent(a.socket_id)+"&channel_name="+encodeURIComponent(this.name),d=document.createElement("script");Pusher.auth_callbacks[this.name]=b;d.src=Pusher.channel_auth_endpoint+"?callback="+encodeURIComponent("Pusher.auth_callbacks['"+this.name+"']")+"&"+c;c=document.getElementsByTagName("head")[0]||document.documentElement;c.insertBefore(d,c.firstChild)}};
|
||||
Pusher.Channel.PrivateChannel={is_private:function(){return true},authorize:function(a,b){Pusher.authorizers[Pusher.channel_auth_transport].scopedTo(this)(a,b)}};
|
||||
Pusher.Channel.PresenceChannel={init:function(){this.bind("pusher_internal:subscription_succeeded",function(a){this.acknowledge_subscription(a);this.dispatch_with_all("pusher:subscription_succeeded",this.members())}.scopedTo(this));this.bind("pusher_internal:member_added",function(a){this.track_member(a,1);if(this.member_exists(a))return false;this.add_member(a);this.dispatch_with_all("pusher:member_added",a)}.scopedTo(this));this.bind("pusher_internal:member_removed",function(a){this.track_member(a,
|
||||
-1);if(this._members_count[a.user_id]>0)return false;this.remove_member(a);this.dispatch_with_all("pusher:member_removed",a)}.scopedTo(this))},disconnect:function(){this._members_map={};this._members_count={}},acknowledge_subscription:function(a){this._members_map={};this._members_count={};for(var b=0;b<a.length;b++){this._members_map[a[b].user_id]=a[b];this.track_member(a[b],1)}this.subscribed=true},track_member:function(a,b){this._members_count[a.user_id]=this._members_count[a.user_id]||0;this._members_count[a.user_id]+=
|
||||
b;return this},member_exists:function(a){return typeof this._members_map[a.user_id]!="undefined"},is_presence:function(){return true},members:function(){var a=[],b;for(b in this._members_map)a.push(this._members_map[b]);return a},add_member:function(a){this._members_map[a.user_id]=a},remove_member:function(a){delete this._members_map[a.user_id]}};
|
||||
Pusher.Channel.factory=function(a){var b=new Pusher.Channel(a);if(a.indexOf(Pusher.Channel.private_prefix)===0)Pusher.Util.extend(b,Pusher.Channel.PrivateChannel);else if(a.indexOf(Pusher.Channel.presence_prefix)===0){Pusher.Util.extend(b,Pusher.Channel.PrivateChannel);Pusher.Util.extend(b,Pusher.Channel.PresenceChannel)}b.init();return b};Pusher.Channel.private_prefix="private-";Pusher.Channel.presence_prefix="presence-";WEB_SOCKET_SWF_LOCATION="http://js.pusherapp.com/1.6.4/WebSocketMain.swf";
|
||||
var _require=function(){var a;a=document.addEventListener?function(b,c){b.addEventListener("load",c,false)}:function(b,c){b.attachEvent("onreadystatechange",function(){b.readyState=="loaded"&&c()})};return function(b,c){function d(j,f){f=f||function(){};var k=document.getElementsByTagName("head")[0],e=document.createElement("script");e.setAttribute("src",j+".js");e.setAttribute("type","text/javascript");e.setAttribute("async",true);a(e,function(){var l=f;h++;i==h&&setTimeout(l,0)});k.appendChild(e)}
|
||||
for(var h=0,i=b.length,g=0;g<i;g++)d(b[g],c)}}();(function(){var a=[],b=function(){Pusher.ready()};window.JSON==undefined&&a.push("http://js.pusherapp.com/1.6.4/json2");if(window.WebSocket==undefined){window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=true;a.push("http://js.pusherapp.com/1.6.4/flashfallback");b=function(){FABridge.addInitializationCallback("webSocket",function(){Pusher.ready()});WebSocket.__initialize()}}a.length>0?_require(a,b):b()})();
|
||||
|
||||
|
||||
(function(){if(Function.prototype.scopedTo===void 0)Function.prototype.scopedTo=function(a,b){var e=this;return function(){return e.apply(a,Array.prototype.slice.call(b||[]).concat(Array.prototype.slice.call(arguments)))}};var c=function(a,b){this.options=b||{};this.key=a;this.channels=new c.Channels;this.global_emitter=new c.EventsDispatcher;var e=this;this.checkAppKey();this.connection=new c.Connection(this.key,this.options);this.connection.bind("connected",function(){e.subscribeAll()}).bind("message",
|
||||
function(b){var a=b.event.indexOf("pusher_internal:")===0;if(b.channel){var c;(c=e.channel(b.channel))&&c.emit(b.event,b.data)}a||e.global_emitter.emit(b.event,b.data)}).bind("disconnected",function(){e.channels.disconnect()}).bind("error",function(b){c.warn("Error",b)});c.instances.push(this);c.isReady&&e.connect()};c.instances=[];c.prototype={channel:function(a){return this.channels.find(a)},connect:function(){this.connection.connect()},disconnect:function(){this.connection.disconnect()},bind:function(a,
|
||||
b){this.global_emitter.bind(a,b);return this},bind_all:function(a){this.global_emitter.bind_all(a);return this},subscribeAll:function(){for(channelName in this.channels.channels)this.channels.channels.hasOwnProperty(channelName)&&this.subscribe(channelName)},subscribe:function(a){var b=this,e=this.channels.add(a,this);this.connection.state==="connected"&&e.authorize(this.connection.socket_id,this.options,function(c,f){c?e.emit("pusher:subscription_error",f):b.send_event("pusher:subscribe",{channel:a,
|
||||
auth:f.auth,channel_data:f.channel_data})});return e},unsubscribe:function(a){this.channels.remove(a);this.connection.state==="connected"&&this.send_event("pusher:unsubscribe",{channel:a})},send_event:function(a,b,e){return this.connection.send_event(a,b,e)},checkAppKey:function(){(this.key===null||this.key===void 0)&&c.warn("Warning","You must pass your app key when you instantiate Pusher.")}};c.Util={extend:function b(e,c){for(var f in c)e[f]=c[f]&&c[f].constructor&&c[f].constructor===Object?b(e[f]||
|
||||
{},c[f]):c[f];return e},stringify:function(){for(var b=["Pusher"],e=0;e<arguments.length;e++)typeof arguments[e]==="string"?b.push(arguments[e]):window.JSON==void 0?b.push(arguments[e].toString()):b.push(JSON.stringify(arguments[e]));return b.join(" : ")},arrayIndexOf:function(b,e){var c=Array.prototype.indexOf;if(b==null)return-1;if(c&&b.indexOf===c)return b.indexOf(e);for(i=0,l=b.length;i<l;i++)if(b[i]===e)return i;return-1}};c.debug=function(){c.log&&c.log(c.Util.stringify.apply(this,arguments))};
|
||||
c.warn=function(){window.console&&window.console.warn?window.console.warn(c.Util.stringify.apply(this,arguments)):c.log&&c.log(c.Util.stringify.apply(this,arguments))};c.VERSION="1.12.2";c.host="ws.pusherapp.com";c.ws_port=80;c.wss_port=443;c.channel_auth_endpoint="/pusher/auth";c.cdn_http="http://js.pusher.com/";c.cdn_https="https://d3dy5gmtp8yhk7.cloudfront.net/";c.dependency_suffix=".min";c.channel_auth_transport="ajax";c.activity_timeout=12E4;c.pong_timeout=3E4;c.isReady=!1;c.ready=function(){c.isReady=
|
||||
!0;for(var b=0,e=c.instances.length;b<e;b++)c.instances[b].connect()};this.Pusher=c}).call(this);
|
||||
(function(){function c(){this._callbacks={}}function a(b){this.callbacks=new c;this.global_callbacks=[];this.failThrough=b}c.prototype.get=function(b){return this._callbacks[this._prefix(b)]};c.prototype.add=function(b,a){var c=this._prefix(b);this._callbacks[c]=this._callbacks[c]||[];this._callbacks[c].push(a)};c.prototype.remove=function(b,a){if(this.get(b)){var c=Pusher.Util.arrayIndexOf(this.get(b),a);this._callbacks[this._prefix(b)].splice(c,1)}};c.prototype._prefix=function(b){return"_"+b};
|
||||
a.prototype.bind=function(b,a){this.callbacks.add(b,a);return this};a.prototype.unbind=function(b,a){this.callbacks.remove(b,a);return this};a.prototype.emit=function(b,a){for(var c=0;c<this.global_callbacks.length;c++)this.global_callbacks[c](b,a);var f=this.callbacks.get(b);if(f)for(c=0;c<f.length;c++)f[c](a);else this.failThrough&&this.failThrough(b,a);return this};a.prototype.bind_all=function(b){this.global_callbacks.push(b);return this};this.Pusher.EventsDispatcher=a}).call(this);
|
||||
(function(){function c(b,a,c){if(a[b]!==void 0)a[b](c)}function a(a,c,f){b.EventsDispatcher.call(this);this.state=void 0;this.errors=[];this.stateActions=f;this.transitions=c;this.transition(a)}var b=this.Pusher;a.prototype.transition=function(a,g){var f=this.state,h=this.stateActions;if(f&&b.Util.arrayIndexOf(this.transitions[f],a)==-1)throw this.emit("invalid_transition_attempt",{oldState:f,newState:a}),Error("Invalid transition ["+f+" to "+a+"]");c(f+"Exit",h,g);c(f+"To"+(a.substr(0,1).toUpperCase()+
|
||||
a.substr(1)),h,g);c(a+"Pre",h,g);this.state=a;this.emit("state_change",{oldState:f,newState:a});c(a+"Post",h,g)};a.prototype.is=function(b){return this.state===b};a.prototype.isNot=function(b){return this.state!==b};b.Util.extend(a.prototype,b.EventsDispatcher.prototype);this.Pusher.Machine=a}).call(this);
|
||||
(function(){var c=function(){var a=this;Pusher.EventsDispatcher.call(this);window.addEventListener!==void 0&&(window.addEventListener("online",function(){a.emit("online",null)},!1),window.addEventListener("offline",function(){a.emit("offline",null)},!1))};c.prototype.isOnLine=function(){return window.navigator.onLine===void 0?!0:window.navigator.onLine};Pusher.Util.extend(c.prototype,Pusher.EventsDispatcher.prototype);this.Pusher.NetInfo=c}).call(this);
|
||||
(function(){function c(a){a.connectionWait=0;a.openTimeout=b.TransportType==="flash"?5E3:2E3;a.connectedTimeout=2E3;a.connectionSecure=a.compulsorySecure;a.connectionAttempts=0}function a(a,r){function k(){d.connectionWait<s&&(d.connectionWait+=g);d.openTimeout<t&&(d.openTimeout+=f);d.connectedTimeout<u&&(d.connectedTimeout+=h);if(d.compulsorySecure!==!0)d.connectionSecure=!d.connectionSecure;d.connectionAttempts++}function m(){d._machine.transition("impermanentlyClosing")}function p(){d._activityTimer&&
|
||||
clearTimeout(d._activityTimer);d._activityTimer=setTimeout(function(){d.send_event("pusher:ping",{});d._activityTimer=setTimeout(function(){d.socket.close()},d.options.pong_timeout||b.pong_timeout)},d.options.activity_timeout||b.activity_timeout)}function v(){var b=d.connectionWait;if(b===0&&d.connectedAt){var a=(new Date).getTime()-d.connectedAt;a<1E3&&(b=1E3-a)}return b}function w(){d._machine.transition("open")}function x(b){b=q(b);if(b!==void 0)if(b.event==="pusher:connection_established")d._machine.transition("connected",
|
||||
b.data.socket_id);else if(b.event==="pusher:error"){var a=b.data.code;d.emit("error",{type:"PusherError",data:{code:a,message:b.data.message}});a===4E3?(d.compulsorySecure=!0,d.connectionSecure=!0,d.options.encrypted=!0,m()):a<4100?d._machine.transition("permanentlyClosing"):a<4200?(d.connectionWait=1E3,d._machine.transition("waiting")):a<4300?m():d._machine.transition("permanentlyClosing")}}function y(a){p();a=q(a);if(a!==void 0){b.debug("Event recd",a);switch(a.event){case "pusher:error":d.emit("error",
|
||||
{type:"PusherError",data:a.data});break;case "pusher:ping":d.send_event("pusher:pong",{})}d.emit("message",a)}}function q(b){try{var a=JSON.parse(b.data);if(typeof a.data==="string")try{a.data=JSON.parse(a.data)}catch(c){if(!(c instanceof SyntaxError))throw c;}return a}catch(e){d.emit("error",{type:"MessageParseError",error:e,data:b.data})}}function n(){d._machine.transition("waiting")}function o(b){d.emit("error",{type:"WebSocketError",error:b})}function j(a,c){var e=d.state;d.state=a;e!==a&&(b.debug("State changed",
|
||||
e+" -> "+a),d.emit("state_change",{previous:e,current:a}),d.emit(a,c))}var d=this;b.EventsDispatcher.call(this);this.options=b.Util.extend({encrypted:!1},r);this.netInfo=new b.NetInfo;this.netInfo.bind("online",function(){d._machine.is("waiting")&&(d._machine.transition("connecting"),j("connecting"))});this.netInfo.bind("offline",function(){if(d._machine.is("connected"))d.socket.onclose=void 0,d.socket.onmessage=void 0,d.socket.onerror=void 0,d.socket.onopen=void 0,d.socket.close(),d.socket=void 0,
|
||||
d._machine.transition("waiting")});this._machine=new b.Machine("initialized",e,{initializedPre:function(){d.compulsorySecure=d.options.encrypted;d.key=a;d.socket=null;d.socket_id=null;d.state="initialized"},waitingPre:function(){d.connectionWait>0&&d.emit("connecting_in",d.connectionWait);d.netInfo.isOnLine()&&d.connectionAttempts<=4?j("connecting"):j("unavailable");if(d.netInfo.isOnLine())d._waitingTimer=setTimeout(function(){d._machine.transition("connecting")},v())},waitingExit:function(){clearTimeout(d._waitingTimer)},
|
||||
connectingPre:function(){if(d.netInfo.isOnLine()===!1)d._machine.transition("waiting"),j("unavailable");else{var a;a=b.ws_port;var c="ws://";if(d.connectionSecure||document.location.protocol==="https:")a=b.wss_port,c="wss://";a=c+b.host+":"+a+"/app/"+d.key+"?protocol=5&client=js&version="+b.VERSION+"&flash="+(b.TransportType==="flash"?"true":"false");b.debug("Connecting",a);d.socket=new b.Transport(a);d.socket.onopen=w;d.socket.onclose=n;d.socket.onerror=o;d._connectingTimer=setTimeout(m,d.openTimeout)}},
|
||||
connectingExit:function(){clearTimeout(d._connectingTimer);d.socket.onopen=void 0},connectingToWaiting:function(){k()},connectingToImpermanentlyClosing:function(){k()},openPre:function(){d.socket.onmessage=x;d.socket.onerror=o;d.socket.onclose=n;d._openTimer=setTimeout(m,d.connectedTimeout)},openExit:function(){clearTimeout(d._openTimer);d.socket.onmessage=void 0},openToWaiting:function(){k()},openToImpermanentlyClosing:function(){k()},connectedPre:function(a){d.socket_id=a;d.socket.onmessage=y;d.socket.onerror=
|
||||
o;d.socket.onclose=n;c(d);d.connectedAt=(new Date).getTime();p()},connectedPost:function(){j("connected")},connectedExit:function(){d._activityTimer&&clearTimeout(d._activityTimer);j("disconnected")},impermanentlyClosingPost:function(){if(d.socket)d.socket.onclose=n,d.socket.close()},permanentlyClosingPost:function(){d.socket?(d.socket.onclose=function(){c(d);d._machine.transition("permanentlyClosed")},d.socket.close()):(c(d),d._machine.transition("permanentlyClosed"))},failedPre:function(){j("failed");
|
||||
b.debug("WebSockets are not available in this browser.")},permanentlyClosedPost:function(){j("disconnected")}})}var b=this.Pusher,e={initialized:["waiting","failed"],waiting:["connecting","permanentlyClosed"],connecting:["open","permanentlyClosing","impermanentlyClosing","waiting"],open:["connected","permanentlyClosing","impermanentlyClosing","waiting"],connected:["permanentlyClosing","waiting"],impermanentlyClosing:["waiting","permanentlyClosing"],permanentlyClosing:["permanentlyClosed"],permanentlyClosed:["waiting",
|
||||
"failed"],failed:["permanentlyClosed"]},g=2E3,f=2E3,h=2E3,s=5*g,t=5*f,u=5*h;a.prototype.connect=function(){!this._machine.is("failed")&&!b.Transport?this._machine.transition("failed"):this._machine.is("initialized")?(c(this),this._machine.transition("waiting")):this._machine.is("waiting")&&this.netInfo.isOnLine()===!0?this._machine.transition("connecting"):this._machine.is("permanentlyClosed")&&(c(this),this._machine.transition("waiting"))};a.prototype.send=function(a){if(this._machine.is("connected")){var b=
|
||||
this;setTimeout(function(){b.socket.send(a)},0);return!0}else return!1};a.prototype.send_event=function(a,c,e){a={event:a,data:c};e&&(a.channel=e);b.debug("Event sent",a);return this.send(JSON.stringify(a))};a.prototype.disconnect=function(){this._machine.is("permanentlyClosed")||(this._machine.is("waiting")||this._machine.is("failed")?this._machine.transition("permanentlyClosed"):this._machine.transition("permanentlyClosing"))};b.Util.extend(a.prototype,b.EventsDispatcher.prototype);this.Pusher.Connection=
|
||||
a}).call(this);
|
||||
(function(){Pusher.Channels=function(){this.channels={}};Pusher.Channels.prototype={add:function(a,b){var c=this.find(a);c||(c=Pusher.Channel.factory(a,b),this.channels[a]=c);return c},find:function(a){return this.channels[a]},remove:function(a){delete this.channels[a]},disconnect:function(){for(var a in this.channels)this.channels[a].disconnect()}};Pusher.Channel=function(a,b){var c=this;Pusher.EventsDispatcher.call(this,function(b){Pusher.debug("No callbacks on "+a+" for "+b)});this.pusher=b;this.name=
|
||||
a;this.subscribed=!1;this.bind("pusher_internal:subscription_succeeded",function(a){c.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(a,b,c){return c(!1,{})},trigger:function(a,b){return this.pusher.send_event(a,b,this.name)}};Pusher.Util.extend(Pusher.Channel.prototype,Pusher.EventsDispatcher.prototype);
|
||||
Pusher.Channel.PrivateChannel={authorize:function(a,b,c){var g=this;return(new Pusher.Channel.Authorizer(this,Pusher.channel_auth_transport,b)).authorize(a,function(a,b){a||g.emit("pusher_internal:authorized",b);c(a,b)})}};Pusher.Channel.PresenceChannel={init:function(){this.members=new c(this)},onSubscriptionSucceeded:function(){this.subscribed=!0}};var c=function(a){var b=this,c=function(){this._members_map={};this.count=0;this.me=null};c.call(this);a.bind("pusher_internal:authorized",function(c){var e=
|
||||
JSON.parse(c.channel_data);a.bind("pusher_internal:subscription_succeeded",function(c){b._members_map=c.presence.hash;b.count=c.presence.count;b.me=b.get(e.user_id);a.emit("pusher:subscription_succeeded",b)})});a.bind("pusher_internal:member_added",function(c){b.get(c.user_id)===null&&b.count++;b._members_map[c.user_id]=c.user_info;a.emit("pusher:member_added",b.get(c.user_id))});a.bind("pusher_internal:member_removed",function(c){var e=b.get(c.user_id);e&&(delete b._members_map[c.user_id],b.count--,
|
||||
a.emit("pusher:member_removed",e))});a.bind("pusher_internal:disconnected",function(){c.call(b)})};c.prototype={each:function(a){for(var b in this._members_map)a(this.get(b))},get:function(a){return this._members_map.hasOwnProperty(a)?{id:a,info:this._members_map[a]}:null}};Pusher.Channel.factory=function(a,b){var c=new Pusher.Channel(a,b);a.indexOf("private-")===0?Pusher.Util.extend(c,Pusher.Channel.PrivateChannel):a.indexOf("presence-")===0&&(Pusher.Util.extend(c,Pusher.Channel.PrivateChannel),
|
||||
Pusher.Util.extend(c,Pusher.Channel.PresenceChannel));c.init();return c}}).call(this);
|
||||
(function(){Pusher.Channel.Authorizer=function(c,a,b){this.channel=c;this.type=a;this.authOptions=(b||{}).auth||{}};Pusher.Channel.Authorizer.prototype={composeQuery:function(c){var c="&socket_id="+encodeURIComponent(c)+"&channel_name="+encodeURIComponent(this.channel.name),a;for(a in this.authOptions.params)c+="&"+encodeURIComponent(a)+"="+encodeURIComponent(this.authOptions.params[a]);return c},authorize:function(c,a){return Pusher.authorizers[this.type].call(this,c,a)}};Pusher.auth_callbacks={};
|
||||
Pusher.authorizers={ajax:function(c,a){var b;b=Pusher.XHR?new Pusher.XHR:window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");b.open("POST",Pusher.channel_auth_endpoint,!0);b.setRequestHeader("Content-Type","application/x-www-form-urlencoded");for(var e in this.authOptions.headers)b.setRequestHeader(e,this.authOptions.headers[e]);b.onreadystatechange=function(){if(b.readyState==4)if(b.status==200){var c,e=!1;try{c=JSON.parse(b.responseText),e=!0}catch(h){a(!0,"JSON returned from webapp was invalid, yet status code was 200. Data was: "+
|
||||
b.responseText)}e&&a(!1,c)}else Pusher.warn("Couldn't get auth info from your webapp",b.status),a(!0,b.status)};b.send(this.composeQuery(c));return b},jsonp:function(c,a){this.authOptions.headers!==void 0&&Pusher.warn("Warn","To send headers with the auth request, you must use AJAX, rather than JSONP.");var b=document.createElement("script");Pusher.auth_callbacks[this.channel.name]=function(b){a(!1,b)};b.src=Pusher.channel_auth_endpoint+"?callback="+encodeURIComponent("Pusher.auth_callbacks['"+this.channel.name+
|
||||
"']")+this.composeQuery(c);var e=document.getElementsByTagName("head")[0]||document.documentElement;e.insertBefore(b,e.firstChild)}}}).call(this);
|
||||
var _require=function(){function c(a,c){document.addEventListener?a.addEventListener("load",c,!1):a.attachEvent("onreadystatechange",function(){(a.readyState=="loaded"||a.readyState=="complete")&&c()})}function a(a,e){var g=document.getElementsByTagName("head")[0],f=document.createElement("script");f.setAttribute("src",a);f.setAttribute("type","text/javascript");f.setAttribute("async",!0);c(f,function(){e()});g.appendChild(f)}return function(b,c){for(var g=0,f=0;f<b.length;f++)a(b[f],function(){b.length==
|
||||
++g&&setTimeout(c,0)})}}();
|
||||
(function(){!window.WebSocket&&window.MozWebSocket&&(window.WebSocket=window.MozWebSocket);if(window.WebSocket)Pusher.Transport=window.WebSocket,Pusher.TransportType="native";var c=(document.location.protocol=="http:"?Pusher.cdn_http:Pusher.cdn_https)+Pusher.VERSION,a=[];window.JSON||a.push(c+"/json2"+Pusher.dependency_suffix+".js");if(!window.WebSocket)window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=!0,a.push(c+"/flashfallback"+Pusher.dependency_suffix+".js");var b=function(){return window.WebSocket?function(){Pusher.ready()}:
|
||||
function(){window.WebSocket?(Pusher.Transport=window.WebSocket,Pusher.TransportType="flash",window.WEB_SOCKET_SWF_LOCATION=c+"/WebSocketMain.swf",WebSocket.__addTask(function(){Pusher.ready()}),WebSocket.__initialize()):(Pusher.Transport=null,Pusher.TransportType="none",Pusher.ready())}}(),e=function(a){var b=function(){document.body?a():setTimeout(b,0)};b()},g=function(){e(b)};a.length>0?_require(a,g):g()})();
|
||||
/*
|
||||
* timeago: a jQuery plugin, version: 0.9.2 (2010-09-14)
|
||||
* @requires jQuery v1.2.3 or later
|
||||
|
|
Loading…
Reference in New Issue
Block a user