2013-01-30 14:30:49 +00:00
|
|
|
extends layout
|
|
|
|
|
2013-01-30 23:09:00 +00:00
|
|
|
block head
|
|
|
|
script(src="/socket.io/socket.io.js")
|
|
|
|
|
2013-01-30 14:30:49 +00:00
|
|
|
block content
|
|
|
|
|
|
|
|
div.container
|
|
|
|
div.row
|
2013-02-12 23:12:44 +00:00
|
|
|
for nr in streams
|
2013-01-30 14:30:49 +00:00
|
|
|
div.cell
|
2013-02-18 05:46:15 +00:00
|
|
|
div(id=nr, class="kasten")
|
|
|
|
h3 --
|
|
|
|
h4 --
|
2013-01-30 14:30:49 +00:00
|
|
|
table
|
|
|
|
tr
|
|
|
|
td Location:
|
2013-02-18 05:46:15 +00:00
|
|
|
td(class="location") --
|
2013-01-30 14:30:49 +00:00
|
|
|
tr
|
|
|
|
td Elevation:
|
2013-02-18 05:46:15 +00:00
|
|
|
td(class="elevation") --
|
2013-01-30 14:30:49 +00:00
|
|
|
tr
|
|
|
|
td Latitude:
|
2013-02-18 05:46:15 +00:00
|
|
|
td(class="latitude") --
|
2013-01-30 14:30:49 +00:00
|
|
|
tr
|
|
|
|
td Longitude:
|
2013-02-18 05:46:15 +00:00
|
|
|
td(class="longitude") --
|
2013-01-30 14:30:49 +00:00
|
|
|
tr
|
|
|
|
td Update:
|
2013-02-18 05:46:15 +00:00
|
|
|
td(class="update") --
|
2013-01-30 14:30:49 +00:00
|
|
|
|
2013-02-18 05:46:15 +00:00
|
|
|
div.mapbox(id="map#{nr}") --
|
2013-01-30 14:38:55 +00:00
|
|
|
|
2013-01-30 14:30:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
script(type="text/javascript",src="http://maps.googleapis.com/maps/api/js?sensor=false&key=AIzaSyDZ5gUZumNEZOHyRLs4HWJEJ-mDeEkWInU")
|
|
|
|
|
|
|
|
script(type="text/javascript")
|
2013-02-18 05:46:15 +00:00
|
|
|
//var streams;
|
|
|
|
//var stream;
|
|
|
|
|
|
|
|
var print = function(o){
|
|
|
|
var str='';
|
|
|
|
|
|
|
|
for(var p in o){
|
|
|
|
if(typeof o[p] == 'string'){
|
|
|
|
str+= p + ': ' + o[p]+'; ';
|
|
|
|
}else{
|
|
|
|
str+= p + ': {' + print(o[p]) + '}';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
2013-01-30 14:30:49 +00:00
|
|
|
|
|
|
|
function loadMap(container, lat, long) {
|
2013-02-18 05:46:15 +00:00
|
|
|
var latlong = new google.maps.LatLng(lat, long);
|
2013-01-30 14:30:49 +00:00
|
|
|
var map = new google.maps.Map(container, { center: latlong,
|
|
|
|
zoom: 8,
|
|
|
|
disableDefaultUI: true,
|
|
|
|
mapTypeId: google.maps.MapTypeId.ROADMAP });
|
|
|
|
var marker = new google.maps.Marker({ position: latlong, map: map});
|
|
|
|
}
|
|
|
|
|
|
|
|
$(function() {
|
2013-02-12 23:12:44 +00:00
|
|
|
|
2013-01-30 23:09:00 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var socket = io.connect('http://localhost');
|
2013-02-12 23:12:44 +00:00
|
|
|
|
|
|
|
socket.on('gotstream', function(data) {
|
2013-02-18 05:46:15 +00:00
|
|
|
console.log("gotstream " + data.id);
|
|
|
|
$("div#" + data.id + " h3").text(data.title);
|
|
|
|
$("div#" + data.id + " h4").text(data.description);
|
|
|
|
$("div#" + data.id + " td.location").text(data.location);
|
|
|
|
$("div#" + data.id + " td.elevation").text(data.elevation);
|
|
|
|
$("div#" + data.id + " td.latitude").text(data.lat);
|
|
|
|
$("div#" + 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);
|
2013-02-12 23:12:44 +00:00
|
|
|
});
|
|
|
|
|
2013-02-18 05:46:15 +00:00
|
|
|
function add_data(data) {
|
|
|
|
console.log("changedvalue");
|
|
|
|
console.dir(data);
|
|
|
|
var row = $('tr#' + data.feed).html();
|
|
|
|
if (row === undefined) {
|
|
|
|
var tmp = '<tr id="' + data.feed + '"><td>' + data.displayname + "</td><td>" + data.value + "</td></tr>";
|
|
|
|
console.log("new tmp: " + tmp);
|
|
|
|
$("div#" + data.stream + " table > tbody").append(tmp);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
var t = 'div#' + data.stream + ' table > tbody tr#' + data.feed;
|
|
|
|
var tmp = "<td>" + data.displayname + "</td><td>" + data.value + "</td>";
|
|
|
|
console.log("existing tmp: " + tmp);
|
|
|
|
$(t).html(tmp);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
socket.on('changedvalue', add_data);
|
|
|
|
|
|
|
|
socket.on('updatevalue', add_data);
|
2013-01-30 14:30:49 +00:00
|
|
|
|