Added hovered events

This commit is contained in:
Thomas FORGIONE
2015-05-21 15:35:40 +02:00
parent 2a5ae4d985
commit 8e592c87b5
6 changed files with 95 additions and 9 deletions

View File

@@ -168,6 +168,27 @@ var addPreviousNextFromId = function(client, req, res, callback, id) {
);
}
var addHoveredFromId = function(client, req, res, callback, id) {
client.query(
"SELECT start, time, arrow_id FROM hovered WHERE id = $1",
[id],
function(err, result) {
res.locals.path = res.locals.path || [];
for (var i in result.rows) {
res.locals.path.push(
{
type: "hovered",
time: result.rows[i].time,
start: result.rows[i].start,
id: result.rows[i].arrow_id
}
);
}
callback();
}
);
}
var getAllUsers = function(req, res, callback) {
pg.connect(pgc.url, function(err, client, release) {
client.query(
@@ -238,15 +259,17 @@ module.exports.replay_info = function(req, res) {
addArrowsFromId(client, req, res, function() {
addResetsFromId(client, req, res, function() {
addPreviousNextFromId(client, req, res, function() {
res.locals.path.sort(function(elt1, elt2) {
// Dates as string can be compared
if (elt1.time < elt2.time)
return -1;
if (elt1.time > elt2.time)
return 1;
return 0;
});
res.send(JSON.stringify(res.locals.path));
addHoveredFromId(client, req, res, function() {
res.locals.path.sort(function(elt1, elt2) {
// Dates as string can be compared
if (elt1.time < elt2.time)
return -1;
if (elt1.time > elt2.time)
return 1;
return 0;
});
res.send(JSON.stringify(res.locals.path));
}, id);
}, id);
}, id);
}, id);