Browse Source

less indentation

master
Julio Biason 11 years ago
parent
commit
9757f7b91f
  1. 51
      lyricsnode/routes/round.js

51
lyricsnode/routes/round.js

@ -34,30 +34,51 @@ function acronymize(phrase) {
*/
function getSong(res) {
var name = dbName();
console.log('Opening the database ' + name + '...');
db = new sqlite3.Database(name, sqlite3.OPEN_READWRITE, function (error) {
if (error) {
throw error;
}
var db = null;
var song = null;
var artist = null;
var lyrics = null;
console.log('Pickling a song...');
db.get('SELECT * FROM songs WHERE done_in IS NULL ORDER BY random() LIMIT 1', function (err, song) {
function pickSong() {
console.log('Picking song...');
db.get('SELECT * FROM songs WHERE done_in IS NULL ORDER BY random() LIMIT 1', function (err, selectSong) {
if (err) {
throw err;
}
song = selectSong;
console.log(song);
pickArtist();
});
}
function pickArtist() {
console.log('Retrieving artist for song...');
db.get('SELECT * FROM artists WHERE id = ' + song.artist, function (err, artist) {
db.get('SELECT * FROM artists WHERE id = ' + song.artist, function (err, selectArtist) {
if (err) {
throw err;
}
artist = selectArtist;
console.log(artist);
pickLyrics();
});
}
function pickLyrics() {
console.log('Retrieving lyrics for song... ');
db.get('SELECT * FROM lyrics WHERE song = ' + song.id, function (err, lyrics) {
db.get('SELECT * FROM lyrics WHERE song = ' + song.id, function (err, selectLyrics) {
if (err) {
throw err;
}
lyrics = selectLyrics;
console.log(lyrics);
answer();
});
}
function answer() {
var params = {
title: 'Round',
lyrics: lyrics.lyrics,
@ -68,9 +89,15 @@ function getSong(res) {
id: song.id
};
res.render('index', params);
});
});
});
}
console.log('Opening the database ' + name + '...');
db = new sqlite3.Database(name, sqlite3.OPEN_READWRITE, function (error) {
if (error) {
throw error;
}
pickSong();
});
}

Loading…
Cancel
Save