Merge branch 'master' of github.com:magnolia-fan/BeatHaven
This commit is contained in:
@@ -57,8 +57,9 @@ class window.Player
|
||||
m = Math.floor(len / 60)
|
||||
s = len - Math.floor(len / 60) * 60
|
||||
duration = m + ':' + (if s < 10 then '0' else '') + s
|
||||
item_class = (if item.available == false then 'unavailable' else '')
|
||||
$('.playlist').append '
|
||||
<li id="i' +Math.round(Math.random() * 999999)+ '" data-id="'+item.id+'">
|
||||
<li id="i' +Math.round(Math.random() * 999999)+ '" data-id="'+item.id+'" class="'+item_class+'">
|
||||
<div class="song-duration">' +duration+ '</div>
|
||||
<div class="remove">remove</div>
|
||||
<div class="artist-name">' +item.artist+ '</div>
|
||||
@@ -85,19 +86,26 @@ class window.Player
|
||||
$('.player .now-playing').html query
|
||||
$('.playlist li').removeClass 'now'
|
||||
$obj.addClass 'now'
|
||||
_vk_music.search track.artist, track.name, track.duration, (audio) ->
|
||||
_player.playSource audio.url
|
||||
if track.length == 0
|
||||
len = parseInt(audio.duration, 10)
|
||||
m = Math.floor(len / 60)
|
||||
s = len - Math.floor(len / 60) * 60
|
||||
duration = m + ':' + (if s < 10 then '0' else '') + s
|
||||
_session.query '/track/update_length', { track_id: track.id, length: len }, (r) ->
|
||||
if r.result is 'success'
|
||||
$('.playlist li[data-id="'+track.id+'"] .song-duration').text(duration)
|
||||
$($('.album div[data-id="'+track.id+'"]').siblings()[0]).text(duration)
|
||||
|
||||
this.updateNowListening track
|
||||
_vk_music.search track.artist, track.name, track.length, (audio) ->
|
||||
if audio is null
|
||||
_session.query '/track/report', { id: track.id }, (r) ->
|
||||
if r.status is 'success'
|
||||
$('.playlist li[data-id="'+track.id+'"]').addClass("unavailable")
|
||||
$($('.album div[data-id="'+track.id+'"]').siblings()[0]).addClass("unavailable")
|
||||
_player.setTrack _player.nextTrack()
|
||||
else
|
||||
_player.playSource audio.url
|
||||
if track.length == 0
|
||||
len = parseInt(audio.duration, 10)
|
||||
m = Math.floor(len / 60)
|
||||
s = len - Math.floor(len / 60) * 60
|
||||
duration = m + ':' + (if s < 10 then '0' else '') + s
|
||||
_session.query '/track/update_length', { track_id: track.id, length: len }, (r) ->
|
||||
if r.status is 'success'
|
||||
$('.playlist li[data-id="'+track.id+'"] .song-duration').text(duration)
|
||||
$($('.album div[data-id="'+track.id+'"]').siblings()[0]).text(duration)
|
||||
_player.updateNowListening track
|
||||
false
|
||||
false
|
||||
|
||||
getTrackInfo: (id) ->
|
||||
@@ -106,6 +114,12 @@ class window.Player
|
||||
return track
|
||||
false
|
||||
|
||||
getAlbumInfo: (id) ->
|
||||
for album in _player.albums
|
||||
if parseInt(album.id, 10) == parseInt(id, 10)
|
||||
return album
|
||||
false
|
||||
|
||||
hasTrack: ->
|
||||
if $('#jplayer audio').length > 0
|
||||
return $('#jplayer audio').attr('src')? and $('#jplayer audio').attr('src') != ''
|
||||
@@ -236,21 +250,19 @@ $('.playlist li').live 'click', ->
|
||||
# Adding To Playlist actions
|
||||
|
||||
$('.add-album').live 'click', ->
|
||||
artist = $('.artist-info h2').text()
|
||||
album = _player.albums[$(this).attr('data-album-id')]
|
||||
album = _player.getAlbumInfo($(this).attr('data-album-id'))
|
||||
for item in album.tracks
|
||||
item['artist'] = artist
|
||||
item['artist'] = album.artist
|
||||
item['album'] = album.name
|
||||
_player.addTracks album.tracks
|
||||
false
|
||||
|
||||
$('.s-add').live 'click', ->
|
||||
artist = $('.artist-info h2').text()
|
||||
album = _player.albums[$(this).attr('data-album-id')]
|
||||
album = _player.getAlbumInfo($(this).attr('data-album-id'))
|
||||
item = album.tracks[$(this).attr('data-id')]
|
||||
for item in album.tracks
|
||||
if item.id == parseInt($(this).attr('data-id'), 10)
|
||||
item['artist'] = artist
|
||||
item['artist'] = album.artist
|
||||
item['album'] = album.name
|
||||
_player.addTracks [item]
|
||||
return false
|
||||
|
||||
@@ -4,7 +4,6 @@ class window.Search
|
||||
$('#search').attr(disabled: 'disabled').blur()
|
||||
$('#autocomplete-container').hide()
|
||||
$('#artist-load-spinner').show()
|
||||
this.hideSuggestions()
|
||||
false
|
||||
|
||||
hideSpinner: ->
|
||||
@@ -22,7 +21,8 @@ class window.Search
|
||||
if _session.getUser().id
|
||||
if data.artist.albums?
|
||||
for album in data.artist.albums
|
||||
_player.albums[album.id] = album
|
||||
album['artist'] = data.artist.name
|
||||
_player.albums.push(album)
|
||||
$('.button-container').show()
|
||||
_search.hideSpinner()
|
||||
if data.status is 'loading'
|
||||
@@ -42,24 +42,9 @@ class window.Search
|
||||
_search.hideSpinner()
|
||||
alert "Not found"
|
||||
false
|
||||
|
||||
showSuggestions: (values) ->
|
||||
for item in values
|
||||
$('.suggestions ul').append '
|
||||
<li>
|
||||
<a class="data artist">' +item.name+ '</a>
|
||||
' +(if item.desc? then '<br/><span>'+item.desc+'</span>' else '')+ '
|
||||
</li>'
|
||||
$('.suggestions').show()
|
||||
false
|
||||
|
||||
hideSuggestions: ->
|
||||
$('.suggestions ul li').remove()
|
||||
$('.suggestions').hide()
|
||||
false
|
||||
|
||||
$('#search-form').live 'submit', ->
|
||||
$('#autocomplete-container').remove()
|
||||
$('#autocomplete-container').hide()
|
||||
_search.loadArtistData $('#search').val()
|
||||
false
|
||||
$('.data.artist').live 'click', ->
|
||||
|
||||
@@ -59,7 +59,7 @@ class window.VkontakteMusic
|
||||
data
|
||||
|
||||
prepareQuery: (artist, track) ->
|
||||
artist+" "+track.replace(/\(.*\)/i, '').split('/')[0]
|
||||
artist+" "+this.trim(/[\w\d\s]+/.exec(track)[0]).replace(/\(.*\)/i, '').split('/')[0]
|
||||
|
||||
trim: (str) ->
|
||||
while str.indexOf(' ') isnt -1
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
& > h3 {
|
||||
margin: -5px 0 5px 0;
|
||||
}
|
||||
tr.unavailable > td {
|
||||
background-color: #FFF0F0;
|
||||
}
|
||||
td.song-duration {
|
||||
text-align: right;
|
||||
.s-duration {
|
||||
|
||||
@@ -109,6 +109,9 @@
|
||||
margin: 16px 5px 0 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
&.unavailable {
|
||||
background-color: #FFF0F0;
|
||||
}
|
||||
&.now {
|
||||
background-color: #EAF5FF;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
#search-form {
|
||||
height: 28px !important;
|
||||
}
|
||||
|
||||
#artist-load-spinner {
|
||||
display: none;
|
||||
float: right;
|
||||
|
||||
@@ -15,7 +15,7 @@ class ArtistController < ApplicationController
|
||||
if results.empty?
|
||||
return render json: { status: 'not_found' }
|
||||
end
|
||||
best_match = results[0][:name]
|
||||
best_match = results[0][:sort_name]
|
||||
if best_match != artist_name and similar_names(artist_name, best_match)
|
||||
return render json: { status: 'corrected', correct_name: best_match }
|
||||
elsif best_match == artist_name
|
||||
|
||||
@@ -38,8 +38,9 @@ class ImportController < ApplicationController
|
||||
artist.pic_url = lastfm_artist['artist']['image'][3]['#text']
|
||||
artist.listeners = lastfm_artist['artist']['stats']['listeners']
|
||||
artist.artist_type = brainz_artist.type
|
||||
artist.original_name = brainz_artist.name
|
||||
artist.mbid = brainz_artist.id
|
||||
artist.save
|
||||
artist.save!
|
||||
|
||||
brainz_artist.urls.each do |service, url|
|
||||
ArtistLink.new(
|
||||
|
||||
@@ -18,7 +18,7 @@ class TrackController < ApplicationController
|
||||
def report_unavailable
|
||||
track = Track.find(params[:id])
|
||||
unless track.nil? or track.available
|
||||
track.available = true
|
||||
track.available = false
|
||||
track.save
|
||||
return render :json => { :status => :success }
|
||||
end
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
.span4.columns.pic
|
||||
= image_tag @artist.pic_url unless @artist.pic_url.nil?
|
||||
.span7.columns.desc
|
||||
%h2= @artist.name
|
||||
%h2
|
||||
=@artist.name
|
||||
%small= " "+@artist.original_name.to_s
|
||||
= @artist.desc.html_safe unless @artist.desc.nil?
|
||||
- unless @artist.artist_links.empty?
|
||||
.service-icons
|
||||
@@ -22,10 +24,12 @@
|
||||
.button-container
|
||||
%a.btn.add-album{ :'data-album-id' => album.id }= I18n.t 'player.add'
|
||||
.span7.columns.tracks
|
||||
%h3{ :'data-album-id' => album.id }= album.name + " (" + album.year.to_s + ")"
|
||||
%h3{ :'data-album-id' => album.id }
|
||||
= album.name
|
||||
%small= " ("+album.year.to_s+")"
|
||||
%table.zebra-striped.tracklist
|
||||
- album.tracks.each do |track|
|
||||
%tr
|
||||
%tr{ class: (track.available == false ? "unavailable" : nil) }
|
||||
%td.song-title= track.name
|
||||
%td.song-duration
|
||||
.s-duration= (track.duration != '0:00' ? track.duration : ' '.html_safe)
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
%ul.suggestions
|
||||
- @suggestions.each do |artist|
|
||||
%li
|
||||
%a.data.artist= artist[:name]
|
||||
%a.data.artist= artist[:sort_name]
|
||||
(
|
||||
= artist[:type]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user