Added stations. updated fonts
This commit is contained in:
parent
8b21f42a25
commit
26ed96dd4b
BIN
fonts/GothamNarrSSm-Bold.otf
Executable file
BIN
fonts/GothamNarrSSm-Bold.otf
Executable file
Binary file not shown.
BIN
fonts/GothamNarrSSm-Book.otf
Executable file
BIN
fonts/GothamNarrSSm-Book.otf
Executable file
Binary file not shown.
BIN
fonts/GothamNarrSSm-Light.otf
Executable file
BIN
fonts/GothamNarrSSm-Light.otf
Executable file
Binary file not shown.
BIN
fonts/GothamNarrSSm-Medium.otf
Executable file
BIN
fonts/GothamNarrSSm-Medium.otf
Executable file
Binary file not shown.
BIN
fonts/GothamSSm-Black.otf
Executable file
BIN
fonts/GothamSSm-Black.otf
Executable file
Binary file not shown.
BIN
fonts/GothamSSm-Bold.otf
Executable file
BIN
fonts/GothamSSm-Bold.otf
Executable file
Binary file not shown.
BIN
fonts/GothamSSm-Book.otf
Executable file
BIN
fonts/GothamSSm-Book.otf
Executable file
Binary file not shown.
BIN
fonts/GothamSSm-Light.otf
Executable file
BIN
fonts/GothamSSm-Light.otf
Executable file
Binary file not shown.
BIN
fonts/GothamSSm-Medium.otf
Executable file
BIN
fonts/GothamSSm-Medium.otf
Executable file
Binary file not shown.
39
fonts/gotham.css
Normal file
39
fonts/gotham.css
Normal file
@ -0,0 +1,39 @@
|
||||
@font-face {
|
||||
font-family: 'Gotham';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(GothamSSm-Book.otf) format('opentype');
|
||||
unicode-range: U+0-10FFFF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Gotham Light';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(GothamSSm-Light.otf) format('opentype');
|
||||
unicode-range: U+0-10FFFF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Gotham Medium';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(GothamSSm-Medium.otf) format('opentype');
|
||||
unicode-range: U+0-10FFFF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Gotham Bold';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(GothamSSm-Bold.otf) format('opentype');
|
||||
unicode-range: U+0-10FFFF;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: 'Gotham Black';
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
src: url(GothamSSm-Black.otf) format('opentype');
|
||||
unicode-range: U+0-10FFFF;
|
||||
}
|
@ -8,6 +8,7 @@ const uglify = require('gulp-uglify-es').default;
|
||||
const sourcemaps = require('gulp-sourcemaps');
|
||||
const gutil = require('gulp-util');
|
||||
const rename = require('gulp-rename');
|
||||
const stripDebug = require('gulp-strip-debug');
|
||||
|
||||
gulp.task('bundleBackbone', function () {
|
||||
// set up the browserify instance on a task basis
|
||||
@ -19,6 +20,7 @@ gulp.task('bundleBackbone', function () {
|
||||
return b.bundle()
|
||||
.pipe(source('app.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(stripDebug())
|
||||
.pipe(rename('bundle.js'))
|
||||
|
||||
.pipe(sourcemaps.init({ 'loadMaps': true }))
|
||||
|
@ -24,6 +24,7 @@ gulp.task('styles', function() {
|
||||
|
||||
/* .pipe(gulp.dest('dist/css'))*/
|
||||
/* .pipe(rename({suffix: '.min'}))*/
|
||||
.pipe(concat('style.min.css'))
|
||||
.pipe(cssnano())
|
||||
.pipe(gulp.dest('live/css'));
|
||||
});
|
||||
@ -63,3 +64,8 @@ gulp.task('fonts', function() {
|
||||
.pipe(gulp.dest(`live/fonts`))
|
||||
;
|
||||
});
|
||||
|
||||
gulp.task('gotham', function() {
|
||||
gulp.src(['fonts/gotham.css']).pipe(gulp.dest('live/fonts'));
|
||||
gulp.src(['fonts/GothamSSm-Black.otf', 'fonts/GothamSSm-Bold.otf', 'fonts/GothamSSm-Book.otf', 'fonts/GothamSSm-Light.otf', 'fonts/GothamSSm-Medium.otf']).pipe(gulp.dest('live/fonts'));
|
||||
});
|
||||
|
@ -4,4 +4,4 @@ const requireDir = require('require-dir');
|
||||
|
||||
requireDir('./gulp');
|
||||
|
||||
gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts']);
|
||||
gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham']);
|
||||
|
170
package-lock.json
generated
170
package-lock.json
generated
@ -155,6 +155,15 @@
|
||||
"integrity": "sha1-SlKCrBZHKek2Gbz9OtFR+BfOkfU=",
|
||||
"dev": true
|
||||
},
|
||||
"ansi-cyan": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-cyan/-/ansi-cyan-0.1.1.tgz",
|
||||
"integrity": "sha1-U4rlKK+JgvKK4w2G8vF0VtJgmHM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-wrap": "0.1.0"
|
||||
}
|
||||
},
|
||||
"ansi-escapes": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.0.0.tgz",
|
||||
@ -170,6 +179,15 @@
|
||||
"ansi-wrap": "0.1.0"
|
||||
}
|
||||
},
|
||||
"ansi-red": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-red/-/ansi-red-0.1.1.tgz",
|
||||
"integrity": "sha1-jGOPnRCAgAo1PJwoyKgcpHBdlGw=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-wrap": "0.1.0"
|
||||
}
|
||||
},
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz",
|
||||
@ -6575,6 +6593,17 @@
|
||||
"plexer": "1.0.1"
|
||||
}
|
||||
},
|
||||
"gulp-strip-debug": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/gulp-strip-debug/-/gulp-strip-debug-2.0.0.tgz",
|
||||
"integrity": "sha512-Gg9FgHTHPVOr6pshTTrA4vc2WVFf+W5EVSu2FSauKn+2KsgxfyMY2r3cpickRdsLBeK9QZl77A9LjNA74j0rnA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"plugin-error": "0.1.2",
|
||||
"strip-debug": "2.0.0",
|
||||
"through2": "2.0.3"
|
||||
}
|
||||
},
|
||||
"gulp-tasks": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/gulp-tasks/-/gulp-tasks-0.0.2.tgz",
|
||||
@ -7688,6 +7717,15 @@
|
||||
"integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=",
|
||||
"dev": true
|
||||
},
|
||||
"jsonfile": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
|
||||
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"graceful-fs": "4.1.11"
|
||||
}
|
||||
},
|
||||
"jsonify": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonify/-/jsonify-0.0.0.tgz",
|
||||
@ -10167,6 +10205,58 @@
|
||||
"readable-stream": "2.3.3"
|
||||
}
|
||||
},
|
||||
"plugin-error": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
|
||||
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-cyan": "0.1.1",
|
||||
"ansi-red": "0.1.1",
|
||||
"arr-diff": "1.1.0",
|
||||
"arr-union": "2.1.0",
|
||||
"extend-shallow": "1.1.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"arr-diff": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
|
||||
"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"arr-flatten": "1.1.0",
|
||||
"array-slice": "0.2.3"
|
||||
}
|
||||
},
|
||||
"arr-union": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
|
||||
"integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=",
|
||||
"dev": true
|
||||
},
|
||||
"array-slice": {
|
||||
"version": "0.2.3",
|
||||
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz",
|
||||
"integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=",
|
||||
"dev": true
|
||||
},
|
||||
"extend-shallow": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
|
||||
"integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"kind-of": "1.1.0"
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
|
||||
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"pluralize": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz",
|
||||
@ -11928,6 +12018,74 @@
|
||||
"inherits": "2.0.3"
|
||||
}
|
||||
},
|
||||
"rocambole": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/rocambole/-/rocambole-0.7.0.tgz",
|
||||
"integrity": "sha1-9seVBVF9xCtvuECEK4uVOw+WhYU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"esprima": "2.7.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"esprima": {
|
||||
"version": "2.7.3",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz",
|
||||
"integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"rocambole-node-remove": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rocambole-node-remove/-/rocambole-node-remove-1.0.0.tgz",
|
||||
"integrity": "sha1-vUmxPb5hInWDdP/SR9inOeghSG8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rocambole-token": "1.2.1"
|
||||
}
|
||||
},
|
||||
"rocambole-node-update": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/rocambole-node-update/-/rocambole-node-update-1.0.1.tgz",
|
||||
"integrity": "sha1-o//JaLDzvNnPKpM23A234lTIPFo=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rocambole-token": "1.2.1"
|
||||
}
|
||||
},
|
||||
"rocambole-strip-alert": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rocambole-strip-alert/-/rocambole-strip-alert-1.0.0.tgz",
|
||||
"integrity": "sha1-OyVf5vGNYwH4BaFOVwsfHy26hX8=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rocambole-node-update": "1.0.1"
|
||||
}
|
||||
},
|
||||
"rocambole-strip-console": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rocambole-strip-console/-/rocambole-strip-console-1.0.0.tgz",
|
||||
"integrity": "sha1-K5fj36bhnUUo6+galCMdyeiqygs=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rocambole-node-update": "1.0.1"
|
||||
}
|
||||
},
|
||||
"rocambole-strip-debugger": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rocambole-strip-debugger/-/rocambole-strip-debugger-1.0.0.tgz",
|
||||
"integrity": "sha1-HFUCQgw9bvXiOnC4BUff0dS7y3Y=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rocambole-node-remove": "1.0.0"
|
||||
}
|
||||
},
|
||||
"rocambole-token": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/rocambole-token/-/rocambole-token-1.2.1.tgz",
|
||||
"integrity": "sha1-x4XfdCjcPLJ614lwR71SOMwHDTU=",
|
||||
"dev": true
|
||||
},
|
||||
"ruglify": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ruglify/-/ruglify-1.0.0.tgz",
|
||||
@ -12750,6 +12908,18 @@
|
||||
"integrity": "sha1-5SEekiQ2n7uB1jOi8ABE3IztrZI=",
|
||||
"dev": true
|
||||
},
|
||||
"strip-debug": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-debug/-/strip-debug-2.0.0.tgz",
|
||||
"integrity": "sha1-86F3x1XDpYrLJuQaBsoT8SHphMk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rocambole": "0.7.0",
|
||||
"rocambole-strip-alert": "1.0.0",
|
||||
"rocambole-strip-console": "1.0.0",
|
||||
"rocambole-strip-debugger": "1.0.0"
|
||||
}
|
||||
},
|
||||
"strip-indent": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz",
|
||||
|
@ -51,11 +51,13 @@
|
||||
"gulp-scss": "^1.4.0",
|
||||
"gulp-sourcemaps": "^2.6.1",
|
||||
"gulp-streamify": "^1.0.2",
|
||||
"gulp-strip-debug": "^2.0.0",
|
||||
"gulp-tasks": "0.0.2",
|
||||
"gulp-uglify": "^3.0.0",
|
||||
"gulp-uglify-es": "^0.1.3",
|
||||
"gulp-util": "^3.0.8",
|
||||
"gulp-webpack": "^1.5.0",
|
||||
"jsonfile": "^4.0.0",
|
||||
"lodash.assign": "^4.2.0",
|
||||
"mocha": "^3.5.3",
|
||||
"require-dir": "^0.3.2",
|
||||
|
@ -10,7 +10,7 @@ $mui-accent-color: mui-color('deep-purple', '900');
|
||||
$mui-accent-color-dark: mui-color('indigo', 'A100');
|
||||
$mui-accent-color-light: mui-color('indigo', 'A400');
|
||||
|
||||
$mui-base-font-family: 'Roboto Slab', "Helvetica Neue", Helvetica, Arial, Verdana,"Trebuchet MS";
|
||||
$mui-base-font-family: 'Roboto', "Helvetica Neue", Helvetica, Arial, Verdana,"Trebuchet MS";
|
||||
|
||||
// import MUI SASS
|
||||
@import "./node_modules/muicss/lib/sass/mui";
|
||||
@ -92,6 +92,14 @@ li {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.time {
|
||||
font-family: 'Roboto Mono';
|
||||
}
|
||||
|
||||
.titleBar {
|
||||
font-family: 'Gotham Light';
|
||||
font-size:125%;
|
||||
}
|
||||
|
||||
/* The snackbar - position it at the bottom and in the middle of the screen */
|
||||
#snackbar {
|
||||
|
@ -1,2 +1,4 @@
|
||||
Roboto+Slab
|
||||
Roboto+Condensed
|
||||
Roboto+Condensed
|
||||
Roboto+Mono
|
||||
Roboto
|
||||
|
@ -6,6 +6,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Train Times</title>
|
||||
<link href="fonts/fonts.css" rel="stylesheet">
|
||||
<link href="fonts/gotham.css" rel="stylesheet">
|
||||
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="/img/apple-touch-icon.png">
|
||||
@ -17,14 +18,13 @@
|
||||
<meta name="application-name" content="Train Times">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
|
||||
<link href="css/backbone.modal.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/backbone.modal.theme.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/style.min.css" rel="stylesheet" type="text/css"/>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<header id="header">
|
||||
<div class="mui-appbar mui--appbar-line-height mui--z2">
|
||||
<div class='mui-col-xs-8 mui-col-md-8 mui--appbar-height'>Train Times</div>
|
||||
<div class='mui-col-xs-8 mui-col-md-8 mui--appbar-height titleBar'>Train Times</div>
|
||||
<div class='mui-col-xs-4 mui-col-md-4 mui--appbar-height'></div>
|
||||
</div>
|
||||
</header>
|
||||
@ -48,9 +48,9 @@
|
||||
|
||||
</div>
|
||||
<div class="bbm-modal__bottombar">
|
||||
<a href="#" class="bbm-button">close</a>
|
||||
<a href="#" class="bbm-button">close</a>
|
||||
</div>
|
||||
</script>
|
||||
</script>
|
||||
|
||||
|
||||
<!--<script src="//cdn.muicss.com/mui-0.9.26/js/mui.min.js"></script>-->
|
||||
|
@ -22,9 +22,9 @@ const RouteModel = Backbone.Model.extend({
|
||||
console.log('Route model update');
|
||||
console.log(this.changedAttributes());
|
||||
console.log(_.keys(this.changedAttributes()));
|
||||
if (!this.get('to'))
|
||||
if (!this.get('to'))
|
||||
return;
|
||||
|
||||
|
||||
const now = new Date;
|
||||
const hours = now.getHours();
|
||||
const limit = (hours < 6) ? 3600000 : 95000;
|
||||
@ -176,13 +176,14 @@ const RouteView = Backbone.View.extend({
|
||||
|
||||
console.log(route);
|
||||
|
||||
const symbol = ['💠', '🚉'];
|
||||
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 platform = item.platform !== null ? item.platform : `${symbol[0]}`;
|
||||
// 🚉 💠
|
||||
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;
|
||||
@ -193,7 +194,7 @@ 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 }<tr><td data-id="${item.serviceIdUrlSafe}" class="station">${dest.locationName} ${via}</td>
|
||||
<td class="mui--text-center">${time}</td>
|
||||
<td class="mui--text-center time">${time}</td>
|
||||
<td class="mui--text-center ${statusMode}">${status}</td>
|
||||
<td class="mui--text-center">${platform}</td>
|
||||
</tr>${delayReason}`;
|
||||
@ -215,7 +216,7 @@ const RouteView = Backbone.View.extend({
|
||||
}
|
||||
|
||||
let nrMessages = '';
|
||||
if (typeof route.nrccMessages === 'object' && route.nrccMessages !== null)
|
||||
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) {
|
||||
@ -228,10 +229,10 @@ const RouteView = Backbone.View.extend({
|
||||
${nrMessages}
|
||||
<table class="mui-table mui-table-bordered">
|
||||
<thead><tr><th>Destination</th>
|
||||
<th>Time</th>
|
||||
<th>Status</th>
|
||||
<th>Platform</th></tr></thead>`;
|
||||
|
||||
<th class="mui--text-center">Time</th>
|
||||
<th class="mui--text-center">Status</th>
|
||||
<th class="mui--text-center">Platform</th></tr></thead>`;
|
||||
|
||||
ws = `${thead}${ws}</table>`;
|
||||
this.$traintext.empty().html(ws);
|
||||
this.$traintext.removeClass('mui--hide').addClass('mui--show');
|
||||
|
14
src/js/stations.js
Normal file
14
src/js/stations.js
Normal file
File diff suppressed because one or more lines are too long
@ -8,6 +8,7 @@
|
||||
const $ = require('jquery');
|
||||
const _ = require('underscore');
|
||||
const Backbone = require('backbone');
|
||||
const { findStation } = require('./stations');
|
||||
|
||||
const TrainModel = Backbone.Model.extend({
|
||||
'initialize': function () {
|
||||
@ -16,9 +17,11 @@ const TrainModel = Backbone.Model.extend({
|
||||
const url = `/getnexttraintimes?from=${ this.get('from') }&to=${ this.get('to')}`;
|
||||
const routeUrl = `/gettrains?from=${ this.get('from') }&to=${ this.get('to')}`;
|
||||
const target = this.get('from') + this.get('to');
|
||||
const fancyTarget = `${findStation(this.get('from'))}<br/>${findStation(this.get('to'))}`;
|
||||
this.set('url', url);
|
||||
this.set('routeUrl', routeUrl);
|
||||
this.set('target', target);
|
||||
this.set('fancyTarget', fancyTarget);
|
||||
this.set('visible', false);
|
||||
this.set('trainData', { 'eta':'OFF', 'sta': 'OFF' });
|
||||
this.update();
|
||||
@ -30,9 +33,9 @@ const TrainModel = Backbone.Model.extend({
|
||||
|
||||
const mod = limit - (now.getTime() % limit);
|
||||
|
||||
if (hours >= 6)
|
||||
if (hours >= 6)
|
||||
this.getTrain();
|
||||
else
|
||||
else
|
||||
this.set('trainData', { 'eta':'OFF', 'sta': 'OFF' });
|
||||
|
||||
const trainUpdateFn = function () {
|
||||
@ -61,7 +64,6 @@ const TrainModel = Backbone.Model.extend({
|
||||
self.set('trainData', data);
|
||||
},
|
||||
'error': function (xhr, type) {
|
||||
|
||||
if (xhr.readyState === 0 && xhr.status === 0)
|
||||
|
||||
bus.trigger('offline');
|
||||
@ -101,19 +103,20 @@ const TrainView = Backbone.View.extend({
|
||||
'initView': function () {
|
||||
const self = this;
|
||||
const target = this.model.get('target');
|
||||
const fancyTarget = this.model.get('fancyTarget');
|
||||
const html = `
|
||||
<div class="mui-row card">
|
||||
<div class='mui-col-xs-7 mui-col-md-7 entry'>${target.toUpperCase()}</div>
|
||||
<div class='mui-col-xs-7 mui-col-md-7 entry'>${fancyTarget}</div>
|
||||
<div class='mui-col-xs-5 mui-col-md-5 mui--text-right'>
|
||||
<button class="mui-btn mui-btn--flat" id="${target}"></button>
|
||||
<button class="mui-btn mui-btn--flat time" id="${target}"></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
`;
|
||||
this.$html = $(html);
|
||||
this.$html.on('click', () => {
|
||||
// console.log('from', self.model.get('from'));
|
||||
// console.log('to', self.model.get('to'));
|
||||
// console.log('from', self.model.get('from'));
|
||||
// console.log('to', self.model.get('to'));
|
||||
self.eventBus.trigger('showRoute', { 'from': self.model.get('from'), 'to': self.model.get('to') });
|
||||
// console.log(self)
|
||||
// self.model.getRoute();
|
||||
@ -132,7 +135,7 @@ const TrainView = Backbone.View.extend({
|
||||
this.events[cevent] = 'showTrains';
|
||||
},
|
||||
'showTrains': function () {
|
||||
// console.log('Show train');
|
||||
// console.log('Show train');
|
||||
this.eventBus.trigger('showRoute');
|
||||
}
|
||||
|
||||
|
60
tools/convert.js
Normal file
60
tools/convert.js
Normal file
@ -0,0 +1,60 @@
|
||||
const { promisify } = require('util');
|
||||
const jsonfile = require('jsonfile');
|
||||
const logger = require('log4js').getLogger();
|
||||
|
||||
logger.level = 'trace';
|
||||
|
||||
const file = 'src/work/stations.json';
|
||||
const outFile = 'src/work/stationsMap.json';
|
||||
|
||||
const readFile = promisify(jsonfile.readFile);
|
||||
const writeFile = promisify(jsonfile.writeFile);
|
||||
|
||||
function doConvert(obj) {
|
||||
const tempArray = [];
|
||||
for(const item of obj.locations)
|
||||
|
||||
if ((item.lat !== 0) && (item.long !== 0)) {
|
||||
// logger.debug(item.name);
|
||||
tempArray.push([item.crs, item.name]);
|
||||
}
|
||||
|
||||
//const locMap = new Map(tempArray);
|
||||
|
||||
// logger.debug(locMap);
|
||||
|
||||
writeFile(outFile, tempArray)
|
||||
.then( () => {
|
||||
logger.debug('Saved...');
|
||||
}
|
||||
|
||||
)
|
||||
.catch(err => {
|
||||
logger.error('Json failed to save');
|
||||
logger.warn(err);
|
||||
});
|
||||
}
|
||||
|
||||
readFile(file)
|
||||
.then(obj => {
|
||||
logger.info('json loaded....');
|
||||
doConvert(obj);
|
||||
})
|
||||
.catch(err => {
|
||||
logger.error('Json failed to load');
|
||||
logger.warn(err);
|
||||
});
|
||||
|
||||
/*
|
||||
|
||||
jsonfile.readFile(file, (err, obj) => {
|
||||
if (err) {
|
||||
logger.error('Json failed to load');
|
||||
logger.warn(err);
|
||||
}
|
||||
else {
|
||||
logger.info('Json loaded...');
|
||||
doConvert(obj);
|
||||
}
|
||||
});
|
||||
*/
|
Loading…
Reference in New Issue
Block a user