diff --git a/app/_css/app.css b/app/_css/app.css index 1b091aed..5aa26be8 100644 --- a/app/_css/app.css +++ b/app/_css/app.css @@ -6915,7 +6915,7 @@ circle.get { fill: #ffcc66; } -path.p2p { +path.connection { fill: none; stroke-width: 1; stroke: white; diff --git a/app/js/helpers.js b/app/js/helpers.js index 678fbab1..809dd8e9 100644 --- a/app/js/helpers.js +++ b/app/js/helpers.js @@ -24,7 +24,7 @@ function makeLogger(prefix) { }; } -//var log = makeLogger('helpers'); +var log = makeLogger('helpers'); function randomChoice(collection) { if (_.isArray(collection)) { @@ -54,7 +54,12 @@ function deleteByPath(obj, path) { path = path.split('.'); var name = path[0], i = 0, l = path.length; for (; i maxGiveGet) { + maxGiveGet = npeers.giveGet; + countryOpacityScale.domain([0, maxGiveGet]); + _.forEach(countries, updateFill); + } else { + updateFill(country); + } }); }); }, true); diff --git a/app/partials/footer.html b/app/partials/footer.html index e4a050a4..140b4487 100644 --- a/app/partials/footer.html +++ b/app/partials/footer.html @@ -16,10 +16,10 @@ {{ model.settings.email }} · {{ model.connectivity.gtalk }} to Google Talk · XXX Lantern friends online · - connected to {{ model.connectivity.peers.lifetime.length }} peers in {{ ncountries || 'XXX' }} countries · + connected to {{ model.connectivity.peers.current.length }} peers in {{ ncountries || 'XXX' }} countries · {{ model.transfers.bpsUp }} M/s up · {{ model.transfers.bpsDn }} M/s down · - {{ model.transfers.bytesTotal || '0B' }} lifetime + {{ model.transfers.bytesTotal || 'XXX M' }} lifetime {{ model.connectivity.gtalk }} to Google Talk · diff --git a/app/partials/vis.html b/app/partials/vis.html index 792838fb..17a774ea 100644 --- a/app/partials/vis.html +++ b/app/partials/vis.html @@ -1,13 +1,13 @@ - {{ d.alpha2 | i18n }}: {{ model.countries[d.alpha2].nusers.online || 0 }} users online - + {{ d.alpha2 | i18n }}: {{ model.countries[d.alpha2].npeers.online.giveGet || 0 }} peers online, {{ model.countries[d.alpha2].npeers.online.give || 0 }} in Give Mode, {{ model.countries[d.alpha2].npeers.online.get || 0 }} in Get Mode + - + {{ peer | prettyUser }} diff --git a/mock/bayeux_backend.js b/mock/bayeux_backend.js index ab560f78..4507e2ae 100644 --- a/mock/bayeux_backend.js +++ b/mock/bayeux_backend.js @@ -36,6 +36,16 @@ BayeuxBackend.prototype.resetModel = function() { merge(this.model, {bayeuxProtocol: BayeuxBackend.VERSION}, 'version.installed'); }; +BayeuxBackend.prototype.publishMultiple = function(state) { + if (_.isEmpty(this._clients)) { + //log('[publishSync]', 'no clients to publish to'); + return; + } + var data = {state: state}; + log('[publishMultiple]\n', data); + this._bayeux._server._engine.publish({channel: MODEL_SYNC_CHANNEL, data: data}); +}; + BayeuxBackend.prototype.publishSync = function(path, delete_) { if (_.isEmpty(this._clients)) { //log('[publishSync]', 'no clients to publish to'); @@ -48,7 +58,7 @@ BayeuxBackend.prototype.publishSync = function(path, delete_) { } else { data.value = getByPath(this.model, path); } - //log('[publishSync]\n', data); + log('[publishSync]\n', data); this._bayeux._server._engine.publish({channel: MODEL_SYNC_CHANNEL, data: data}); //this._bayeux.getClient().publish({ // XXX why doesn't this work? }; diff --git a/mock/http_api.js b/mock/http_api.js index 69c9a597..cf19f074 100644 --- a/mock/http_api.js +++ b/mock/http_api.js @@ -109,6 +109,13 @@ ApiServlet.prototype.updateModel = function(state, publish) { } }; +ApiServlet.prototype.updateMultiple = function(state, publish) { + for (var path in state) { + merge(this.model, state[path], path); + } + this._bayeuxBackend.publishMultiple.call(this._bayeuxBackend, state); +}; + /* * Show next modal that should be shown, including possibly MODAL.none. * Needed because some modals can be skipped if the user is diff --git a/mock/scenarios.js b/mock/scenarios.js index d4f4cc8f..bcd0f2c0 100644 --- a/mock/scenarios.js +++ b/mock/scenarios.js @@ -363,13 +363,21 @@ exports.SCENARIOS = { func: function() { var this_ = this; setInterval(function() { - var randomCountry = randomChoice(this_.model.countries), - stats = this_.model.countries[randomCountry], - nusersOnlineNow = getByPath(stats, 'nusers.online', _.random(0, 1000)), - nusersOnlineNext = Math.max(0, nusersOnlineNow + _.random(-50, 50)), + var country = randomChoice(this_.model.countries), + stats = this_.model.countries[country], + censors = stats.censors, + npeersOnlineGive = getByPath(stats, 'npeers.online.give', + censors ? 0 : _.random(0, 1000)), + npeersOnlineGet = getByPath(stats, 'npeers.online.get', + censors ? _.random(0, 1000) :_.random(0, 500)), + npeersOnlineGive_ = censors ? npeersOnlineGive : + Math.max(0, npeersOnlineGive + _.random(-50, 50)), + npeersOnlineGet_ = Math.max(0, npeersOnlineGet + _.random(-50, 50)), update = {}; - update['countries.'+randomCountry+'.nusers.online'] = nusersOnlineNext; - this_.updateModel(update, true); + update['countries.'+country+'.npeers.online.give'] = npeersOnlineGive_; + update['countries.'+country+'.npeers.online.get'] = npeersOnlineGet_; + update['countries.'+country+'.npeers.online.giveGet'] = npeersOnlineGive_ + npeersOnlineGet_; + this_.updateMultiple(update); }, 1000); } } diff --git a/sass/_vis.sass b/sass/_vis.sass index 2d9f6a52..0f00c7c9 100644 --- a/sass/_vis.sass +++ b/sass/_vis.sass @@ -12,7 +12,7 @@ circle.give circle.get fill: $getModeColor -path.p2p +path.connection fill: none stroke-width: 1 stroke: #fff