Added glc to london

added alert messages
added some delay messages, i hope.
This commit is contained in:
Martin Donnelly 2017-12-28 12:06:19 +00:00
parent c932fef30b
commit e889947777
3 changed files with 31 additions and 16 deletions

View File

@ -58,7 +58,7 @@ li {
}
.down, .delayed, .trendDown {
color: mui-color('red') !important;
color: $mui-text-danger; !important;
}
.nochange {

View File

@ -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':{}

View File

@ -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 = `<div class="mui--text-center mui--text-accent">${route.locationName} TO ${route.filterLocationName}</div>
<table class="mui-table mui-table-bordered">
<thead><tr><th>Destination</th>
<th>Time</th>
<th>Status</th>
<th>Platform</th></tr></thead>
`;
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 ? `<em class="mui--text-accent">${dest.via}</em>` : '';
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 : `<em class="mui--text-accent-secondary">D</em> ${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) ? '<tr><td colspan="4" class="mui--bg-danger mui--text-white" style="padding-bottom:2px;">${item.delayReason}</td></tr>' : '';
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({
<td class="mui--text-center">${time}</td>
<td class="mui--text-center ${statusMode}">${status}</td>
<td class="mui--text-center">${platform}</td>
</tr>`;
</tr>${delayReason}`;
else
ws = `${ws }<tr><td>${dest.locationName} ${via}</td><td>${time}</td>
<td colspan="2" class="delayed"> ${item.cancelReason}</td></tr>`;
@ -157,6 +152,24 @@ const RouteView = Backbone.View.extend({
ws = `${ws }<tr><td>🚌 ${dest.locationName} ${via}</td><td>${time}</td><td>${status}</td><td>${platform}</td></tr>`;
}
let nrMessages = '';
if (typeof route.nrccMessages === 'object' && route.nrccMessages !== null)
// we have national rail messages so put a box at the top
// <div class="mui--bg-danger .mui--text-white" style="height:10px;"></div>
for (const item of route.nrccMessages) {
const msg = item.value;
nrMessages = `${nrMessages}<div class="mui--bg-danger mui--text-white" style="padding:2px;">${msg}</div>`;
}
const thead = `<div class="mui--text-center mui--text-accent">${route.locationName} TO ${route.filterLocationName}</div>
${nrMessages}
<table class="mui-table mui-table-bordered">
<thead><tr><th>Destination</th>
<th>Time</th>
<th>Status</th>
<th>Platform</th></tr></thead>`;
ws = `${thead}${ws}</table>`;
this.$traintext.empty().html(ws);
this.$traintext.removeClass('mui--hide').addClass('mui--show');