Permalink
Browse files

finished. sort of.

  • Loading branch information...
1 parent 0f38870 commit e7e24035add30008b6043f23cbee097ccd6e2389 Alex Michael committed Dec 4, 2011
Showing with 83 additions and 32 deletions.
  1. +52 −11 app/app.js
  2. +1 −2 index.html
  3. +28 −18 libs/css/styles.css
  4. +2 −1 manifest.json
  5. BIN res/imgs/Play-Small.png
View
@@ -24,6 +24,7 @@ var Song = function(data)
"<div class='title'>" +
title +
"</div>" +
+ "<span><img src='../res/imgs/Play-Small.png' to play/></span>" +
"</div>");
var onSearchReturn = function(err, tracks) {
@@ -41,6 +42,11 @@ var Song = function(data)
});
}
});
+ elem.click((function(t) {
+ return function() {
+ m.player.play(t);
+ }
+ })(track));
} else {
// TODO: handle.
console.log('no tracks.');
@@ -55,6 +61,7 @@ var Song = function(data)
containment: '#main',
revert: true
});
+
return {
track: function() {
@@ -91,20 +98,39 @@ var Playlist = function(elem)
var onDrop = function(event, ui) {
var l = $("#anim .song").length;
var draggable = ui.draggable,
- song = songIds[draggable.attr("id")];
+ song = songIds[draggable.attr("id")],
+ newe = $("<div class='s'>" +
+ "<div>" +
+ song.artist() +
+ " - " +
+ song.title() +
+ "</div>" +
+ "<span><img height='15' width='15' src='../res/imgs/Play-Small.png'/></span>" +
+ "</div>");
songs.push(song);
+ elem.find("#songs").append(newe);
+
draggable.draggable('option', 'revert', false);
- elem.find("#songs").append($("<div class='s'>" + song.artist() + " - " + song.title() + "</div>"));
draggable.remove();
+
MHD.app.renderMore(l - $("#anim .song").length);
+
var name = elem.find("#name div").html();
if (spPlaylist === null) {
spPlaylist = new m.Playlist(name);
}
if (spPlaylist.name !== name) {
spPlaylist.name = name;
}
- spPlaylist.add(m.Track.fromURI(song.track().uri));
+ var track = m.Track.fromURI(song.track().uri);
+ spPlaylist.add(track);
+
+ newe.click((function(t) {
+ return function() {
+ console.log("zf");
+ m.player.play(t);
+ }
+ })(track));
};
elem.find("#songs").droppable({
@@ -272,7 +298,7 @@ var App = function()
knobs: knobs,
init: function()
{
- var h = $(document).height() - titleElem.height(),
+ var h = $(document).height() - titleElem.height() - 20,
w = $(document).width();
mainElem.height(h);
@@ -284,7 +310,7 @@ var App = function()
animElem.height(h);
animElem.width(w/3);
- playElem.height(h);
+ playElem.height(h-2);
playElem.width(w/3);
numSongs = Math.round(h / 45);
@@ -305,7 +331,7 @@ var App = function()
rnd = Math.random(),
init = 0;
if (rnd > 0.7) {
- init = 90;
+ init = 45;
}
knobs.push(new Knob(id, term, init));
}, this);
@@ -354,10 +380,18 @@ var App = function()
$("#playlist #name div").html(this.derivePlaylistName());
$("#anim").children().fadeOut();
this.buffer = [];
+ var seen = {};
var d = data.response.songs;
for (var i = 0; i < d.length; i++) {
var song = new Song(d[i]);
- this.buffer.push(song);
+ var dedup = (song.title().replace(/\s/g, "")
+ + song.artist().replace(" ", ""))
+ .toLowerCase();
+ console.log(dedup);
+ if (!seen[dedup]) {
+ this.buffer.push(song);
+ seen[dedup] = true;
+ }
}
shuffle(this.buffer);
window.setTimeout($.proxy(hiSongs, this), 1000);
@@ -384,18 +418,25 @@ var App = function()
derivePlaylistName: function()
{
- var name = "";
+ var name = [];
for (var i in knobs) {
if (knobs.hasOwnProperty(i)) {
var knob = knobs[i];
console.log(knob.boost());
if (knob.boost() > 0) {
- name += knob.searchTerm();
+ var extra = "";
+ if (knob.boost() > 1.6) {
+ extra = "too much";
+ } else if (knob.boost() >= 1) {
+ extra = "some";
+ } else {
+ extra = "a little";
+ }
+ name.push(extra + " " + knob.searchTerm());
}
}
}
- console.log(name);
- return name || "noname";
+ return (name.length > 0)? name.join(" and ") : "no name";
}
};
View
@@ -33,8 +33,7 @@
</div>
<div id="playlist" class="column clearfix">
<div id="name" class="clearfix">
- <div>hello</div>
- <button class="cupid-green">Clear</button>
+ <div>Loading..</div>
</div>
<div id="songs">
</div>
View
@@ -18,9 +18,11 @@ head, body {
height: 49px;
line-height: 50px;
text-align: center;
+ color: white;
border-bottom: 2px solid black;
- font-size: 1.38em;
+ font-size: 1.153em;
z-index: 20;
+ text-shadow: 0px 1px 0px black;
background-image: url("../../res/imgs/dark_leather.png");
}
@@ -66,13 +68,18 @@ head, body {
text-overflow: ellipsis;
z-index: 500;
padding: 5px;
+ position: relative;
width: 96%;
}
-.song:hover {
+.song:hover, .s:hover {
cursor: pointer;
background-color: #242424;
}
+
+.song:hover .dets span, .s:hover span {
+ visibility: visible;
+}
.song .img {
height: 32px;
width: 32px;
@@ -90,6 +97,18 @@ head, body {
color: white;
}
+ .song .dets span, .s span {
+ position: absolute;
+ right: 8px;
+ visibility: hidden;
+ bottom: 3px;
+ }
+
+ .s span {
+ bottom: 2px;
+ right: 12px;
+ }
+
#playlist { border-top: 1px solid #292929;
box-shadow: 0px 1px 4px black;
@@ -102,31 +121,21 @@ head, body {
height: 43px;
line-height: 43px;
border-bottom: 1px solid black;
+ text-align: center;
}
#playlist #songs {
border-top: 1px solid #292929;
- height: 100%;
+ min-height: 400px;
}
- #playlist #name div,
- #playlist #name button {
- border: none;
- top: 0;
- left: 0;
- margin: 0;
- padding:0;
- position: relative;
- left: 6px;
- border-radius: 3px;
- float: left;
- }
-
#playlist #name div {
- width: 79%;
+ width: 100%;
font-weight: bold;
- font-sizse: 0.923em;
+ font-size: 0.846em;
height: 45px;
+ overflow: hidden;
+ text-overflow-mode: ellipsis;
color: white;
}
@@ -143,6 +152,7 @@ head, body {
.s {
font-size: 0.823em;
+ position: relative;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 3px;
View
@@ -17,5 +17,6 @@
"http://*.last.fm",
"http://*.myspacecdn.com",
"http://*.amazon.com",
- "http://www.oldchesterpa.com"]
+ "http://www.oldchesterpa.com",
+ "http://*.wikimedia.org"]
}
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e7e2403

Please sign in to comment.