diff --git a/gulp/build.js b/gulp/build.js
index 105c7ed..2210c2e 100644
--- a/gulp/build.js
+++ b/gulp/build.js
@@ -30,7 +30,7 @@ gulp.task('styles', function() {
gulp.task('copy', function() {
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'));
});
diff --git a/src/bridger.js b/src/bridger.js
new file mode 100644
index 0000000..e69de29
diff --git a/src/index.html b/src/index.html
index ee8eabb..56e71ed 100644
--- a/src/index.html
+++ b/src/index.html
@@ -4,7 +4,7 @@
-
TestMVC
+ Train Times
diff --git a/src/js/app.js b/src/js/app.js
index 7239008..aab769e 100644
--- a/src/js/app.js
+++ b/src/js/app.js
@@ -7,6 +7,7 @@ const { RouteModel, RouteView } = require('./route');
(function () {
let offline = false;
+ const bridger = new Worker('bridger.js');
const $snackbar = $('#snackbar');
const app = {
@@ -51,12 +52,12 @@ const { RouteModel, RouteView } = require('./route');
}
};
- if ('serviceWorker' in navigator)
+ /*if ('serviceWorker' in navigator)
navigator.serviceWorker
.register('./service-worker.js')
.then(function() {
console.log('Service Worker Registered');
- });
+ });*/
app.createViews();
})();
diff --git a/src/js/route.js b/src/js/route.js
index 2194b37..4adef1a 100644
--- a/src/js/route.js
+++ b/src/js/route.js
@@ -112,14 +112,16 @@ const RouteView = Backbone.View.extend({
console.log(route);
- let ws = `${route.locationName} TO ${route.filterLocationName}
+ const thead = `${route.locationName} TO ${route.filterLocationName}
- Destination |
- Time |
- Status |
- Platform |
+ Destination |
+ Time |
+ Status |
+ Platform |
+
`;
+ let ws = '';
const services = [];
if (typeof route.trainServices === 'object' && route.trainServices !== null)
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' });
if (!item.isCancelled)
ws = `${ws }${dest.locationName} ${via} |
- ${time} |
- ${status} |
- ${platform} |
+ ${time} |
+ ${status} |
+ ${platform} |
`;
else
ws = `${ws }${dest.locationName} ${via} | ${time} |
@@ -155,7 +157,7 @@ const RouteView = Backbone.View.extend({
ws = `${ws }
🚌 ${dest.locationName} ${via} | ${time} | ${status} | ${platform} |
`;
}
- ws = `${ws }
`;
+ ws = `${thead}${ws}`;
this.$traintext.empty().html(ws);
this.$traintext.removeClass('mui--hide').addClass('mui--show');
},
diff --git a/src/js/train.js b/src/js/train.js
index 05057ae..4d6c132 100644
--- a/src/js/train.js
+++ b/src/js/train.js
@@ -61,51 +61,12 @@ const TrainModel = Backbone.Model.extend({
self.set('trainData', data);
},
'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)
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.removeClass('delayed').removeClass('ontime').addClass(status);
-
- /*if (visible) {
- let ws = `${route.locationName} TO ${route.filterLocationName}
-
- Destination |
- Time |
- Status |
- Platform |
- `;
-
- 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 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 }${dest.locationName} ${via} |
- ${time} |
- ${status} |
- ${platform} |
-
`;
- else
- ws = `${ws }${dest.locationName} ${via} | ${time} |
- ❌ ${item.cancelReason} |
`;
- }
-
- if (typeof route.busServices === 'object' && route.busServices !== null)
- for (const item of route.busServices) {
- 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 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 }🚌 ${dest.locationName} ${via} | ${time} | ${status} | ${platform} |
`;
- }
-
- ws = `${ws }
`;
- this.$traintext.empty().html(ws);
- this.$traintext.removeClass('mui--hide').addClass('mui--show');
- }
- else
- this.$traintext.removeClass('mui--show').addClass('mui--hide');*/
},
'initView': function () {
const self = this;