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

27
posts/hovered/index.js Normal file
View File

@@ -0,0 +1,27 @@
var pg = require('pg');
var secret = require('../../private');
module.exports.index = function(req, res) {
var user_id = req.session.user_id;
pg.connect(secret.url, function(err, client, release) {
client.query(
"INSERT INTO hovered(user_id, time, start, arrow_id)" +
"VALUES($1, to_timestamp($2), $3, $4);" ,
[
user_id,
req.body.time,
req.body.start ? true : false,
req.body.arrow_id
],
function(err, result) {
release();
}
);
});
res.setHeader('Content-Type', 'text/html');
res.send("user_id = " + user_id);
}

3
posts/hovered/urls.js Normal file
View File

@@ -0,0 +1,3 @@
module.exports = {
'/hovered': 'index'
}