updated stations
This commit is contained in:
parent
b77783a88c
commit
7e5b69ebc0
@ -30,7 +30,7 @@ gulp.task('styles', function() {
|
|||||||
|
|
||||||
gulp.task('copy', function() {
|
gulp.task('copy', function() {
|
||||||
gulp.src(['src/img/**/*']).pipe(gulp.dest('live/img'));
|
gulp.src(['src/img/**/*']).pipe(gulp.dest('live/img'));
|
||||||
gulp.src(['src/browserconfig.xml', 'src/manifest.json', 'src/service-worker.js']).pipe(gulp.dest('live'));
|
gulp.src(['src/browserconfig.xml', 'src/manifest.json', 'src/service-worker.js', 'src/bridger.js']).pipe(gulp.dest('live'));
|
||||||
gulp.src(['src/index.html']).pipe(gulp.dest('live'));
|
gulp.src(['src/index.html']).pipe(gulp.dest('live'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
0
src/bridger.js
Normal file
0
src/bridger.js
Normal file
@ -4,7 +4,7 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>TestMVC</title>
|
<title>Train Times</title>
|
||||||
<link href="fonts/fonts.css" rel="stylesheet">
|
<link href="fonts/fonts.css" rel="stylesheet">
|
||||||
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ const { RouteModel, RouteView } = require('./route');
|
|||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
let offline = false;
|
let offline = false;
|
||||||
|
const bridger = new Worker('bridger.js');
|
||||||
const $snackbar = $('#snackbar');
|
const $snackbar = $('#snackbar');
|
||||||
|
|
||||||
const app = {
|
const app = {
|
||||||
@ -51,12 +52,12 @@ const { RouteModel, RouteView } = require('./route');
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if ('serviceWorker' in navigator)
|
/*if ('serviceWorker' in navigator)
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker
|
||||||
.register('./service-worker.js')
|
.register('./service-worker.js')
|
||||||
.then(function() {
|
.then(function() {
|
||||||
console.log('Service Worker Registered');
|
console.log('Service Worker Registered');
|
||||||
});
|
});*/
|
||||||
|
|
||||||
app.createViews();
|
app.createViews();
|
||||||
})();
|
})();
|
||||||
|
@ -112,14 +112,16 @@ const RouteView = Backbone.View.extend({
|
|||||||
|
|
||||||
console.log(route);
|
console.log(route);
|
||||||
|
|
||||||
let ws = `<div class="mui--text-center mui--text-accent">${route.locationName} TO ${route.filterLocationName}</div>
|
const thead = `<div class="mui--text-center mui--text-accent">${route.locationName} TO ${route.filterLocationName}</div>
|
||||||
<table class="mui-table mui-table-bordered">
|
<table class="mui-table mui-table-bordered">
|
||||||
<tr><th>Destination</th>
|
<thead><tr><th>Destination</th>
|
||||||
<th>Time</th>
|
<th>Time</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Platform</th></tr>
|
<th>Platform</th></tr></thead>
|
||||||
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
let ws = '';
|
||||||
const services = [];
|
const services = [];
|
||||||
if (typeof route.trainServices === 'object' && route.trainServices !== null)
|
if (typeof route.trainServices === 'object' && route.trainServices !== null)
|
||||||
for (const item of route.trainServices) {
|
for (const item of route.trainServices) {
|
||||||
@ -134,9 +136,9 @@ const RouteView = Backbone.View.extend({
|
|||||||
services.push({ 'location':dest.locationName, 'time':time, 'status':status, 'platform':platform, 'cancel':item.cancelReason, 'type':'train' });
|
services.push({ 'location':dest.locationName, 'time':time, 'status':status, 'platform':platform, 'cancel':item.cancelReason, 'type':'train' });
|
||||||
if (!item.isCancelled)
|
if (!item.isCancelled)
|
||||||
ws = `${ws }<tr><td>${dest.locationName} ${via}</td>
|
ws = `${ws }<tr><td>${dest.locationName} ${via}</td>
|
||||||
<td>${time}</td>
|
<td class="mui--text-center">${time}</td>
|
||||||
<td class="${statusMode}">${status}</td>
|
<td class="mui--text-center ${statusMode}">${status}</td>
|
||||||
<td>${platform}</td>
|
<td class="mui--text-center">${platform}</td>
|
||||||
</tr>`;
|
</tr>`;
|
||||||
else
|
else
|
||||||
ws = `${ws }<tr><td>${dest.locationName} ${via}</td><td>${time}</td>
|
ws = `${ws }<tr><td>${dest.locationName} ${via}</td><td>${time}</td>
|
||||||
@ -155,7 +157,7 @@ const RouteView = Backbone.View.extend({
|
|||||||
ws = `${ws }<tr><td>🚌 ${dest.locationName} ${via}</td><td>${time}</td><td>${status}</td><td>${platform}</td></tr>`;
|
ws = `${ws }<tr><td>🚌 ${dest.locationName} ${via}</td><td>${time}</td><td>${status}</td><td>${platform}</td></tr>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws = `${ws }</table>`;
|
ws = `${thead}${ws}</table>`;
|
||||||
this.$traintext.empty().html(ws);
|
this.$traintext.empty().html(ws);
|
||||||
this.$traintext.removeClass('mui--hide').addClass('mui--show');
|
this.$traintext.removeClass('mui--hide').addClass('mui--show');
|
||||||
},
|
},
|
||||||
|
@ -61,51 +61,12 @@ const TrainModel = Backbone.Model.extend({
|
|||||||
self.set('trainData', data);
|
self.set('trainData', data);
|
||||||
},
|
},
|
||||||
'error': function (xhr, type) {
|
'error': function (xhr, type) {
|
||||||
/*
|
|
||||||
console.log('ajax error');
|
|
||||||
console.log('readyState', xhr.readyState);
|
|
||||||
console.log('status', xhr.status);
|
|
||||||
console.log(type);
|
|
||||||
*/
|
|
||||||
if (xhr.readyState === 0 && xhr.status === 0)
|
if (xhr.readyState === 0 && xhr.status === 0)
|
||||||
|
|
||||||
bus.trigger('offline');
|
bus.trigger('offline');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
|
||||||
'getRoute': function () {
|
|
||||||
const url = this.get('routeUrl');
|
|
||||||
const self = this;
|
|
||||||
|
|
||||||
if (this.get('visible') === true)
|
|
||||||
this.set('visible', false);
|
|
||||||
else
|
|
||||||
$.ajax({
|
|
||||||
'type': 'GET',
|
|
||||||
'url': url,
|
|
||||||
'data': '',
|
|
||||||
'dataType': 'json',
|
|
||||||
|
|
||||||
'timeout': 10000,
|
|
||||||
'headers': {
|
|
||||||
'Access-Control-Allow-Origin': '*',
|
|
||||||
'Access-Control-Allow-Methods': 'PUT, GET, POST, DELETE, OPTIONS',
|
|
||||||
'Access-Control-Allow-Headers': 'Content-Type'
|
|
||||||
|
|
||||||
},
|
|
||||||
'success': function (data) {
|
|
||||||
// getTrainsCB(data);
|
|
||||||
// console.log('Got', data);
|
|
||||||
|
|
||||||
self.set('route', data);
|
|
||||||
self.set('visible', true);
|
|
||||||
},
|
|
||||||
'error': function (xhr, type) {
|
|
||||||
console.error('ajax error');
|
|
||||||
/*console.error(xhr);
|
|
||||||
console.error(type);*/
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -136,55 +97,6 @@ const TrainView = Backbone.View.extend({
|
|||||||
|
|
||||||
this.$button.html(output);
|
this.$button.html(output);
|
||||||
this.$button.removeClass('delayed').removeClass('ontime').addClass(status);
|
this.$button.removeClass('delayed').removeClass('ontime').addClass(status);
|
||||||
|
|
||||||
/*if (visible) {
|
|
||||||
let ws = `<div class="mui--text-center mui--text-accent">${route.locationName} TO ${route.filterLocationName}</div>
|
|
||||||
<table class="mui-table mui-table-bordered">
|
|
||||||
<tr><th>Destination</th>
|
|
||||||
<th>Time</th>
|
|
||||||
<th>Status</th>
|
|
||||||
<th>Platform</th></tr>
|
|
||||||
`;
|
|
||||||
|
|
||||||
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 status = item.eta !== null ? item.eta : item.etd;
|
|
||||||
|
|
||||||
services.push({ 'location':dest.locationName, 'time':time, 'status':status, 'platform':platform, 'cancel':item.cancelReason, 'type':'train' });
|
|
||||||
if (!item.isCancelled)
|
|
||||||
ws = `${ws }<tr><td>${dest.locationName} ${via}</td>
|
|
||||||
<td>${time}</td>
|
|
||||||
<td>${status}</td>
|
|
||||||
<td>${platform}</td>
|
|
||||||
</tr>`;
|
|
||||||
else
|
|
||||||
ws = `${ws }<tr><td>${dest.locationName} ${via}</td><td>${time}</td>
|
|
||||||
<td colspan="2">❌ ${item.cancelReason}</td></tr>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof route.busServices === 'object' && route.busServices !== null)
|
|
||||||
for (const item of route.busServices) {
|
|
||||||
const dest = item.destination[0];
|
|
||||||
const via = dest.via !== null ? `<em>${dest.via}</em>` : '';
|
|
||||||
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;
|
|
||||||
services.push({ 'location':dest.locationName, 'time':time, 'status':status, 'platform':platform, 'cancel':item.cancelReason, 'type':'bus' });
|
|
||||||
|
|
||||||
ws = `${ws }<tr><td>🚌 ${dest.locationName} ${via}</td><td>${time}</td><td>${status}</td><td>${platform}</td></tr>`;
|
|
||||||
}
|
|
||||||
|
|
||||||
ws = `${ws }</table>`;
|
|
||||||
this.$traintext.empty().html(ws);
|
|
||||||
this.$traintext.removeClass('mui--hide').addClass('mui--show');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.$traintext.removeClass('mui--show').addClass('mui--hide');*/
|
|
||||||
},
|
},
|
||||||
'initView': function () {
|
'initView': function () {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
Loading…
Reference in New Issue
Block a user