yeah done
This commit is contained in:
parent
b6c6b5ce0f
commit
77858bc9ad
4
app.js
4
app.js
|
@ -10,10 +10,10 @@ var cosmStreams = [53146, 34606, 43573];
|
||||||
|
|
||||||
var cosmFeeds = {53146 : ["GearboxRPM", "Windspeed", "Pitch"],
|
var cosmFeeds = {53146 : ["GearboxRPM", "Windspeed", "Pitch"],
|
||||||
34606 : ["CCChannel1,Import1", "CCSensor1,Servers2", "CCSensor2,Office3"],
|
34606 : ["CCChannel1,Import1", "CCSensor1,Servers2", "CCSensor2,Office3"],
|
||||||
43573 : ["Humidity0", "Air pressure2", "Thermo3"]};
|
43573 : ["Humidity1", "Air pressure2", "Thermo3"]};
|
||||||
|
|
||||||
var cosmClient = new cosm(cosmStreams, 'orKBBdLAKuKJU-RxqmZpZB6q0baSAKxBTVhKdjhUNkdyVT0g');
|
var cosmClient = new cosm(cosmStreams, 'orKBBdLAKuKJU-RxqmZpZB6q0baSAKxBTVhKdjhUNkdyVT0g');
|
||||||
var oscClient = new osc('chaosc', 7110);
|
var oscClient = new osc('localhost', 7110);
|
||||||
|
|
||||||
function logErrors(err, req, res, next) {
|
function logErrors(err, req, res, next) {
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
|
|
|
@ -9,7 +9,7 @@ block content
|
||||||
div.row
|
div.row
|
||||||
for nr in streams
|
for nr in streams
|
||||||
div.cell
|
div.cell
|
||||||
div(id=nr, class="kasten")
|
div(id="stream-#{nr}", class="kasten")
|
||||||
h3 --
|
h3 --
|
||||||
table
|
table
|
||||||
tr
|
tr
|
||||||
|
@ -31,7 +31,7 @@ block content
|
||||||
td(class="break")
|
td(class="break")
|
||||||
td(class="break")
|
td(class="break")
|
||||||
|
|
||||||
div.mapbox(id="map#{nr}") --
|
div.mapbox(id="map-#{nr}") --
|
||||||
|
|
||||||
script(type="text/javascript")
|
script(type="text/javascript")
|
||||||
//var streams;
|
//var streams;
|
||||||
|
@ -68,48 +68,47 @@ block content
|
||||||
|
|
||||||
socket.on('gotstream', function(data) {
|
socket.on('gotstream', function(data) {
|
||||||
console.log("gotstream " + data.id);
|
console.log("gotstream " + data.id);
|
||||||
$("div#" + data.id + " h3").text(data.title);
|
$("div#stream-" + data.id + " h3").text(data.title);
|
||||||
$("div#" + data.id + " td.location").text(data.location);
|
$("div#stream-" + data.id + " td.location").text(data.location);
|
||||||
$("div#" + data.id + " td.latitude").text(data.lat);
|
$("div#stream-" + data.id + " td.latitude").text(data.lat);
|
||||||
$("div#" + data.id + " td.longitude").text(data.lon);
|
$("div#stream-" + data.id + " td.longitude").text(data.lon);
|
||||||
var now = new Date();
|
var now = new Date();
|
||||||
$("div#" + data.id + " td.update").text(now);
|
$("div#stream-" + data.id + " td.update").text(now);
|
||||||
loadMap($('div#map' + data.id)[0], data.lat, data.lon);
|
loadMap($('div#map-' + data.id)[0], data.lat, data.lon);
|
||||||
});
|
});
|
||||||
|
|
||||||
function add_data(data) {
|
function add_data(data) {
|
||||||
console.log("add_data");
|
console.log("update_data");
|
||||||
console.dir(data);
|
console.dir(data);
|
||||||
var row = $('tr#' + data.feed).html();
|
console.log('searching for "#feed-' + data.feed + '"')
|
||||||
|
var row = $('#stream-' + data.stream + '-feed-' + data.feed).html();
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
var tmp = '<tr id="' + data.feed + '"class="value"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
var tmp = '<tr id="stream-' + data.stream + '-feed-' + data.feed + '" class="value"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
||||||
console.log("new tmp: " + tmp);
|
console.log("new tmp: " + tmp);
|
||||||
$("div#" + data.stream + " table > tbody").append(tmp);
|
$("#stream-" + data.stream + " table > tbody").append(tmp);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function update_data(data) {
|
function update_data(data) {
|
||||||
console.log("update_data");
|
console.log("update_data");
|
||||||
console.dir(data);
|
console.dir(data);
|
||||||
var row = $('tr#' + data.feed).html();
|
console.log('searching for "#feed-' + data.feed + '"')
|
||||||
|
var row = $('#stream-' + data.stream + '-feed-' + data.feed).html();
|
||||||
if (row === undefined) {
|
if (row === undefined) {
|
||||||
var tmp = '<tr id="' + data.feed + '" class="value"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
var tmp = '<tr id="stream-' + data.stream + '-feed-' + data.feed + '" class="value"><td>' + data.displayname + '</td><td class="value">' + data.value + "</td></tr>";
|
||||||
console.log("new tmp: " + tmp);
|
console.log("new tmp: " + tmp);
|
||||||
$("div#" + data.stream + " table > tbody").append(tmp);
|
$("#stream-" + data.stream + " table > tbody").append(tmp);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$("body").effect("highlight", {times:2}, 2000);
|
$("body").effect("highlight", {times:2}, 2000);
|
||||||
var t = 'div#' + data.stream + ' table > tbody tr#' + data.feed;
|
var t = '#stream-' + data.stream + '-feed-' + data.feed;
|
||||||
var tmp = "<td>" + data.displayname + '</td><td class="value">' + data.value + "</td>";
|
var tmp = "<td>" + data.displayname + '</td><td class="value">' + data.value + "</td>";
|
||||||
console.log("existing tmp: " + tmp);
|
console.log("update: " + tmp);
|
||||||
$(t).html(tmp);
|
$(t).html(tmp);
|
||||||
var f = $("tr#" + data.feed + " .value");
|
var f = $('#stream-' + data.stream + '-feed-' + data.feed + ' .value');
|
||||||
console.dir(f);
|
|
||||||
f.effect("pulsate", { times:3 }, 2000);
|
f.effect("pulsate", { times:3 }, 2000);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.on('changedvalue', update_data);
|
socket.on('changedvalue', update_data);
|
||||||
|
|
||||||
socket.on('updatevalue', add_data);
|
socket.on('updatevalue', add_data);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue