http.HandleFunc("/", serve_page)
// @todo Not sure how to cancel this routine yet
// wg.Add(1)
+ fmt.Printf("[tinyweb] listening on %s\n", addr)
go http.ListenAndServe(addr, nil)
return 0
}
});
/* Realtime updates */
function poller(feed, interval, cb) {
- setInterval(function () {
+ var func = function() {
$.ajax({
url: feed,
type: 'get',
dataType: 'json',
success: cb
});
- }, interval);
+ }
+ setInterval(func, interval);
+ func();
}
poller('stats', 1000, function(resp) {
var now = Date.now();
/* Normalize, convert to HSL. */
for (var key in update) {
var ratio = 1.0 - update[key]/max;
- update[key] = 'hsl(205,70%,' + Math.floor(20.0 + 70.0 * ratio) + '%)'
+ update[key] = 'hsl(205,70%,' + Math.floor(10.0 + 70.0 * (ratio * ratio)) + '%)'
}
map.updateChoropleth(update);
});
-}
\ No newline at end of file
+}