events and weather
This commit is contained in:
parent
996c2d6d1f
commit
ca1b7b15da
1
.gitignore
vendored
1
.gitignore
vendored
@ -188,3 +188,4 @@ node_modules
|
|||||||
/libpeerconnection.log
|
/libpeerconnection.log
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
testem.log
|
testem.log
|
||||||
|
/lib/newdata.json
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
(function($) {
|
(function($) {
|
||||||
|
|
||||||
var TodayDataModel = Backbone.Model.extend({
|
let TodayDataModel = Backbone.Model.extend({
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.set('url', '/today/data');
|
this.set('url', '/today/data');
|
||||||
|
|
||||||
@ -17,15 +17,15 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
var webSocketModel = new SOCKETMANAGER();
|
const webSocketModel = new SOCKETMANAGER();
|
||||||
webSocketModel.turnOn();
|
webSocketModel.turnOn();
|
||||||
|
|
||||||
var clock = new Clock({model: new ClockModel()});
|
window.clock = new Clock({model: new ClockModel()});
|
||||||
var weatherModel = new WeatherModel({lat: 55.95, long: -4.5666667});
|
let weatherModel = new WeatherModel({geo:{coords:{latitude: 55.95, longitude: -4.5666667}}});
|
||||||
var weather = new Weather({model: weatherModel});
|
window.weather = new Weather({model: weatherModel});
|
||||||
|
|
||||||
var trainModel = new TrainModel();
|
let trainModel = new TrainModel({from:'hym', to:'dbe'});
|
||||||
var train = new Train({model: trainModel});
|
window.train = new Train({model: trainModel});
|
||||||
|
|
||||||
webSocketModel.setWeather(weatherModel);
|
webSocketModel.setWeather(weatherModel);
|
||||||
webSocketModel.setTrain(trainModel);
|
webSocketModel.setTrain(trainModel);
|
||||||
@ -36,3 +36,4 @@
|
|||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
|
@ -2,13 +2,14 @@ var WEBSOCKET = function(model) {
|
|||||||
|
|
||||||
var wsUrl = ['localhost','silvrtree.co.uk'];
|
var wsUrl = ['localhost','silvrtree.co.uk'];
|
||||||
var wsPort = '9000';
|
var wsPort = '9000';
|
||||||
|
let useUrl = 0;
|
||||||
|
|
||||||
if ('https:' === document.location.protocol) {
|
if ('https:' === document.location.protocol) {
|
||||||
wsUrl = 'wss://' + wsUrl[1] + '';
|
wsUrl = 'wss://' + wsUrl[useUrl] + '';
|
||||||
wsPort = '';
|
wsPort = '';
|
||||||
} else {
|
} else {
|
||||||
//wsUrl = 'ws://localhost:3001';
|
//wsUrl = 'ws://localhost:3001';
|
||||||
wsUrl = 'ws://' + wsUrl[1] + '';
|
wsUrl = 'ws://' + wsUrl[useUrl] + '';
|
||||||
wsPort = '';
|
wsPort = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
"tokenPath": "/oauth2/token"
|
"tokenPath": "/oauth2/token"
|
||||||
},
|
},
|
||||||
"authorization_uri": {
|
"authorization_uri": {
|
||||||
"redirect_uri": "http://www.silvrtree.co.uk/fitbit_auth_callback/",
|
"redirect_uri": "https://www.silvrtree.co.uk/fitbit_auth_callback/",
|
||||||
"response_type": "code",
|
"response_type": "code",
|
||||||
"scope": "activity nutrition profile settings sleep social weight heartrate",
|
"scope": "activity nutrition profile settings sleep social weight heartrate",
|
||||||
"state": "3(#0/!~"
|
"state": "3(#0/!~"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -35,7 +35,7 @@ today.setEmitter(busEmitter);
|
|||||||
|
|
||||||
// train = require('lib/train')
|
// train = require('lib/train')
|
||||||
/* ,submit = require('./routes/mongo/submit') */
|
/* ,submit = require('./routes/mongo/submit') */
|
||||||
;
|
|
||||||
|
|
||||||
let fs = require('fs');
|
let fs = require('fs');
|
||||||
const config = require('./config/config.json');
|
const config = require('./config/config.json');
|
||||||
@ -148,7 +148,6 @@ const tfile = 'fb-token.json';
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
const fitbit = new Fitbit(config.fitbit);
|
const fitbit = new Fitbit(config.fitbit);
|
||||||
|
|
||||||
// In a browser, http://localhost:4000/fitbit to authorize a user for the first time.
|
// In a browser, http://localhost:4000/fitbit to authorize a user for the first time.
|
||||||
@ -157,6 +156,24 @@ app.get('/fitbit', function(req, res) {
|
|||||||
res.redirect(fitbit.authorizeURL());
|
res.redirect(fitbit.authorizeURL());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.get( '/fb-profile', function( req, res, next ) {
|
||||||
|
fitbit.request({
|
||||||
|
uri: "https://api.fitbit.com/1/user/-/profile.json",
|
||||||
|
method: 'GET',
|
||||||
|
}, function( err, body, token ) {
|
||||||
|
if ( err ) return next( err );
|
||||||
|
var profile = JSON.parse( body );
|
||||||
|
// if token is not null, a refesh has happened and we need to persist the new token
|
||||||
|
if ( token )
|
||||||
|
persist.write( tfile, token, function( err ) {
|
||||||
|
if ( err ) return next( err );
|
||||||
|
res.send( '<pre>' + JSON.stringify( profile, null, 2 ) + '</pre>' );
|
||||||
|
});
|
||||||
|
else
|
||||||
|
res.send( '<pre>' + JSON.stringify( profile, null, 2 ) + '</pre>' );
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Callback service parsing the authorization token and asking for the access token. This
|
// Callback service parsing the authorization token and asking for the access token. This
|
||||||
// endpoint is refered to in config.fitbit.authorization_uri.redirect_uri. See example
|
// endpoint is refered to in config.fitbit.authorization_uri.redirect_uri. See example
|
||||||
// config below.
|
// config below.
|
||||||
@ -180,6 +197,7 @@ app.get('/fitbit_auth_callback', function(req, res, next) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
jsonfile.readFile('./fb-token.json', function(err, obj) {
|
jsonfile.readFile('./fb-token.json', function(err, obj) {
|
||||||
if (err) {
|
if (err) {
|
||||||
logger.error(err);
|
logger.error(err);
|
||||||
@ -187,7 +205,6 @@ jsonfile.readFile('./fb-token.json', function(err, obj) {
|
|||||||
fitbit.setToken(obj);
|
fitbit.setToken(obj);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
// });
|
// });
|
||||||
|
Loading…
Reference in New Issue
Block a user