diff --git a/src/css/custom.scss b/src/css/custom.scss index d8123ea..31e3a5a 100644 --- a/src/css/custom.scss +++ b/src/css/custom.scss @@ -58,7 +58,7 @@ li { } .down, .delayed, .trendDown { - color: mui-color('red') !important; + color: $mui-text-danger; !important; } .nochange { diff --git a/src/js/app.js b/src/js/app.js index 6cd463f..1c55abd 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -16,7 +16,9 @@ const { RouteModel, RouteView } = require('./route'); { 'from': 'glq', 'to': 'dbe' }, { 'from': 'pyg', 'to': 'glc' }, { 'from': 'glc', 'to': 'ptk' }, - { 'from': 'ptk', 'to': 'dbe' } + { 'from': 'ptk', 'to': 'dbe' }, + { 'from': 'glc', 'to': 'eus' }, + { 'from': 'eus', 'to': 'glc' } ], 'views':{} diff --git a/src/js/route.js b/src/js/route.js index 4adef1a..899381e 100644 --- a/src/js/route.js +++ b/src/js/route.js @@ -16,8 +16,10 @@ const RouteModel = Backbone.Model.extend({ this.set('interval', null); this.update(); }, - 'update': function () { + 'update': function (m) { console.log('Route model update'); + console.log(this.changedAttributes()); + console.log(_.keys(this.changedAttributes())); if (!this.get('to')) return; @@ -112,26 +114,19 @@ const RouteView = Backbone.View.extend({ console.log(route); - const thead = `
${route.locationName} TO ${route.filterLocationName}
- - - - - - - `; - let ws = ''; const services = []; if (typeof route.trainServices === 'object' && route.trainServices !== null) for (const item of route.trainServices) { const dest = item.destination[0]; const via = dest.via !== null ? `${dest.via}` : ''; - const platform = item.platform !== null ? item.platform : '💠'; - const time = item.sta !== null ? item.sta : `D ${item.std}`; + const platform = item.platform !== null ? item.platform : '🚉'; + // 🚉 💠 + const time = item.sta !== null ? item.sta : `D ${item.std}`; const status = item.eta !== null ? item.eta : item.etd; - const statusMode = (item.eta.toLowerCase() === 'on time') ? 'ontime' : 'delayed'; + const statusMode = (status.toLowerCase() === 'on time') ? 'ontime' : 'delayed'; + const delayReason = (item.delayReason !== null) ? '' : ''; services.push({ 'location':dest.locationName, 'time':time, 'status':status, 'platform':platform, 'cancel':item.cancelReason, 'type':'train' }); if (!item.isCancelled) @@ -139,7 +134,7 @@ const RouteView = Backbone.View.extend({ - `; + ${delayReason}`; else ws = `${ws }`; @@ -157,6 +152,24 @@ const RouteView = Backbone.View.extend({ ws = `${ws }`; } + let nrMessages = ''; + if (typeof route.nrccMessages === 'object' && route.nrccMessages !== null) + // we have national rail messages so put a box at the top + //
+ for (const item of route.nrccMessages) { + const msg = item.value; + + nrMessages = `${nrMessages}
${msg}
`; + } + + const thead = `
${route.locationName} TO ${route.filterLocationName}
+${nrMessages} +
DestinationTimeStatusPlatform
${item.delayReason}
${time} ${status} ${platform}
${dest.locationName} ${via}${time} ❌ ${item.cancelReason}
🚌 ${dest.locationName} ${via}${time}${status}${platform}
+ + + + `; + ws = `${thead}${ws}
DestinationTimeStatusPlatform
`; this.$traintext.empty().html(ws); this.$traintext.removeClass('mui--hide').addClass('mui--show');