diff --git a/server/euronews.js b/server/euronews.js index 4b94cec..ab6acfc 100644 --- a/server/euronews.js +++ b/server/euronews.js @@ -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'); diff --git a/src/css/custom.scss b/src/css/custom.scss index 1d01eb9..482a5d3 100644 --- a/src/css/custom.scss +++ b/src/css/custom.scss @@ -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"; diff --git a/src/css/weather.scss b/src/css/weather.scss new file mode 100644 index 0000000..e810090 --- /dev/null +++ b/src/css/weather.scss @@ -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; +} diff --git a/src/service-worker.js b/src/service-worker.js index 503b4bf..53ab840 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -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 = [ diff --git a/src/v1/js/Greet.js b/src/v1/js/Greet.js index 97f541e..6773e3f 100644 --- a/src/v1/js/Greet.js +++ b/src/v1/js/Greet.js @@ -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(); diff --git a/src/v1/js/Nearby.js b/src/v1/js/Nearby.js index 2179ec6..a801151 100644 --- a/src/v1/js/Nearby.js +++ b/src/v1/js/Nearby.js @@ -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); } }); diff --git a/src/v1/js/News.js b/src/v1/js/News.js index c24bcdb..58a9f00 100644 --- a/src/v1/js/News.js +++ b/src/v1/js/News.js @@ -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); } }); diff --git a/src/v1/js/Weather.js b/src/v1/js/Weather.js index 552515a..ed25d17 100644 --- a/src/v1/js/Weather.js +++ b/src/v1/js/Weather.js @@ -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); } }); diff --git a/src/v1/js/WeatherAlert.js b/src/v1/js/WeatherAlert.js index 757edcd..e464982 100644 --- a/src/v1/js/WeatherAlert.js +++ b/src/v1/js/WeatherAlert.js @@ -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(`
@@ -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); } }); diff --git a/src/v1/js/app.js b/src/v1/js/app.js index 5b605e6..66edb84 100644 --- a/src/v1/js/app.js +++ b/src/v1/js/app.js @@ -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'); + }); })();