From 53247e9b0fc55126373b6fca843241469c03472a Mon Sep 17 00:00:00 2001 From: dbathurst Date: Sun, 29 Aug 2010 16:17:56 -0700 Subject: [PATCH] added next and previous js and next song onend event listener --- public/css/ntunes.less | 10 +++------- public/js/ntunes.js | 18 ++++++++++++++++-- server.js | 4 ++-- views/index.ejs | 4 +--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/public/css/ntunes.less b/public/css/ntunes.less index d8ff8cb..7ddbb7f 100644 --- a/public/css/ntunes.less +++ b/public/css/ntunes.less @@ -349,16 +349,12 @@ body { * Where library and playlist browsing happens */ #songCanvas { - overflow-y:scroll; + overflow-y:auto; -webkit-border-radius:0 0 5px 0; border: 0; float: left; - ul { - padding:8px 0 0 0; - list-style:none; - } - li:nth-child(even) { + a:nth-child(even) { background:#F3F7FB; } a { @@ -372,7 +368,7 @@ body { } } .focus { - background:#3691E8; + background:#3691E8 !important; color:#fff; } } diff --git a/public/js/ntunes.js b/public/js/ntunes.js index e1302a9..d10d72a 100644 --- a/public/js/ntunes.js +++ b/public/js/ntunes.js @@ -14,10 +14,10 @@ ntunes = { var html = ''; for (var i=0; i < this.songs.length; i++) { - html += '
  • ' + this.songs[i].title + '
  • ' + html += '' + this.songs[i].title + '' }; - $('#songCanvas ul').html(html); + $('#songCanvas').html(html); songClickandPlay(); @@ -85,6 +85,7 @@ function songClickandPlay() { sCan.dblclick(function(e){ var target = $(e.target); if (target.attr('href')) { + target.attr('id', 'playing'); var title = target.text(); var artist = target.attr('title'); var song = target.attr('href'); @@ -98,6 +99,9 @@ function songClickandPlay() { song + '.mp3" />'); } + document.getElementById('playa').addEventListener('onended', function(){ + $('#playing').next('A').dblclick().end().attr('id', ''); + }, false); }); $('#playPause').click(function(){ @@ -112,6 +116,16 @@ function songClickandPlay() { } }); + $('#nextSong').click(function(e){ + e.preventDefault(); + $('#playing').next('A').dblclick().end().attr('id', ''); + }); + + $('#prevSong').click(function(e){ + e.preventDefault(); + $('#playing').prev('A').dblclick().end().attr('id', ''); + }); + $('body').keypress(function(e){ if (e.keyCode == '32') { $('#playPause').click(); diff --git a/server.js b/server.js index 6d9a0b9..e14af54 100644 --- a/server.js +++ b/server.js @@ -8,7 +8,7 @@ var // Module Deps app = require('express').createServer(), express = require('express'), - couchdb = require('couchdb'), + couchdb = require('node-couchdb/lib/couchdb'), // CouchDB Connection client = couchdb.createClient(5984, 'vegasjs.couchone.com'), @@ -72,4 +72,4 @@ app.get('/catalog', function(req, res) { }); // end app.get // Listen on port 80 -app.listen(80); +app.listen(3000); diff --git a/views/index.ejs b/views/index.ejs index 6545abb..edfd81b 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -83,8 +83,6 @@
    - + Loading Catalog...