From c52094028341678e8585a3160d7f9625c38a3e1a Mon Sep 17 00:00:00 2001 From: Julio Biason Date: Fri, 16 Aug 2013 13:53:29 -0300 Subject: [PATCH] linted --- lyricsnode/routes/round.js | 90 +++++++++++++++++++------------------- 1 file changed, 44 insertions(+), 46 deletions(-) diff --git a/lyricsnode/routes/round.js b/lyricsnode/routes/round.js index 970a85a..10b95cb 100644 --- a/lyricsnode/routes/round.js +++ b/lyricsnode/routes/round.js @@ -4,71 +4,69 @@ var sqlite3 = require('sqlite3'); var path = require('path'); -var db; // make it global +var db; // make it global /** * db name */ -function dbName() -{ - return path.join(__dirname, '../../db/lyrics.sq3'); +function dbName() { + return path.join(__dirname, '../../db/lyrics.sq3'); } /** * turn a phrase into a list of acronyms */ -function acronymize(phrase) -{ - var letters = []; - phrase.split(' ').forEach(function(elem, idx, array) { - letters.push(elem[0].toUpperCase()); - }) +function acronymize(phrase) { + var letters = []; + phrase.split(' ').forEach(function (elem, idx, array) { + letters.push(elem[0].toUpperCase()); + }); - return letters.join(''); + return letters.join(''); } /** * Pick a song */ 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 name = dbName(); + console.log('Opening the database ' + name + '...'); + db = new sqlite3.Database(name, sqlite3.OPEN_READWRITE, function (error) { + if (error) { + throw error; + } - console.log('Pickling a song...'); - db.get('SELECT * FROM songs WHERE done_in IS NULL ORDER BY random() LIMIT 1', function(err, song) { - if (err) { - throw err; - } + console.log('Pickling a song...'); + db.get('SELECT * FROM songs WHERE done_in IS NULL ORDER BY random() LIMIT 1', function (err, song) { + if (err) { + throw err; + } - db.get('SELECT * FROM artists WHERE id = ' + song.artist, function(err, artist) { - if (err) { - throw err; - } + db.get('SELECT * FROM artists WHERE id = ' + song.artist, function (err, artist) { + if (err) { + throw err; + } - db.get('SELECT * FROM lyrics WHERE song = ' + song.id, function(err, lyrics) { - if (err) { - throw err; - } + db.get('SELECT * FROM lyrics WHERE song = ' + song.id, function (err, lyrics) { + if (err) { + throw err; + } - params = {title: 'Round', - lyrics: lyrics.lyrics, - song_title: song.title, - song_artist: artist.name, - acronym_title: acronymize(song.title), - acronym_artist: acronymize(artist.name) - }; - res.render('index', params); - }); - }); - }); - }); + var params = {title: 'Round', + lyrics: lyrics.lyrics, + song_title: song.title, + song_artist: artist.name, + acronym_title: acronymize(song.title), + acronym_artist: acronymize(artist.name), + id: song.id + }; + res.render('index', params); + }); + }); + }); + }); } -exports.index = function(req, res) { - // res.render('index', { title: 'Round'} ); - getSong(res); -} +exports.index = function (req, res) { + getSong(res); +}; \ No newline at end of file