diff --git a/api/controllers/ActionController.js b/api/controllers/ActionController.js index b4bcba71a0..27f756264d 100644 --- a/api/controllers/ActionController.js +++ b/api/controllers/ActionController.js @@ -19,7 +19,7 @@ * @param {} callback * @return */ -var haveRights = function(action, user,callback){ +function haveRights(action, user,callback){ Action.findOne({id : action, user: user}, function(err, action){ if(err) return callback(err); diff --git a/api/controllers/AlarmController.js b/api/controllers/AlarmController.js index 08ab3f8d80..d30241d7f3 100644 --- a/api/controllers/AlarmController.js +++ b/api/controllers/AlarmController.js @@ -94,7 +94,7 @@ module.exports = { AlarmService.destroyAlarm(req.param('id'), function(err,alarm){ if(err) return res.json(err); - res.json(alarm) + res.json(alarm); }); } }; \ No newline at end of file diff --git a/api/controllers/HouseController.js b/api/controllers/HouseController.js index 916104a940..b574ca1f69 100644 --- a/api/controllers/HouseController.js +++ b/api/controllers/HouseController.js @@ -155,17 +155,17 @@ module.exports = { * @return */ getrelationhouse: function(req,res,next){ - var request = "SELECT userhouserelation.id AS id, user.id AS userId, CONCAT(user.firstname, ' ', user.lastname) as userName, house.id as houseId, house.name as houseName, userhouserelationtype " + var request = "SELECT userhouserelation.id AS id, user.id AS userId, CONCAT(user.firstname, ' ', user.lastname) as userName, house.id as houseId, house.name as houseName, userhouserelationtype "; request+= "FROM userhouserelation "; request+= "JOIN user ON (userhouserelation.user = user.id) "; request+= "JOIN house ON (userhouserelation.house = house.id) "; request+= "WHERE house IN ( SELECT house FROM userhouserelation WHERE userhouserelationtype = 1 "; request+= "AND user = ?) "; - UserHouseRelation.query(request,[req.session.User.id], function UserHouseRelation(err,UserHouseRelation){ + UserHouseRelation.query(request,[req.session.User.id], function UserHouseRelation(err,userHouseRelation){ if(err) res.json(err); - res.json(UserHouseRelation); + res.json(userHouseRelation); }); }, diff --git a/api/controllers/LauncherController.js b/api/controllers/LauncherController.js index fe26fec895..15a1f7c366 100644 --- a/api/controllers/LauncherController.js +++ b/api/controllers/LauncherController.js @@ -37,7 +37,7 @@ function haveRights(launcher, user,callback){ * @param {} callback * @return */ -var haveRightsAction = function(action, user,callback){ +function haveRightsAction (action, user,callback){ Action.findOne({id : action, user: user}, function(err, action){ if(err) return callback(err); @@ -53,7 +53,7 @@ var haveRightsAction = function(action, user,callback){ * @param {} callback * @return */ -var haveRightsState = function(state, user,callback){ +function haveRightsState(state, user,callback){ State.findOne({id : state, user: user}, function(err, state){ if(err) return callback(err); diff --git a/api/controllers/RoomController.js b/api/controllers/RoomController.js index 0214360f6f..91e1ac55bf 100755 --- a/api/controllers/RoomController.js +++ b/api/controllers/RoomController.js @@ -21,12 +21,12 @@ * @param {} callback * @return */ -var haveRights = function (user,room,callback){ +function haveRights (user,room,callback){ Room.findOne({id:room}, function(err, room){ if(err) callback(err); if(!room){ - callback(false,false) + callback(false,false); }else{ UserHouseRelation.findOne({house: room.house, user: user, userhouserelationtype: sails.config.userhouserelationtype.Admin }, function(err, userHouseRelation){ if(err) callback(err); diff --git a/api/controllers/ScriptController.js b/api/controllers/ScriptController.js index 290e9498ce..168323bfd5 100644 --- a/api/controllers/ScriptController.js +++ b/api/controllers/ScriptController.js @@ -18,7 +18,7 @@ */ function validFileName(name){ var reg = /[a-zA-Z0-9]+\.js$/; - return reg.test(name) + return reg.test(name); } function stringifyError (err, filter, space) { diff --git a/api/controllers/SessionController.js b/api/controllers/SessionController.js index a3f83c9aed..87dfb5f1a2 100755 --- a/api/controllers/SessionController.js +++ b/api/controllers/SessionController.js @@ -80,7 +80,7 @@ module.exports = { var usernamePasswordRequiredError = [{ name: 'usernamePasswordRequired', message: 'You must enter both a username and password.' - }] + }]; req.flash('error', usernamePasswordRequiredError); return res.redirect('/login'); @@ -97,7 +97,7 @@ module.exports = { var noAccountError = [{ name: 'noAccount', message: 'The email address ' + req.param('email') + ' not found.' - }] + }]; req.flash('error', noAccountError); @@ -114,7 +114,7 @@ module.exports = { var usernamePasswordMismatchError = [{ name: 'usernamePasswordMismatch', message: 'Invalid username and password combination.' - }] + }]; req.flash('error', usernamePasswordMismatchError); res.redirect('/login'); return; diff --git a/api/controllers/StateController.js b/api/controllers/StateController.js index 1bf5312fd1..fd293ed989 100644 --- a/api/controllers/StateController.js +++ b/api/controllers/StateController.js @@ -17,7 +17,7 @@ * @param {} callback * @return */ -var haveRights = function(state, user,callback){ +function haveRights(state, user,callback){ State.findOne({id : state, user: user}, function(err, state){ if(err) return callback(err); diff --git a/api/controllers/TimerController.js b/api/controllers/TimerController.js index f04d4001bc..0f8896fce9 100644 --- a/api/controllers/TimerController.js +++ b/api/controllers/TimerController.js @@ -26,7 +26,7 @@ module.exports = { */ create:function(req,res,next){ if(!req.param('duration')) - return res.json('Missing parametres') + return res.json('Missing parametres'); // defaults name var name = 'Timer'; diff --git a/api/models/Alarm.js b/api/models/Alarm.js index 96f37e9773..ee727d81b8 100644 --- a/api/models/Alarm.js +++ b/api/models/Alarm.js @@ -20,7 +20,7 @@ module.exports = { // new time type because time does not exist in sails time: function(time){ var re = /^[0-2]\d:[0-5]\d$/ ; - return (time != '' && time.match(re)); + return (time !== '' && time.match(re)); }, }, diff --git a/api/models/Contact.js b/api/models/Contact.js index 87a41d1336..7fdcbadce0 100644 --- a/api/models/Contact.js +++ b/api/models/Contact.js @@ -33,7 +33,7 @@ module.exports = { }, fullname: function() { - return this.firstname + ' ' + this.lastname + return this.firstname + ' ' + this.lastname; }, email:{ diff --git a/api/models/House.js b/api/models/House.js index 23fa80846c..3d642a1a31 100755 --- a/api/models/House.js +++ b/api/models/House.js @@ -95,9 +95,9 @@ module.exports = { var checkifAllDestroyed = function(){ if(nbOk == values.length*nbThingsToDestroy) next(); - } + }; - if(values.length == 0) + if(values.length === 0) return next(); for(i = 0; i 6) ? ip : default_ip; this.port = (port != undefined && port > 0) ? port : default_port; }; -/** - * Description - * @method command - * @param {} threeByteArray - * @return - */ +/** + * Description + * @method command + * @param {} threeByteArray + * @return + */ WifiBox.prototype.command = function (threeByteArray) { var buffer = new Buffer(threeByteArray); this.client.send(buffer @@ -61,17 +61,17 @@ WifiBox.prototype.command = function (threeByteArray) { console.log("udp error:" + err); throw err; } else { - console.log('bytes send: ' + [threeByteArray[0], threeByteArray[1], threeByteArray[2]]) + console.log('bytes send: ' + [threeByteArray[0], threeByteArray[1], threeByteArray[2]]); } } ); -} +}; -/** - * Description - * @method toString - * @return BinaryExpression - */ +/** + * Description + * @method toString + * @return BinaryExpression + */ WifiBox.prototype.toString = function () { return 'WifiBox: { ip:' + this.ip + ':' + this.port + '}'; }; diff --git a/api/services/MilightService.js b/api/services/MilightService.js index a04a5854a7..2d11a89905 100644 --- a/api/services/MilightService.js +++ b/api/services/MilightService.js @@ -131,7 +131,7 @@ module.exports = { * @return */ hue: function(userId,color,callback){ - if(lastLampId == null) return callback(false); + if(lastLampId === null) return callback(false); connectWifiBox(lastLampId, function (success, box, zone){ // if we can't find the wifi module associated with the lamp @@ -153,7 +153,7 @@ module.exports = { * @return */ brightness: function (userId,brightness, callback){ - if(lastLampId == null) return callback(false); + if(lastLampId === null) return callback(false); connectWifiBox(lastLampId, function (success, box, zone){ // if we can't find the wifi module associated with the lamp @@ -174,7 +174,7 @@ module.exports = { * @return */ effectModeNext: function(userId,callback){ - if(lastLampId == null) return callback(false); + if(lastLampId === null) return callback(false); connectWifiBox(lastLampId, function (success, box, zone){ // if we can't find the wifi module associated with the lamp @@ -195,7 +195,7 @@ module.exports = { * @return */ whiteMode: function(userId,callback){ - if(lastLampId == null) return callback(false); + if(lastLampId === null) return callback(false); connectWifiBox(lastLampId, function (success, box, zone){ // if we can't find the wifi module associated with the lamp diff --git a/api/services/MotionService.js b/api/services/MotionService.js index 110ec3fd2e..7a02c9c291 100644 --- a/api/services/MotionService.js +++ b/api/services/MotionService.js @@ -53,7 +53,7 @@ module.exports = { Motion.query(request,[roomId], function(err, motions){ if(err) return callback(err); - callback(null, motions) + callback(null, motions); }); }, @@ -75,7 +75,7 @@ module.exports = { Motion.query(request,[houseId], function(err, motions){ if(err) return callback(err); - callback(null, motions) + callback(null, motions); }); }, diff --git a/api/services/MusicService.js b/api/services/MusicService.js index f4f2a63b1d..3b7e3e8b1c 100644 --- a/api/services/MusicService.js +++ b/api/services/MusicService.js @@ -177,7 +177,7 @@ module.exports = { * @method checkIfDone * @return */ - var checkIfDone = function(){ + function checkIfDone(){ inserted++; if(inserted >= size) callback(null); @@ -210,7 +210,7 @@ module.exports = { checkIfDone(); } else{ - if(tags.title == null) + if(tags.title === null) tags.title = file; // insert the music in the database diff --git a/api/services/NotificationService.js b/api/services/NotificationService.js index d249293a97..cbceea0af3 100755 --- a/api/services/NotificationService.js +++ b/api/services/NotificationService.js @@ -12,18 +12,18 @@ var request = require("request"); module.exports = { - /** - * Description - * @method newNotification - * @param {} title - * @param {} content - * @param {} priority - * @param {} icon - * @param {} iconColor - * @param {} userId - * @param {} callback - * @return - */ + /** + * Description + * @method newNotification + * @param {} title + * @param {} content + * @param {} priority + * @param {} icon + * @param {} iconColor + * @param {} userId + * @param {} callback + * @return + */ newNotification : function(title, content, priority, icon, iconColor,userId, callback) { var NotificationObj = { title: title, @@ -41,7 +41,7 @@ module.exports = { SocketService.sendDesktopMessageUser(userId, 'newNotification' , notification, function(err, nbOfMsgSent){ if(err) return callback(err); - if(nbOfMsgSent == 0){ + if(nbOfMsgSent === 0){ pushBulletService.sendNotificationUser(notification.user, notification.id, notification.title, notification.content, callback); }else{ callback(null); diff --git a/api/services/RoomService.js b/api/services/RoomService.js index e6e1baf120..443530f621 100644 --- a/api/services/RoomService.js +++ b/api/services/RoomService.js @@ -27,7 +27,7 @@ module.exports = { Motion.query(request,[roomId], function(err, motions){ if(err) return callback(err); - callback(null, (motions.length == 0)) + callback(null, (motions.length === 0)); }); } }; \ No newline at end of file diff --git a/api/services/ScriptService.js b/api/services/ScriptService.js index a35330715f..d5e508fd9f 100644 --- a/api/services/ScriptService.js +++ b/api/services/ScriptService.js @@ -18,7 +18,7 @@ var fs = require("fs"); */ function validFileName (name){ var reg = /[a-zA-Z0-9]+\.js$/; - return reg.test(name) + return reg.test(name); } /** @@ -28,7 +28,7 @@ function validFileName (name){ * @param {} callback * @return */ -var loadInSandbox = function(path, callback){ +function loadInSandbox (path, callback){ callback = callback || function(){}; fs.readdir(path, function (err, files) { diff --git a/api/services/SerialPortService.js b/api/services/SerialPortService.js index d78bc53384..4a916404d3 100644 --- a/api/services/SerialPortService.js +++ b/api/services/SerialPortService.js @@ -14,7 +14,7 @@ * @param {} callback * @return */ -var motionSensorExist = function(code,callback){ +function motionSensorExist(code,callback){ MotionSensor.findOne({code : code}, function(err, motionSensor){ if(err) return sails.log.warn('SerialPortService : motionSensorExist : ' + err); @@ -57,6 +57,7 @@ module.exports = { // each time a serial port message is received sp.on("data", function (data) { + try { // trying to parse JSON received diff --git a/api/services/SocketService.js b/api/services/SocketService.js index 88b9e46f11..f72f9efd87 100644 --- a/api/services/SocketService.js +++ b/api/services/SocketService.js @@ -15,7 +15,7 @@ * @param {} callback * @return */ -var getUserSocketsId = function(userId,callback){ +function getUserSocketsId (userId,callback){ Socket.find({user : userId}, function(err,sockets){ if(err) return callback('SocketService : getUserSocketId : ' + err); @@ -116,7 +116,7 @@ module.exports = { */ joinRoom: function(userId, roomName,callback){ getUserSocketsId(userId,function(sockets){ - if(!sockets || sockets.length == 0) return callback(null, 0); + if(!sockets || sockets.length === 0) return callback(null, 0); for(var i = 0;i