From 77858bc9adb1827191bc2e71c2be6128990df36c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20K=C3=B6gl?= Date: Wed, 20 Feb 2013 15:14:09 +0100 Subject: [PATCH] yeah done --- app.js | 4 ++-- views/index.jade | 41 ++++++++++++++++++++--------------------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/app.js b/app.js index dbf2eaf..d447f83 100644 --- a/app.js +++ b/app.js @@ -10,10 +10,10 @@ var cosmStreams = [53146, 34606, 43573]; var cosmFeeds = {53146 : ["GearboxRPM", "Windspeed", "Pitch"], 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 oscClient = new osc('chaosc', 7110); +var oscClient = new osc('localhost', 7110); function logErrors(err, req, res, next) { console.error(err.stack); diff --git a/views/index.jade b/views/index.jade index 59cbeff..d4fc317 100644 --- a/views/index.jade +++ b/views/index.jade @@ -9,7 +9,7 @@ block content div.row for nr in streams div.cell - div(id=nr, class="kasten") + div(id="stream-#{nr}", class="kasten") h3 -- table tr @@ -31,7 +31,7 @@ block content td(class="break") td(class="break") - div.mapbox(id="map#{nr}") -- + div.mapbox(id="map-#{nr}") -- script(type="text/javascript") //var streams; @@ -68,48 +68,47 @@ block content socket.on('gotstream', function(data) { console.log("gotstream " + data.id); - $("div#" + data.id + " h3").text(data.title); - $("div#" + data.id + " td.location").text(data.location); - $("div#" + data.id + " td.latitude").text(data.lat); - $("div#" + data.id + " td.longitude").text(data.lon); + $("div#stream-" + data.id + " h3").text(data.title); + $("div#stream-" + data.id + " td.location").text(data.location); + $("div#stream-" + data.id + " td.latitude").text(data.lat); + $("div#stream-" + data.id + " td.longitude").text(data.lon); var now = new Date(); - $("div#" + data.id + " td.update").text(now); - loadMap($('div#map' + data.id)[0], data.lat, data.lon); + $("div#stream-" + data.id + " td.update").text(now); + loadMap($('div#map-' + data.id)[0], data.lat, data.lon); }); function add_data(data) { - console.log("add_data"); + console.log("update_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) { - var tmp = '' + data.displayname + '' + data.value + ""; + var tmp = '' + data.displayname + '' + data.value + ""; console.log("new tmp: " + tmp); - $("div#" + data.stream + " table > tbody").append(tmp); + $("#stream-" + data.stream + " table > tbody").append(tmp); } }; function update_data(data) { console.log("update_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) { - var tmp = '' + data.displayname + '' + data.value + ""; + var tmp = '' + data.displayname + '' + data.value + ""; console.log("new tmp: " + tmp); - $("div#" + data.stream + " table > tbody").append(tmp); + $("#stream-" + data.stream + " table > tbody").append(tmp); } else { $("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 = "" + data.displayname + '' + data.value + ""; - console.log("existing tmp: " + tmp); + console.log("update: " + tmp); $(t).html(tmp); - var f = $("tr#" + data.feed + " .value"); - console.dir(f); + var f = $('#stream-' + data.stream + '-feed-' + data.feed + ' .value'); f.effect("pulsate", { times:3 }, 2000); } }; socket.on('changedvalue', update_data); - socket.on('updatevalue', add_data); -