Merge branch 'traffic_fixes' into 'master'

Traffic fixes

See merge request martind2000/jubilee!3
This commit is contained in:
Martin Donnelly 2018-04-19 20:29:46 +00:00
commit 5459713176
5 changed files with 24 additions and 28 deletions

10
package-lock.json generated
View File

@ -52,7 +52,7 @@
},
"@sinonjs/formatio": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
"resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
"integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
"dev": true,
"requires": {
@ -659,7 +659,7 @@
"resolved": "https://registry.npmjs.org/backbone/-/backbone-1.3.3.tgz",
"integrity": "sha1-TMgOp8sWMaxHSInOQPL4vGg7KZk=",
"requires": {
"underscore": "1.8.3"
"underscore": "1.9.0"
}
},
"balanced-match": {
@ -11498,9 +11498,9 @@
"dev": true
},
"underscore": {
"version": "1.8.3",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz",
"integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI="
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.0.tgz",
"integrity": "sha512-4IV1DSSxC1QK48j9ONFK1MoIAKKkbE8i7u55w2R6IqBqbT7A/iG7aZBCR2Bi8piF0Uz+i/MG1aeqLwl/5vqF+A=="
},
"union-value": {
"version": "1.0.0",

View File

@ -49,7 +49,7 @@
"sugar": "^2.0.4",
"twitter": "^1.7.1",
"uglifyify": "^4.0.5",
"underscore": "^1.8.3",
"underscore": "^1.9.0",
"winston": "^2.4.1",
"winston-mongodb": "^4.0.0-rc1",
"yelp-fusion": "^2.0.3"

View File

@ -11,7 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
const CACHE_VERSION = { 'version': '0.0.689' };
const CACHE_VERSION = { 'version': '0.0.695' };
const dataCacheName = 'jubileeData-v1';
const cacheName = 'jubilee-final-1';
const filesToCache = [

View File

@ -24,23 +24,20 @@ const TrafficModel = Backbone.Model.extend({
'tick': function() {
const hour = (new Date()).getHours();
// ( ((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)) )
//
console.log('this.has(\'latlong\')', this.has('latlong'));
if (this.has('latlong')) {
const day = new Date().getDay();
let doRequest = false;
if (day !== 0 && day !== 6)
doRequest = (((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)));
const delay = doRequest ? 600000 : toHour();
if (this.has('latlong') && doRequest) {
this.updateID = 1;
this.getTraffic();
}
const day = new Date().getDay();
console.log('tick', this.attributes);
console.log('((hour >= 7) && (hour <= 9))', ((hour >= 7) && (hour <= 9)));
console.log('((hour >= 17) && (hour <= 19))', ((hour >= 17) && (hour <= 19)));
let delay;
if (day === 0 || day === 6)
delay = toHour();
else
delay = ( ((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)) ) ? 600000 : toHour();
this.set('mode', 0);
console.log('Delay', delay);
this.timerID = setTimeout(
@ -52,7 +49,7 @@ const TrafficModel = Backbone.Model.extend({
this.getTraffic();
},
'getTraffic': function() {
console.log('Get Raffic');
console.log('Get Traffic');
// olat, olon, dlat, dlon
const time = new Date().getTime() ;
const hour = (new Date()).getHours();
@ -141,8 +138,8 @@ const TrafficView = Backbone.View.extend({
},
'template': _.template(`
<div class="">
<div><i class="small fa <%= "fa-" + dest.toLowerCase() %> mui--align-middle "></i> <%=readable%> to <%= dest.toLowerCase() %></div>
<div class="<%= className %>"><%=traffic %></div>
<div class="itemRow mui--align-middle"><i class=" fa <%= "fa-" + dest.toLowerCase() %> fa-2x mui--align-middle <%= className %>"></i> <%=readable%> to <%= dest.toLowerCase() %> <span class="<%= className %>"><%=traffic %></span></div>
</div>
`),
@ -180,15 +177,14 @@ const parts = new Map(
['9', 'left_turn'],
['13', 'right_turn'],
['11', 'continue'],
['23','right_fork'],
['17','left_exit'],
['23', 'right_fork'],
['17', 'left_exit'],
['19', 'left_ramp'],
['29', 'turn'],
['','']
['', '']
]
);
module.exports = { TrafficModel, TrafficView };

View File

@ -21,7 +21,7 @@ const { NearbyListModel, NearbyListView } = require('./NearbyList');
const { NearbyPlacesView } = require('./NearbyPlaces');
var app = app || {};
const live = true;
const live = false;
if (live) {
window.loc = 'https://jubilee.silvrtree.co.uk';