From d09d26116363e55eace24842bccb1a831cfe9bbf Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Wed, 16 May 2018 23:24:27 +0100 Subject: [PATCH] Colours and stuff updated --- .eslintrc.json | 2 +- notes/directions.json | 269 ++++++++++++++++++++++++++++++++++++ package-lock.json | 2 +- src/css/common.css | 49 +++++++ src/css/custom.scss | 50 +++++++ src/service-worker.js | 2 +- src/v1/js/Forecast.js | 85 +----------- src/v1/js/Traffic.js | 2 + src/v1/js/libs/templates.js | 77 ++++++++++- 9 files changed, 454 insertions(+), 84 deletions(-) create mode 100644 notes/directions.json diff --git a/.eslintrc.json b/.eslintrc.json index 537ab8c..a242ad8 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -27,7 +27,7 @@ "func-names": 1, "indent": ["error", 2, { "SwitchCase": 1 }], "lines-around-comment": ["error", { "beforeBlockComment": true, "allowArrayStart": true }], - "max-len": [1, 120, 2], // 2 spaces per tab, max 80 chars per line + "max-len": [1, 180, 2], // 2 spaces per tab, max 80 chars per line "new-cap": 1, "newline-before-return": "error", "no-array-constructor": 1, diff --git a/notes/directions.json b/notes/directions.json new file mode 100644 index 0000000..33a9025 --- /dev/null +++ b/notes/directions.json @@ -0,0 +1,269 @@ +{ + "@lang": "en-US", + "ResultSet": { + "@version": "2.0", + "@lang": "en-US", + "Error": "0", + "ErrorMessage": "No error", + "Locale": "en-US", + "Result": { + "yahoo_driving_directions": { + "routeHandle": "0", + "address": [ + { + "type": "Origin", + "lat": "55.872407", + "lon": "-3.549003", + "line1": "", + "line2": "", + "line3": "", + "line4": "", + "country": "" + }, + { + "type": "Destination", + "lat": "55.942673", + "lon": "-4.556334", + "line1": "", + "line2": "", + "line3": "", + "line4": "", + "country": "" + } + ], + "total_distance": "81363", + "total_time": "62.0", + "total_time_with_traffic": "68.0", + "boundingbox": { + "north": "55.942587", + "south": "55.832605", + "east": "-3.540913", + "west": "-4.556462" + }, + "route_id": "AIIACAAAAB4AAABSAAAAmQAAAJ4AAAB42mOYx8DAxMQABBVvKmufOO1OZ4CCuPnVYiuYF9kw/P8PEfiwnwEJcAHxoivLljMxFHUfqmnjPQHXaBBfI+bCsMgKj8bvHSxVjECL4YJpsZcOdANpUXaGwzI1DFxASQYJBicgCQAvuB+Jc1TTsQ==", + "directions": { + "route_leg": [ + { + "@type": "PrivateRouteLeg", + "number": "1", + "lat": "55.872313", + "lon": "-3.547393", + "distance": "98", + "description": "Head northeast. Go for 98 m.", + "time": "0", + "time_with_traffic": "0", + "turn_angle": "0", + "exit_num": "", + "man_type": "0", + "street": ", " + }, + { + "@type": "PrivateRouteLeg", + "number": "2", + "lat": "55.872978", + "lon": "-3.546385", + "distance": "252", + "description": "Take the 3rd exit from roundabout. Go for 252 m.", + "time": "1", + "time_with_traffic": "1", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": ", " + }, + { + "@type": "PrivateRouteLeg", + "number": "3", + "lat": "55.872967", + "lon": "-3.543209", + "distance": "127", + "description": "Take the 2nd exit from Brotherton Roundabout roundabout. Go for 127 m.", + "time": "1", + "time_with_traffic": "1", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": ", " + }, + { + "@type": "PrivateRouteLeg", + "number": "4", + "lat": "55.873493", + "lon": "-3.541557", + "distance": "2453", + "description": "Take the 1st exit from Rosebank Roundabout roundabout onto Simpson Parkway. Go for 2.5 km.", + "time": "3", + "time_with_traffic": "3", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": ", SIMPSON PARKWAY" + }, + { + "@type": "PrivateRouteLeg", + "number": "5", + "lat": "55.885177", + "lon": "-3.557704", + "distance": "432", + "description": "Turn left onto A705. Go for 432 m.", + "time": "1", + "time_with_traffic": "1", + "turn_angle": "-90", + "exit_num": "", + "man_type": "9", + "street": "A705, " + }, + { + "@type": "PrivateRouteLeg", + "number": "6", + "lat": "55.886142", + "lon": "-3.563454", + "distance": "623", + "description": "Take the 2nd exit from Toll Roundabout roundabout onto Starlaw Road (A779). Go for 623 m.", + "time": "1", + "time_with_traffic": "1", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": "A779, STARLAW ROAD" + }, + { + "@type": "PrivateRouteLeg", + "number": "7", + "lat": "55.889865", + "lon": "-3.570009", + "distance": "1652", + "description": "Take the 1st exit from Tailend Roundabout roundabout onto Starlaw Road (A779). Go for 1.7 km.", + "time": "2", + "time_with_traffic": "2", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": "A779, STARLAW ROAD" + }, + { + "@type": "PrivateRouteLeg", + "number": "8", + "lat": "55.890005", + "lon": "-3.596199", + "distance": "49437", + "description": "Take the 1st exit from Starlaw West Roundabout roundabout onto M8 toward Glasgow. Go for 49.4 km.", + "time": "33", + "time_with_traffic": "33", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": "M8, ", + "sign": "Glasgow" + }, + { + "@type": "PrivateRouteLeg", + "number": "9", + "lat": "55.84886", + "lon": "-4.306791", + "distance": "14959", + "description": "Keep right onto M8. Go for 15.0 km.", + "time": "10", + "time_with_traffic": "10", + "turn_angle": "30", + "exit_num": "", + "man_type": "23", + "street": "M8, " + }, + { + "@type": "PrivateRouteLeg", + "number": "10", + "lat": "55.898191", + "lon": "-4.483388", + "distance": "1391", + "description": "Take exit 30 toward Erskine Bridge/Erskine/Bishopton onto M898. Go for 1.4 km.", + "time": "1", + "time_with_traffic": "1", + "turn_angle": "-30", + "exit_num": "", + "man_type": "17", + "street": "M898, ", + "sign": "Bishopton, Erskine, Erskine Bridge" + }, + { + "@type": "PrivateRouteLeg", + "number": "11", + "lat": "55.90745", + "lon": "-4.473388", + "distance": "2509", + "description": "Keep right onto A898 toward Erskine Br./Glasgow/Crianlarich/(A82). Go for 2.5 km.", + "time": "2", + "time_with_traffic": "2", + "turn_angle": "30", + "exit_num": "", + "man_type": "23", + "street": "A898, ", + "sign": "(A82), Crianlarich, Erskine Br., Glasgow" + }, + { + "@type": "PrivateRouteLeg", + "number": "12", + "lat": "55.923564", + "lon": "-4.450718", + "distance": "3714", + "description": "Take ramp onto Great Western Road (A82) toward Crianlarich. Go for 3.7 km.", + "time": "3", + "time_with_traffic": "3", + "turn_angle": "-30", + "exit_num": "", + "man_type": "19", + "street": "A82, GREAT WESTERN ROAD", + "sign": "Crianlarich" + }, + { + "@type": "PrivateRouteLeg", + "number": "13", + "lat": "55.931783", + "lon": "-4.502968", + "distance": "1656", + "description": "Take the 2nd exit from Dunglass Roundabout roundabout onto Dumbarton Road (A82) toward Crianlarich/Dumbarton. Go for 1.7 km.", + "time": "2", + "time_with_traffic": "2", + "turn_angle": "-90", + "exit_num": "", + "man_type": "29", + "street": "A82, DUMBARTON ROAD", + "sign": "Crianlarich, Dumbarton" + }, + { + "@type": "PrivateRouteLeg", + "number": "14", + "lat": "55.935098", + "lon": "-4.526989", + "distance": "2060", + "description": "Turn left onto Glasgow Road (A814) toward Dumbarton/Town Centre/H'burgh. Go for 2.1 km.", + "time": "3", + "time_with_traffic": "3", + "turn_angle": "-90", + "exit_num": "", + "man_type": "9", + "street": "A814, GLASGOW ROAD", + "sign": "Dumbarton, H'burgh, Town Centre" + }, + { + "@type": "PrivateRouteLeg", + "number": "15", + "lat": "55.942587", + "lon": "-4.556462", + "distance": "0", + "description": "Arrive at Glasgow Road (A814). Your destination is on the right.", + "time": "0", + "time_with_traffic": "0", + "turn_angle": "0", + "exit_num": "", + "man_type": "2", + "street": ", " + } + ] + }, + "copy_right": "Copyright © 2018 Yahoo! Inc. All rights reserved. © Navteq" + }, + "geocode_results": null + } + } +} diff --git a/package-lock.json b/package-lock.json index a015e17..2b7f6c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -52,7 +52,7 @@ }, "@sinonjs/formatio": { "version": "2.0.0", - "resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", + "resolved": "https://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz", "integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==", "dev": true, "requires": { diff --git a/src/css/common.css b/src/css/common.css index 91e2386..2f18c92 100644 --- a/src/css/common.css +++ b/src/css/common.css @@ -87,6 +87,55 @@ body { color: rgb(236, 110, 5) } + .temp21 { + color: #ea5a24; + } + + .temp22 { + color: #e4572b; + } + + .temp23 { + color: #e14a29; + } + + .temp24 { + color: #e04127; + } + + .temp25 { + color: #d9372b; + } + + .temp26 { + color: #d63129; + } + + .temp27 { + color: #d12b2b; + } + + .temp28 { + color: #cd282f; + } + + .temp29 { + color: #c82432; + } + + .temp30 { + color: #c32334; + } + + .temp31 { + color: #be2138; + } + + .temp32, .temp33, .temp34, .temp35 { + color: #b9203b; + } + + .day { font-family: "Roboto Slab", "Helvetica Neue", Helvetica, Arial, sans-serif; text-transform: uppercase; diff --git a/src/css/custom.scss b/src/css/custom.scss index 08dce64..cf71a2b 100644 --- a/src/css/custom.scss +++ b/src/css/custom.scss @@ -284,6 +284,56 @@ li { color: rgb(236, 110, 5) } +.temp21 { + color: #ea5a24; +} + +.temp22 { + color: #e4572b; +} + +.temp23 { + color: #e14a29; +} + +.temp24 { + color: #e04127; +} + +.temp25 { + color: #d9372b; +} + +.temp26 { + color: #d63129; +} + +.temp27 { + color: #d12b2b; +} + +.temp28 { + color: #cd282f; +} + +.temp29 { + color: #c82432; +} + +.temp30 { + color: #c32334; +} + +.temp31 { + color: #be2138; + } + +.temp32, .temp33, .temp34, .temp35 { + color: #b9203b; +} + + + .day { font-family: "Roboto Slab", "Helvetica Neue", Helvetica, Arial, sans-serif; text-transform: uppercase; diff --git a/src/service-worker.js b/src/service-worker.js index e154e0b..4c56a64 100644 --- a/src/service-worker.js +++ b/src/service-worker.js @@ -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.704' }; +const CACHE_VERSION = { 'version': '0.0.705' }; const dataCacheName = 'jubileeData-v1'; const cacheName = 'jubilee-final-1'; const filesToCache = [ diff --git a/src/v1/js/Forecast.js b/src/v1/js/Forecast.js index 746ba23..648b70e 100644 --- a/src/v1/js/Forecast.js +++ b/src/v1/js/Forecast.js @@ -4,6 +4,7 @@ const Backbone = require('backbone'); const request = require('request'); const { get, isEmpty } = require('lodash'); const { createPanel, addPanel } = require('./libs/panel'); +const templates = require('./libs/templates'); const ForecastModel = Backbone.Model.extend({ 'defaults': function (obj) { @@ -58,82 +59,6 @@ const ForecastView = Backbone.View.extend({ this.eventBus.on('showForecast', this.showForecastPanel, this); }, - 'templateCurrently': _.template(` -
-
<%=summary%>
-
- <%=tempMax%>° - <%=tempMin%>° -
-
<%=temperature%>°
-
- `), - 'templateForecast': _.template(` -
-

Forecast

-
- <%_.forEach(today, function(i) {%> -
-
<%=i.time %>
-
-
<%=~~(i.temp)%>°
-
- <%}) %> -
- -
-
- <%_.forEach(daily, function(i) {%> -
-
<%=i.time %>
-
-
<%=~~(i.tempHigh)%>°
-
<%=~~(i.tempLow)%>°
-
- <%}) %> -
- -
-
- `), - 'templateDetails': _.template(` -
-

Details

-
-
Humidity
-
<%=~~(humidity * 100) %>%
-
-
-
Visibility
-
<%=visibility %>km
-
-
-
UV Index
-
<%=uvIndex %>
-
-
-
<%=summary%>
-
-

Wind & Pressure

-
-
Wind
-
<%=windSpeed %>km/h
-
Barometer
-
<%=pressure %>mBar
- -
-

Sun & Moon

-
-
Sunrise
-
<%=sunriseTime %>
-
Sunset
-
<%=sunsetTime %>
- -
- -
- `), - 'showForecastPanel': function(ll) { console.log('Showing forecast', ll); const prevll = this.model.get('ll'); @@ -186,10 +111,10 @@ const ForecastView = Backbone.View.extend({ const currently = this.model.get('currently'); const forcastToday = { 'today':this.model.get('forcastToday'), 'daily':this.model.get('dailyForecast') }; const details = this.model.get('details'); -html.push('
'); - html.push(this.templateCurrently(currently)); - html.push(this.templateForecast(forcastToday)); - html.push(this.templateDetails(details)); + html.push('
'); + html.push(templates.templateCurrently(currently)); + html.push(templates.templateForecast(forcastToday)); + html.push(templates.templateDetails(details)); html.push('
'); html.push('
'); diff --git a/src/v1/js/Traffic.js b/src/v1/js/Traffic.js index 871c459..9e47e39 100644 --- a/src/v1/js/Traffic.js +++ b/src/v1/js/Traffic.js @@ -25,6 +25,7 @@ const TrafficModel = Backbone.Model.extend({ const hour = (new Date()).getHours(); const day = new Date().getDay(); + console.log('>> day', day); let doRequest = false; if (day !== 0 && day !== 6) @@ -39,6 +40,7 @@ const TrafficModel = Backbone.Model.extend({ else this.set('mode', 0); + console.log('doRequest', doRequest); console.log('Delay', delay); this.timerID = setTimeout( () => this.tick(), diff --git a/src/v1/js/libs/templates.js b/src/v1/js/libs/templates.js index bbe24f8..516b75b 100644 --- a/src/v1/js/libs/templates.js +++ b/src/v1/js/libs/templates.js @@ -62,7 +62,82 @@ const templates = { 'openInFS' : _.template(`
Open in Foursquare
`), - 'map': _.template('
') + 'map': _.template('
'), + 'templateCurrently': _.template(` +
+
<%=summary%>
+
+ <%=tempMax%>° + <%=tempMin%>° +
+
<%=temperature%>°
+
+ `), + 'templateForecast': _.template(` +
+

Forecast

+
+ <%_.forEach(today, function(i) {%> +
+
<%=i.time %>
+
+
<%=~~(i.temp)%>°
+
+ <%}) %> +
+ +
+
+ <%_.forEach(daily, function(i) {%> +
+
<%=i.time %>
+
+
<%=~~(i.tempHigh)%>°
+
<%=~~(i.tempLow)%>°
+
+ <%}) %> +
+ +
+
+ `), + 'templateDetails': _.template(` +
+

Details

+
+
Humidity
+
<%=~~(humidity * 100) %>%
+
+
+
Visibility
+
<%=visibility %>km
+
+
+
UV Index
+
<%=uvIndex %>
+
+
+
<%=summary%>
+
+

Wind & Pressure

+
+
Wind
+
<%=windSpeed %>km/h
+
Barometer
+
<%=pressure %>mBar
+ +
+

Sun & Moon

+
+
Sunrise
+
<%=sunriseTime %>
+
Sunset
+
<%=sunsetTime %>
+ +
+ +
+ `) }; module.exports = templates;