App should be more aware of focus being regained and update if it's been an hour.
This commit is contained in:
parent
1cc2a8afe3
commit
e6ce05cfda
@ -2,7 +2,6 @@ const FeedMe = require('feedme');
|
||||
const fecha = require('fecha');
|
||||
const request = require('request');
|
||||
const http = require('http');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const { reduceArticle } = require('./reducers/euronews');
|
||||
|
||||
|
@ -395,83 +395,4 @@ li {
|
||||
height:66px;
|
||||
}
|
||||
|
||||
|
||||
#weatherP {
|
||||
background-size: cover;
|
||||
color:white;
|
||||
font-family: 'Roboto';
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
.weatherDay {
|
||||
background-image: url(../gfx/bg_morning.jpg);
|
||||
}
|
||||
|
||||
.weatherEvening {
|
||||
background-image: url(../gfx/bg_evening.jpg);
|
||||
}
|
||||
|
||||
.cloudy_n {
|
||||
background-image: url(../gfx/cloudy_n.jpg);
|
||||
}
|
||||
|
||||
.cloudy_d {
|
||||
background-image: url(../gfx/cloudy_d.jpg);
|
||||
}
|
||||
|
||||
.clear_d {
|
||||
background-image: url(../gfx/clear_d.jpg);
|
||||
}
|
||||
|
||||
.clear_n {
|
||||
background-image: url(../gfx/clear_n.jpg);
|
||||
}
|
||||
|
||||
.foggy_d {
|
||||
background-image: url(../gfx/foggy_d.jpg);
|
||||
}
|
||||
|
||||
.foggy_n {
|
||||
background-image: url(../gfx/foggy_n.jpg);
|
||||
}
|
||||
|
||||
.rain_d {
|
||||
background-image: url(../gfx/rain_d.jpg);
|
||||
}
|
||||
|
||||
.rain_n {
|
||||
background-image: url(../gfx/rain_n.jpg);
|
||||
}
|
||||
|
||||
.snow_d {
|
||||
background-image: url(../gfx/snow_d.jpg);
|
||||
}
|
||||
|
||||
.snow_n {
|
||||
background-image: url(../gfx/snow_n.jpg);
|
||||
}
|
||||
|
||||
.storm_d {
|
||||
background-image: url(../gfx/storm_d.jpg);
|
||||
}
|
||||
|
||||
.storm_n {
|
||||
background-image: url(../gfx/storm_n.jpg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.glassy {
|
||||
background-color: rgba(31, 28, 23, 0.4);
|
||||
-webkit-backdrop-filter: blur(5px);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.animTrans {
|
||||
-webkit-transition: all 1s linear;
|
||||
transition : all 1s linear;
|
||||
-moz-transition : all 1s linear;
|
||||
-webkit-transition: all 1s linear;
|
||||
-o-transition : all 1s linear;
|
||||
}
|
||||
@import "./src/css/weather";
|
||||
|
80
src/css/weather.scss
Normal file
80
src/css/weather.scss
Normal file
@ -0,0 +1,80 @@
|
||||
|
||||
#weatherP {
|
||||
background-size: cover;
|
||||
color:white;
|
||||
font-family: 'Roboto';
|
||||
font-weight: 100;
|
||||
}
|
||||
|
||||
.weatherDay {
|
||||
background-image: url(../gfx/bg_morning.jpg);
|
||||
}
|
||||
|
||||
.weatherEvening {
|
||||
background-image: url(../gfx/bg_evening.jpg);
|
||||
}
|
||||
|
||||
.cloudy_n {
|
||||
background-image: url(../gfx/cloudy_n.jpg);
|
||||
}
|
||||
|
||||
.cloudy_d {
|
||||
background-image: url(../gfx/cloudy_d.jpg);
|
||||
}
|
||||
|
||||
.clear_d {
|
||||
background-image: url(../gfx/clear_d.jpg);
|
||||
}
|
||||
|
||||
.clear_n {
|
||||
background-image: url(../gfx/clear_n.jpg);
|
||||
}
|
||||
|
||||
.foggy_d {
|
||||
background-image: url(../gfx/foggy_d.jpg);
|
||||
}
|
||||
|
||||
.foggy_n {
|
||||
background-image: url(../gfx/foggy_n.jpg);
|
||||
}
|
||||
|
||||
.rain_d {
|
||||
background-image: url(../gfx/rain_d.jpg);
|
||||
}
|
||||
|
||||
.rain_n {
|
||||
background-image: url(../gfx/rain_n.jpg);
|
||||
}
|
||||
|
||||
.snow_d {
|
||||
background-image: url(../gfx/snow_d.jpg);
|
||||
}
|
||||
|
||||
.snow_n {
|
||||
background-image: url(../gfx/snow_n.jpg);
|
||||
}
|
||||
|
||||
.storm_d {
|
||||
background-image: url(../gfx/storm_d.jpg);
|
||||
}
|
||||
|
||||
.storm_n {
|
||||
background-image: url(../gfx/storm_n.jpg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
.glassy {
|
||||
background-color: rgba(31, 28, 23, 0.4);
|
||||
-webkit-backdrop-filter: blur(5px);
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
.animTrans {
|
||||
-webkit-transition: all 1s linear;
|
||||
transition : all 1s linear;
|
||||
-moz-transition : all 1s linear;
|
||||
-webkit-transition: all 1s linear;
|
||||
-o-transition : all 1s linear;
|
||||
}
|
@ -11,7 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
const CACHE_VERSION = { 'version': '0.0.166' };
|
||||
const CACHE_VERSION = { 'version': '0.0.205' };
|
||||
const dataCacheName = 'jubileeData-v1';
|
||||
const cacheName = 'jubilee-final-1';
|
||||
const filesToCache = [
|
||||
|
@ -44,7 +44,7 @@ const GreetView = Backbone.View.extend({
|
||||
},
|
||||
'updateLocation': function(l) {
|
||||
console.log('>> Location has changed...');
|
||||
console.log(JSON.stringify(l.changed));
|
||||
// console.log(JSON.stringify(l.changed));
|
||||
|
||||
if (l.has('atHome')) {
|
||||
const location = l.toJSON();
|
||||
|
@ -5,6 +5,7 @@ const request = require('request');
|
||||
const { get } = require('lodash');
|
||||
const { reduceNearby } = require('./libs/reducers');
|
||||
const { toHour } = require('./libs/utils');
|
||||
const TimeFormat = require('hh-mm-ss');
|
||||
|
||||
const { FSDetailView } = require('./Foursquare');
|
||||
|
||||
@ -40,12 +41,17 @@ const fsItemView = Backbone.View.extend({
|
||||
});
|
||||
|
||||
const NearbyModel = Backbone.Model.extend({
|
||||
'initialize': function() {
|
||||
'defaults' : function (obj) {
|
||||
// return a new object
|
||||
return {
|
||||
'update' : new Date().getTime()
|
||||
};
|
||||
}, 'initialize': function() {
|
||||
this.fsCollection = fsCollection;
|
||||
this.timerID = 0;
|
||||
this.tick();
|
||||
this.set('totalResults', 0);
|
||||
this.listenTo(this, 'change:llFixed change:section', this.onChange);
|
||||
this.listenTo(this, 'change:llFixed change:section change:update', this.onChange);
|
||||
},
|
||||
'tick': function() {
|
||||
const hour = parseInt((new Date()).getHours().toString(), 10);
|
||||
@ -88,8 +94,15 @@ const NearbyModel = Backbone.Model.extend({
|
||||
newItems.push(reduceNearby(item));
|
||||
|
||||
this.fsCollection.reset(newItems);
|
||||
this.logUpdate();
|
||||
}
|
||||
}.bind(this));
|
||||
}, 'logUpdate': function() {
|
||||
console.log('Nearby logging:');
|
||||
|
||||
const time = new Date().getTime() ;
|
||||
|
||||
this.set('time', time);
|
||||
}
|
||||
});
|
||||
|
||||
@ -107,6 +120,7 @@ const NearbyView = Backbone.View.extend({
|
||||
this.$nearby = $('#nearby');
|
||||
|
||||
this.fsCollection.bind('reset', this.render, this);
|
||||
this.eventBus.on('focused', this.focused, this);
|
||||
},
|
||||
'events': {
|
||||
'click .itemRow': 'doClick'
|
||||
@ -146,6 +160,15 @@ const NearbyView = Backbone.View.extend({
|
||||
console.log(id);
|
||||
|
||||
const fsdetail = new FSDetailView({ 'fsID':id });
|
||||
}, 'focused': function() {
|
||||
console.log('>> Nearby received focus msg');
|
||||
const now = new Date().getTime();
|
||||
const since = now - this.model.get('time');
|
||||
|
||||
console.log(`Nearby was last updated: ${TimeFormat.fromMs(since, 'hh:mm')} ago`);
|
||||
|
||||
if (since > (60 * 1000 * 60) )
|
||||
this.model.set('update', now);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -4,6 +4,7 @@ const Backbone = require('backbone');
|
||||
const request = require('request');
|
||||
const { get } = require('lodash');
|
||||
const { reduceEuronews } = require('./libs/reducers');
|
||||
const TimeFormat = require('hh-mm-ss');
|
||||
|
||||
const NewsItem = Backbone.Model.extend({
|
||||
|
||||
@ -109,6 +110,8 @@ const NewsView = Backbone.View.extend({
|
||||
});
|
||||
|
||||
this.newsCollection.bind('reset', this.render, this);
|
||||
|
||||
this.eventBus.on('focused', this.focused, this);
|
||||
},
|
||||
'attributes': function() {
|
||||
return {
|
||||
@ -135,6 +138,15 @@ const NewsView = Backbone.View.extend({
|
||||
const id = get(d, 'currentTarget.dataset.guid', '');
|
||||
console.log(id);
|
||||
this.eventBus.trigger('showNews', id);
|
||||
}, 'focused': function() {
|
||||
console.log('>> News received focus msg');
|
||||
const now = new Date().getTime();
|
||||
const since = now - this.model.get('time');
|
||||
|
||||
console.log(`News was last updated: ${TimeFormat.fromMs(since, 'hh:mm')} ago`);
|
||||
|
||||
if (since > (60 * 1000 * 60) )
|
||||
this.model.set('update', now);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -5,6 +5,7 @@ const request = require('request');
|
||||
const { get } = require('lodash');
|
||||
const { reduceOpenWeather } = require('./libs/reducers');
|
||||
const { distance } = require('./libs/utils');
|
||||
const TimeFormat = require('hh-mm-ss');
|
||||
|
||||
const weatherItem = Backbone.Model.extend({
|
||||
|
||||
@ -157,6 +158,7 @@ const WeatherView = Backbone.View.extend({
|
||||
});*/
|
||||
|
||||
this.wCollection.bind('reset', this.render, this);
|
||||
this.eventBus.on('focused', this.focused, this);
|
||||
},
|
||||
'attributes': function() {
|
||||
return {
|
||||
@ -194,6 +196,16 @@ const WeatherView = Backbone.View.extend({
|
||||
const llFixed = this.location.get('llFixed');
|
||||
console.log(llFixed);
|
||||
this.eventBus.trigger('showForecast', llFixed);
|
||||
}, 'focused': function() {
|
||||
console.log('>> Weather received focus msg');
|
||||
const now = new Date().getTime();
|
||||
const log = this.model.get('log');
|
||||
const since = now - log.time;
|
||||
|
||||
console.log(`Weather was last updated: ${TimeFormat.fromMs(since, 'hh:mm')} ago`);
|
||||
|
||||
if (since > (60 * 1000 * 60) )
|
||||
this.model.set('update', now);
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -119,6 +119,7 @@ const WeatherAlertView = Backbone.View.extend({
|
||||
// this.model.bind('change', this.render, this);
|
||||
this.location.bind('change:llShort', this.updateLocation, this);
|
||||
this.model.bind('change:alert', this.render, this);
|
||||
this.eventBus.on('focused', this.focused, this);
|
||||
},
|
||||
'template': _.template(`
|
||||
<div>
|
||||
@ -164,6 +165,16 @@ const WeatherAlertView = Backbone.View.extend({
|
||||
this.$el.html(this.template(alert[0]));
|
||||
this.$el.parent().show();
|
||||
}
|
||||
}, 'focused': function() {
|
||||
console.log('>> WeatherAlert received focus msg');
|
||||
const now = new Date().getTime();
|
||||
const log = this.model.get('log');
|
||||
const since = now - log.time;
|
||||
|
||||
console.log(`WeatherAlert was last updated: ${TimeFormat.fromMs(since, 'hh:mm')} ago`);
|
||||
|
||||
if (since > (60 * 1000 * 60) )
|
||||
this.model.set('update', now);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -71,4 +71,9 @@ else
|
||||
app.news = new NewsView({ 'model': new NewsModel(), 'eventBus': app.eventBus, 'el':'#news' });
|
||||
|
||||
app.byMe = new ByMeView({ 'model': new ByMeModel(), 'eventBus': app.eventBus, 'location': app.locationModel, 'el':'#byme' });
|
||||
|
||||
window.addEventListener('focus', () => {
|
||||
console.log('Window has focus...');
|
||||
app.eventBus.trigger('focused');
|
||||
});
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user