1
0
Fork 0

Separate the sensors code on the client side.

This commit is contained in:
flabbergast 2013-12-03 22:40:06 +00:00
parent 57f2bcd488
commit f51d9172a7
4 changed files with 21 additions and 14 deletions

10
public/js/sensors/TM.js Normal file
View File

@ -0,0 +1,10 @@
// Temperature sensor / TM
exports.register = function (socket) {
socket.on('received-TM-temp', function (data) {
$('#TMtemp').html(data.content);
});
socket.on('received-TM-batt', function (data) {
$('#TMbatt').html(data.content);
});
}

View File

@ -2,6 +2,12 @@ var socket = io.connect('/');
var socket_connected = false;
var autoMode;
var TMsensor = require('./sensors/TM.js')
// Sensors: register on the socket
TMsensor.register(socket);
// Initialising the connection
socket.on('connected-to-server', function (data) {
// update the view based with the current server settings //
// generate a random id for this newly connected user //
@ -28,13 +34,3 @@ socket.on('sent-latest-logs', function (data) {
$('#logs-content').append(elt.timestamp + ": "+elt.message+"<br />");
});
});
// Sensors:
// TM
socket.on('received-TM-temp', function (data) {
$('#TMtemp').html(data.content);
});
socket.on('received-TM-batt', function (data) {
$('#TMbatt').html(data.content);
});

View File

@ -17,10 +17,7 @@ block left-column
block main-column
#devices
h3.well.text-center TM / temperature sensor
br
button.btn.btn-primary.btn-large.disabled#TMtemp Temp: No value yet
button.btn.btn-info.btn-large.disabled#TMbatt Batt: No value yet
include sensors/TM.jade
block right-column

4
views/sensors/TM.jade Normal file
View File

@ -0,0 +1,4 @@
h3.well.text-center TM / temperature sensor
br
button.btn.btn-primary.btn-large.disabled#TMtemp Temp: No value yet
button.btn.btn-info.btn-large.disabled#TMbatt Batt: No value yet