Browse Source

starting to mark songs as played

master
Julio Biason 11 years ago
parent
commit
e9adf3007c
  1. 1
      lyricsnode/app.js
  2. 20
      lyricsnode/routes/round.js
  3. 2
      lyricsnode/views/index.html

1
lyricsnode/app.js

@ -37,6 +37,7 @@ if ('development' == app.get('env')) {
app.get('/', round.index);
app.post('/round/others/', round.others);
app.post('/round/played/', round.played);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));

20
lyricsnode/routes/round.js

@ -133,7 +133,7 @@ exports.others = function (req, res) {
var now = new Date();
console.log('Adding song as played in ' + now.toJSON() + '...');
var stmt = db.run('INSERT INTO songs (id, title, artist, done_in) VALUES (NULL, ?, ?, ?)', [
db.run('INSERT INTO songs (id, title, artist, done_in) VALUES (NULL, ?, ?, ?)', [
posted_song,
artist,
now.toJSON()
@ -158,7 +158,7 @@ exports.others = function (req, res) {
);
}
var stmt = db.run('INSERT INTO artists (id, name) VALUES (NULL, ?)', [
db.run('INSERT INTO artists (id, name) VALUES (NULL, ?)', [
posted_artist
],
function (error) {
@ -180,3 +180,19 @@ exports.others = function (req, res) {
}
);
};
/**********************************************************************
* Mark a song as played
*********************************************************************/
exports.played = function (req, res) {
var now = new Date();
db.run('UPDATE songs SET done_in = ? WHERE id = ?', [
now.toJSON(), req.body.id
], function (error) {
if (error) {
throw error;
}
}
);
}

2
lyricsnode/views/index.html

@ -78,7 +78,7 @@
<div class='large-12 columns form-close'>
<form method='POST' action='/song/played/'>
<input type='hidden' name='id' value='{{ id }}'>
<button class='button radius secondary small'>Skip</button>
<a href='/' class='button radius secondary small'>Skip</a>
<button class='button radius small'>Next</button>
</form>
</div>

Loading…
Cancel
Save