diff --git a/fonts/fujicons.css b/fonts/fujicons.css new file mode 100644 index 0000000..1f0cf7f --- /dev/null +++ b/fonts/fujicons.css @@ -0,0 +1,205 @@ +@font-face { + font-family: 'Fujicons'; + font-style: normal; + font-weight: 400; + src: url(fujicons.ttf) format('truetype'); + unicode-range: U+0-10FFFF; +} + + +.fa { + display: inline-block; + font: normal normal normal 14px/1 Fujicons; + font-size: inherit; + text-rendering: auto; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} +/* makes the font 33% larger relative to the icon container */ +.fa-lg { + font-size: 1.33333333em; + line-height: 0.75em; + vertical-align: -15%; +} +.fa-2x { + font-size: 2em; +} +.fa-3x { + font-size: 3em; +} +.fa-4x { + font-size: 4em; +} +.fa-5x { + font-size: 5em; +} +.fa-fw { + width: 1.28571429em; + text-align: center; +} +.fa-ul { + padding-left: 0; + margin-left: 2.14285714em; + list-style-type: none; +} +.fa-ul > li { + position: relative; +} +.fa-li { + position: absolute; + left: -2.14285714em; + width: 2.14285714em; + top: 0.14285714em; + text-align: center; +} +.fa-li.fa-lg { + left: -1.85714286em; +} +.fa-border { + padding: .2em .25em .15em; + border: solid 0.08em #eeeeee; + border-radius: .1em; +} +.fa-pull-left { + float: left; +} +.fa-pull-right { + float: right; +} +.fa.fa-pull-left { + margin-right: .3em; +} +.fa.fa-pull-right { + margin-left: .3em; +} +/* Deprecated as of 4.4.0 */ +.pull-right { + float: right; +} +.pull-left { + float: left; +} +.fa.pull-left { + margin-right: .3em; +} +.fa.pull-right { + margin-left: .3em; +} +.fa-spin { + -webkit-animation: fa-spin 2s infinite linear; + animation: fa-spin 2s infinite linear; +} +.fa-pulse { + -webkit-animation: fa-spin 1s infinite steps(8); + animation: fa-spin 1s infinite steps(8); +} +@-webkit-keyframes fa-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +@keyframes fa-spin { + 0% { + -webkit-transform: rotate(0deg); + transform: rotate(0deg); + } + 100% { + -webkit-transform: rotate(359deg); + transform: rotate(359deg); + } +} +.fa-rotate-90 { + -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=1)"; + -webkit-transform: rotate(90deg); + -ms-transform: rotate(90deg); + transform: rotate(90deg); +} +.fa-rotate-180 { + -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)"; + -webkit-transform: rotate(180deg); + -ms-transform: rotate(180deg); + transform: rotate(180deg); +} +.fa-rotate-270 { + -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=3)"; + -webkit-transform: rotate(270deg); + -ms-transform: rotate(270deg); + transform: rotate(270deg); +} +.fa-flip-horizontal { + -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0, mirror=1)"; + -webkit-transform: scale(-1, 1); + -ms-transform: scale(-1, 1); + transform: scale(-1, 1); +} +.fa-flip-vertical { + -ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2, mirror=1)"; + -webkit-transform: scale(1, -1); + -ms-transform: scale(1, -1); + transform: scale(1, -1); +} +:root .fa-rotate-90, +:root .fa-rotate-180, +:root .fa-rotate-270, +:root .fa-flip-horizontal, +:root .fa-flip-vertical { + filter: none; +} +.fa-stack { + position: relative; + display: inline-block; + width: 2em; + height: 2em; + line-height: 2em; + vertical-align: middle; +} +.fa-stack-1x, +.fa-stack-2x { + position: absolute; + left: 0; + width: 100%; + text-align: center; +} +.fa-stack-1x { + line-height: inherit; +} +.fa-stack-2x { + font-size: 2em; +} +.fa-inverse { + color: #ffffff; +} + + +.fa-back:before { + content: ""; +} + +.fa-forward:before { + content: ""; +} + +.fa-globe:before { + content: "\EA12" +} + +.fa-up:before { + content: "\E925" +} + +.fa-down:before { + content: "\E922" +} + +.fa-work:before { + content: "\E998" +} + +.fa-home:before { + content: "\EA1E" +} diff --git a/fonts/fujicons.ttf b/fonts/fujicons.ttf new file mode 100755 index 0000000..a323b19 Binary files /dev/null and b/fonts/fujicons.ttf differ diff --git a/gulp/build.js b/gulp/build.js index 1c8b5f8..134cc5e 100644 --- a/gulp/build.js +++ b/gulp/build.js @@ -70,3 +70,9 @@ 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')); }); + + +gulp.task('fujicons', function() { + gulp.src(['fonts/fujicons.css']).pipe(gulp.dest('live/fonts')); + gulp.src(['fonts/fujicons.ttf']).pipe(gulp.dest('live/fonts')); +}); diff --git a/gulpfile.js b/gulpfile.js index d468464..71232d1 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -4,4 +4,4 @@ const requireDir = require('require-dir'); requireDir('./gulp'); -gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham']); +gulp.task('default', ['bundleBackbone', 'styles', 'copy', 'customMUI', 'vendor', 'fonts', 'gotham', 'fujicons']); diff --git a/package-lock.json b/package-lock.json index 86622d0..ccda070 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/server.js b/server.js index 9a6d81a..2d7c503 100644 --- a/server.js +++ b/server.js @@ -110,7 +110,7 @@ app.get('/rightbyme', cache('15 minutes'), (req, res) => { } }); -app.get('/nearbydetail', cache('15 minutes'), (req, res) => { +app.get('/nearbydetail'/*, cache('15 minutes')*/, (req, res) => { if (req.query.hasOwnProperty('id')) rightbyme.doGetMoreDetail(req.query.id) .then((d) => { diff --git a/server/RightByMe.js b/server/RightByMe.js index cfb59e8..9b56a6c 100644 --- a/server/RightByMe.js +++ b/server/RightByMe.js @@ -103,7 +103,7 @@ function doYelpSearch(data = {}) { yelpSearch.latitude = payLoad.latitude; yelpSearch.longitude = payLoad.longitude; - // yelpSearch.radius = 250; + yelpSearch.radius = 250; yelpSearch.sort_by = 'distance'; logger.debug(yelpSearch); client.search(yelpSearch).then(response => { diff --git a/src/service-worker.js b/src/service-worker.js index 41c11ea..9dacf22 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.483' }; +const CACHE_VERSION = { 'version': '0.0.538' }; const dataCacheName = 'jubileeData-v1'; const cacheName = 'jubilee-final-1'; const filesToCache = [ diff --git a/src/v1/index.html b/src/v1/index.html index ad2b83b..3067ec0 100644 --- a/src/v1/index.html +++ b/src/v1/index.html @@ -7,8 +7,8 @@ Jubilee - + @@ -31,8 +31,8 @@
@@ -64,7 +64,7 @@
Latest news
diff --git a/src/v1/js/Forecast.js b/src/v1/js/Forecast.js index 7a3780e..6b99f85 100644 --- a/src/v1/js/Forecast.js +++ b/src/v1/js/Forecast.js @@ -62,8 +62,8 @@ const ForecastView = Backbone.View.extend({
<%=summary%>
- vertical_align_top<%=tempMax%>° - vertical_align_bottom<%=tempMin%>° + <%=tempMax%>° + <%=tempMin%>°
<%=temperature%>°
@@ -186,7 +186,7 @@ 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('
'); html.push(this.templateCurrently(currently)); html.push(this.templateForecast(forcastToday)); html.push(this.templateDetails(details)); diff --git a/src/v1/js/Nearby.js b/src/v1/js/Nearby.js index bc0ca88..68fb729 100644 --- a/src/v1/js/Nearby.js +++ b/src/v1/js/Nearby.js @@ -25,7 +25,7 @@ const fsItemView = Backbone.View.extend({ 'tagName': 'div', 'className': 'itemRow mui--align-middle', 'template': _.template(` -<%= name %> <%= category %> `), +<%= name %> <%= category %> `), 'initialize': function() { this.render(); }, @@ -36,6 +36,7 @@ const fsItemView = Backbone.View.extend({ }, 'render': function() { + console.log(this.model.attributes); this.$el.html(this.template(this.model.toJSON())); } }); @@ -136,7 +137,7 @@ const NearbyView = Backbone.View.extend({ this.fsCollection.bind('reset', this.render, this); this.eventBus.on('focused', this.focused, this); - this.other = $(''); + this.other = $(''); }, 'events': { 'click .itemRow': 'doClick' @@ -176,7 +177,7 @@ const NearbyView = Backbone.View.extend({ console.log('Do click', d); const id = get(d, 'currentTarget.dataset.id', ''); console.log(id); - + this.eventBus.trigger('showVenueDetail', id); const fsdetail = new FSDetailView({ 'fsID':id }); }, 'focused': function() { console.log('>> Nearby received focus msg'); diff --git a/src/v1/js/News.js b/src/v1/js/News.js index 5a8a5b8..09b2e35 100644 --- a/src/v1/js/News.js +++ b/src/v1/js/News.js @@ -108,7 +108,7 @@ const NewsView = Backbone.View.extend({
Latest news
`), diff --git a/src/v1/js/NewsList.js b/src/v1/js/NewsList.js index ec560c4..70d7b08 100644 --- a/src/v1/js/NewsList.js +++ b/src/v1/js/NewsList.js @@ -18,7 +18,7 @@ const newsCollection = new NewsCollection(); const NewsItemView = Backbone.View.extend({ 'tagName': 'div', - 'className' : 'newsItem mui-container', + 'className' : 'newsItem', 'template': _.template(`
<%=title%>
diff --git a/src/v1/js/RightByMe.js b/src/v1/js/RightByMe.js index 08095f9..8ba8fa3 100644 --- a/src/v1/js/RightByMe.js +++ b/src/v1/js/RightByMe.js @@ -4,6 +4,7 @@ const Backbone = require('backbone'); const request = require('request'); const { get, isEmpty } = require('lodash'); const { maybePluralize } = require('./libs/utils'); +const templates = require('./libs/templates'); const ByMeModel = Backbone.Model.extend({ 'initialize': function() { @@ -77,53 +78,7 @@ const ByMeView = Backbone.View.extend({ 'id':'byme', 'className': '', 'template': _.template('
'), - 'yelpTemplate': _.template(`
-
- -
-
-<%= yelp.reviewCount %> review -
-
- -
-
- `), - 'tipsTemplate': _.template(` -
-
Tips
-
- <%_.forEach(tips, function(i) {%> -
- <%=i %> -
- <%}) %> -
-
- `), - 'imagesTemplate': _.template(` -
-
- <%_.forEach(images, function(i) {%> -
- -
- <%}) %> -
-
- `), - 'tweetsTemplate': _.template(` -
-
Tweets
-
- <%_.forEach(tweets, function(i) {%> -
- <%=i %> -
- <%}) %> -
-
- `), + 'initialize': function(options) { this.eventBus = options.eventBus; this.location = options.location; @@ -169,16 +124,16 @@ const ByMeView = Backbone.View.extend({ // this.imagesTemplate(this.model.toJSON()), this.yelpTemplate(this.model.toJSON()), this.tipsTemplate(this.model.toJSON()) if (!isEmpty(m.images)) - contents.push(this.imagesTemplate(m)); + contents.push(templates.imagesTemplate(m)); if (!isEmpty(m.yelp)) - contents.push(this.yelpTemplate(m)); + contents.push(templates.yelpTemplate(m)); if (!isEmpty(m.tips)) - contents.push(this.tipsTemplate(m)); + contents.push(templates.tipsTemplate(m)); if (!isEmpty(m.tweets)) - contents.push(this.tweetsTemplate(m)); + contents.push(templates.tweetsTemplate(m)); this.$el.html(contents.join('')); // console.log(this.el); diff --git a/src/v1/js/Traffic.js b/src/v1/js/Traffic.js index 65aaf7a..8a54631 100644 --- a/src/v1/js/Traffic.js +++ b/src/v1/js/Traffic.js @@ -37,9 +37,9 @@ const TrafficModel = Backbone.Model.extend({ 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) + if (day === 0 || day === 6) delay = toHour(); - else + else delay = ( ((hour >= 7) && (hour <= 9)) || ((hour >= 17) && (hour <= 19)) ) ? 600000 : toHour(); console.log('Delay', delay); @@ -141,7 +141,7 @@ const TrafficView = Backbone.View.extend({ }, 'template': _.template(`
-
<%= dest.toLowerCase() %> <%=readable%> to <%= dest.toLowerCase() %>
+
mui--align-middle "> <%=readable%> to <%= dest.toLowerCase() %>
<%=traffic %>
diff --git a/src/v1/js/VenueDetail.js b/src/v1/js/VenueDetail.js new file mode 100644 index 0000000..1f38fcf --- /dev/null +++ b/src/v1/js/VenueDetail.js @@ -0,0 +1,106 @@ +const $ = require('jquery'); +const _ = require('underscore'); +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 VenueDetailModel = Backbone.Model.extend({ + 'initialize': function() { + this.listenTo(this, 'change:id', this.newId); + }, + 'newId': function() { + console.log('>> ID changed:', this.get('id')); + this.getVenue(); + }, + 'getVenue': function() { + const id = this.get('id'); + request({ + 'url': `${window.loc}/nearbydetail`, + 'method': 'GET', + 'qs': { + 'id': id + } + }, function(err, res, body) { + console.log('statusCode', res.statusCode); + if (err) + console.error(err); + else{ + // console.log(body); + const fsJSON = JSON.parse(body); + // console.log(fsJSON); + + this.set('details', fsJSON); + // console.log(body); + } + }.bind(this)); + } + +}); + +const VenueDetailView = Backbone.View.extend({ + 'initialize': function(options) { + this.eventBus = options.eventBus; + + this.model.bind('change:details', this.doRender, this); + this.eventBus.on('showVenueDetail', this.showNewsPanel, this); + }, + + 'showNewsPanel': function(id) { + console.log('Showing venue details', id); + const prevId = this.model.get('id'); + + this.model.set('id', id); + + this.$newPanel = createPanel({ 'title':'Venue details', 'divId':'VenueDetail' }); + + this.$el = addPanel(this.$newPanel); + + this.$el.empty(); + this.$newPanel.show(); + + if (prevId === id) + this.doRender(); + }, + 'events': { + 'click .closebutton': 'doClick' + }, + 'doClick': function(d) { + console.log('Do click', d); + const id = get(d, 'currentTarget', ''); + console.log(id); + // this.eventBus.trigger('showNews', id); + }, + 'doClose': function(d) { + console.log('close??'); + }, + 'doRender': function() { + const contents = []; + const m = this.model.get('details'); + // this.imagesTemplate(this.model.toJSON()), this.yelpTemplate(this.model.toJSON()), this.tipsTemplate(this.model.toJSON()) + + contents.push(templates.venueTitle(m)); + + if (!isEmpty(m.images)) + contents.push(templates.imagesTemplate(m)); + + if (!isEmpty(m.yelp)) + contents.push(templates.yelpTemplate(m)); + + if (!isEmpty(m.tips)) + contents.push(templates.tipsTemplate(m)); + + if (!isEmpty(m.tweets)) + contents.push(templates.tweetsTemplate(m)); + + contents.push(templates.openInFS(m)); + this.$el.html(contents.join('')); + + } + +}); + +module.exports = { VenueDetailModel, VenueDetailView }; + diff --git a/src/v1/js/Weather.js b/src/v1/js/Weather.js index 8bb8004..68d43a6 100644 --- a/src/v1/js/Weather.js +++ b/src/v1/js/Weather.js @@ -40,7 +40,7 @@ const weatherItemView = Backbone.View.extend({ For <%=city%> to <%= readdate %>
`), 'initialize': function() { @@ -201,7 +201,7 @@ const WeatherView = Backbone.View.extend({ console.log('>> Weather received focus msg'); if (!this.model.has('log')) { console.log('No log yet'); - + return ; } const now = new Date().getTime(); diff --git a/src/v1/js/app.js b/src/v1/js/app.js index b3174c3..d400364 100644 --- a/src/v1/js/app.js +++ b/src/v1/js/app.js @@ -14,6 +14,7 @@ const { NewsModel, NewsView } = require('./News'); const { NewsCardModel, NewsCardView } = require('./NewsViewer'); const { NewsListModel, NewsListView } = require('./NewsList'); const { ByMeModel, ByMeView } = require('./RightByMe'); +const { VenueDetailModel, VenueDetailView } = require('./VenueDetail'); const { AgendaModel, AgendaView } = require('./Agenda'); const { TrafficModel, TrafficView } = require('./Traffic'); var app = app || {}; @@ -60,7 +61,7 @@ else app.newsCard = new NewsCardView({ 'model': new NewsCardModel(), 'eventBus': app.eventBus }); - app.newsList = new NewsListView({'model': new NewsListModel(), 'eventBus' : app.eventBus}); + app.newsList = new NewsListView({ 'model': new NewsListModel(), 'eventBus' : app.eventBus }); app.news = new NewsView({ 'model': new NewsModel(), 'eventBus': app.eventBus, 'el':'#newsShell' }); @@ -70,6 +71,8 @@ else app.traffic = new TrafficView({ 'model': new TrafficModel(), 'eventBus': app.eventBus, 'location': app.locationModel, 'el':'#traffic' }); + app.newsCard = new VenueDetailView({ 'model': new VenueDetailModel(), 'eventBus': app.eventBus }); + app.updateOnlineStatus = function(event) { if (navigator.onLine) // handle online status diff --git a/src/v1/js/libs/panel.js b/src/v1/js/libs/panel.js index 63b4850..dd00ddc 100644 --- a/src/v1/js/libs/panel.js +++ b/src/v1/js/libs/panel.js @@ -10,7 +10,7 @@ function createPanel(params) {
@@ -22,7 +22,7 @@ function createPanel(params) {
-
+
diff --git a/src/v1/js/libs/reducers.js b/src/v1/js/libs/reducers.js index fe35174..08b8d29 100644 --- a/src/v1/js/libs/reducers.js +++ b/src/v1/js/libs/reducers.js @@ -88,7 +88,7 @@ const reduceNearby = function(item) { obj.id = get(item, 'venue.id', ''); obj.name = get(item, 'venue.name', ''); obj.category = get(categories[0], 'name', ''); - obj.icon = `${get(categories[0], 'icon.prefix', '')}${get(categories[0], 'icon.suffix', '')}`; + obj.icon = `${get(categories[0], 'icon.prefix', '')}32${get(categories[0], 'icon.suffix', '')}`; return obj; }; diff --git a/src/v1/js/libs/templates.js b/src/v1/js/libs/templates.js new file mode 100644 index 0000000..0092f0b --- /dev/null +++ b/src/v1/js/libs/templates.js @@ -0,0 +1,67 @@ +const _ = require('underscore'); + +const templates = { + + 'empty': _.template('
'), + 'yelpTemplate': _.template(`
+
+ +
+
+<%= yelp.reviewCount %> review +
+
+ +
+
+ `), + 'tipsTemplate': _.template(` +
+
+
Tips
+
+
+
+ <%_.forEach(tips, function(i) {%> +
+ <%=i %> +
+ <%}) %> +
+
+ `), + 'imagesTemplate': _.template(` +
+
+ <%_.forEach(images, function(i) {%> +
+ +
+ <%}) %> +
+
+ `), + 'tweetsTemplate': _.template(` +
+
+
Tweets
+
+
+
+ <%_.forEach(tweets, function(i) {%> +
+ <%=i %> +
+ <%}) %> +
+
+ `), + 'venueTitle' : _.template(` +
<%=name %>
+ `), + 'openInFS' : _.template(` +
Open in Foursquare
+ `) +}; + +module.exports = templates;