swapped manifest file and added bumper

This commit is contained in:
Martin Donnelly 2019-01-19 22:47:39 +00:00
parent 7a597ba55c
commit 9fa076439c
5 changed files with 45 additions and 3 deletions

View File

@ -32,6 +32,27 @@ gulp.task('bundleBackbone', function () {
.pipe(gulp.dest('./live/js')); .pipe(gulp.dest('./live/js'));
}); });
gulp.task('liveBackbone', function () {
// set up the browserify instance on a task basis
const b = browserify({
'debug': true,
'entries': './src/js/app.js'
});
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(stripDebug())
.pipe(rename('bundle.js'))
.pipe(sourcemaps.init({ 'loadMaps': true }))
// Add transformation tasks to the pipeline here.
// .pipe(uglify())
.on('error', gutil.log)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./live/js'));
});
gulp.task('bump', function() { gulp.task('bump', function() {
gulp.src('src/service-worker.js') gulp.src('src/service-worker.js')
.pipe(bump({ 'key': 'version' })) .pipe(bump({ 'key': 'version' }))

View File

@ -5,3 +5,6 @@ const requireDir = require('require-dir');
requireDir('./gulp'); requireDir('./gulp');
gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham', 'fujicons']); gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham', 'fujicons']);
gulp.task('live', ['liveBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham', 'fujicons']);

View File

@ -3,6 +3,12 @@ const _ = require('underscore');
const Backbone = require('backbone'); const Backbone = require('backbone');
const { createPanel, addPanel } = require('./libs/panel'); const { createPanel, addPanel } = require('./libs/panel');
function minuteFloor() {
const now = new Date();
return parseInt(~~(now.getTime() / 60000) * 60000, 10).toString(32);
}
const RouteModel = Backbone.Model.extend({ const RouteModel = Backbone.Model.extend({
'initialize': function () { 'initialize': function () {
const fromStation = this.get('from'); const fromStation = this.get('from');
@ -48,7 +54,7 @@ const RouteModel = Backbone.Model.extend({
this.interval = setTimeout(routeUpdateFn.bind(this), mod + 10); this.interval = setTimeout(routeUpdateFn.bind(this), mod + 10);
}, },
'getRoute': function () { 'getRoute': function () {
const url = `/gettrains?from=${ this.get('from') }&to=${ this.get('to')}`; const url = `/gettrains?from=${ this.get('from') }&to=${ this.get('to')}&m=${minuteFloor()}`;
const self = this; const self = this;
$.ajax({ $.ajax({

View File

@ -10,6 +10,18 @@ const _ = require('underscore');
const Backbone = require('backbone'); const Backbone = require('backbone');
const { findStation } = require('./stations'); const { findStation } = require('./stations');
function hourFloor() {
const now = new Date();
return parseInt(~~(now.getTime() / 3600000) * 3600000, 10).toString(32);
}
function minuteFloor() {
const now = new Date();
return parseInt(~~(now.getTime() / 60000) * 60000, 10).toString(32);
}
const TrainModel = Backbone.Model.extend({ const TrainModel = Backbone.Model.extend({
'defaults': function (obj) { 'defaults': function (obj) {
// return a new object // return a new object
@ -58,7 +70,7 @@ const TrainModel = Backbone.Model.extend({
const bus = this.get('bus'); const bus = this.get('bus');
$.ajax({ $.ajax({
'type': 'GET', 'type': 'GET',
'url': url, 'url': `${url}&m=${minuteFloor()}`,
'data': '', 'data': '',
'dataType': 'json', 'dataType': 'json',
'timeout': 10000, 'timeout': 10000,

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
const CACHE_VERSION = { 'version': '0.0.18' }; const CACHE_VERSION = { 'version': '0.0.21' };
const PRECACHE = `traintimesData-v${CACHE_VERSION.version}`; const PRECACHE = `traintimesData-v${CACHE_VERSION.version}`;
const cacheName = `traintimePWA-final-${CACHE_VERSION.version}`; const cacheName = `traintimePWA-final-${CACHE_VERSION.version}`;
const RUNTIME = 'runtime'; const RUNTIME = 'runtime';