1
0
Fork 0

It works!!1

This commit is contained in:
Gregory Eremin 2011-09-15 15:07:35 +04:00
parent 024f1d7af2
commit e2b0fac59e
4 changed files with 37 additions and 32 deletions

View File

@ -1,6 +1,6 @@
class window.Player
bar_width: 330
bar_width: 263
jp: null
scrobbled: false
albums: []
@ -31,7 +31,7 @@ class window.Player
@jp.bind $.jPlayer.event.timeupdate, (e) ->
data = e.jPlayer.status
if not _player.scrobbled and data.currentPercentAbsolute > 50
$obj = $('.playlist-tracks li.now')
$obj = $('.playlist li.now')
self.scrobble $obj.attr('data-artist'), $obj.attr('data-album'), $obj.attr('data-track')
_player.scrobbled = true
$('.player .progress .loaded').width(data.seekPercent * self.bar_width / 100)
@ -43,7 +43,7 @@ class window.Player
$('#jplayer').jPlayer 'clearMedia'
$('.player .now-playing').html 'Nothing left to <strike>lose</strike> play'
$('.player .loaded, .player .played').width 0
$('.playlist-tracks li').removeClass 'now'
$('.playlist li').removeClass 'now'
else
self.setTrack next
false
@ -111,47 +111,47 @@ class window.Player
nextTrack: (manual) ->
manual = manual?
cnt = $('.playlist-tracks li').length
cnt = $('.playlist li').length
if not this.onShuffle() # Shuffle off
if $('.playlist-tracks .now').next().length == 0 # Last track and repeat is on
if $('.playlist .now').next().length == 0 # Last track and repeat is on
if _player.onRepeat() or manual # Repeat or manual click
return $('.playlist-tracks li').first().attr('id').split('i')[1]
return $('.playlist li').first().attr('id').split('i')[1]
else
false
else
return $('.playlist-tracks .now').next().attr('id').split('i')[1]
return $('.playlist .now').next().attr('id').split('i')[1]
else if cnt == 1 # Single track in the playlist
return $('.playlist-tracks li').first().attr('id').split('i')[1]
return $('.playlist li').first().attr('id').split('i')[1]
else # Shuffle on
while true
rnd = Math.floor(Math.random() * (cnt + .999))
$li = $('.playlist-tracks li').eq rnd
$li = $('.playlist li').eq rnd
if $li.length > 0 and not $li.hasClass 'now'
return $li.attr('id').split('i')[1]
false
prevTrack: ->
cnt = $('.playlist-tracks li').length
cnt = $('.playlist li').length
if not _player.onShuffle() # Shuffle off
if $('.playlist-tracks .now').prev().length == 0 # First track in the playlist
return $('.playlist-tracks li').last().attr('id').split('i')[1]
if $('.playlist .now').prev().length == 0 # First track in the playlist
return $('.playlist li').last().attr('id').split('i')[1]
else
return $('.playlist-tracks .now').prev().attr('id').split('i')[1]
return $('.playlist .now').prev().attr('id').split('i')[1]
else if cnt == 1 # Single track in the playlist
return $('.playlist-tracks li').first().attr('id').split('i')[1]
return $('.playlist li').first().attr('id').split('i')[1]
else # Shuffle on
while true
rnd = Math.floor(Math.random() * (cnt + .999))
$li = $('.playlist-tracks li').eq rnd
$li = $('.playlist li').eq rnd
if $li.length > 0 and not $li.hasClass 'now'
return $li.attr('id').split('i')[1]
false
onShuffle: ->
return $('#shuffle').hasClass 'active'
#return $('#shuffle').hasClass 'active'
onRepeat: ->
return $('#repeat').hasClass 'active'
#return $('#repeat').hasClass 'active'
updateNowListening: (artist, album, track) ->
if _session.getUser().lastfm_username
@ -166,17 +166,17 @@ class window.Player
# Player Controls
$('.player .controls .prev').live 'click', ->
$('.player .prev').live 'click', ->
_player.setTrack _player.prevTrack()
false
$('.player .controls .next').live 'click', ->
$('.player .next').live 'click', ->
_player.setTrack _player.nextTrack(true)
false
$('.player .play').live 'click', ->
if $('.playlist-tracks li').length > 0 and not _player.hasTrack()
_player.setTrack $('.playlist-tracks li').first().attr('id').split('i')[1]
if $('.playlist li').length > 0 and not _player.hasTrack()
_player.setTrack $('.playlist li').first().attr('id').split('i')[1]
false
$('.player .progress').live 'click', (e) ->
@ -191,7 +191,7 @@ $('#repeat, #shuffle').live 'click', ->
$('#empty-playlist').live 'click', ->
if confirm('Are you sure?')
$('.playlist-tracks li').remove()
$('.playlist li').remove()
$('#jplayer').jPlayer 'clearMedia'
$('.player .now-playing').text 'Add some music to playlist'
$('.player .loaded, .player .played').width 0
@ -199,7 +199,7 @@ $('#empty-playlist').live 'click', ->
# Playlist Actions
$('.playlist-tracks li .fade, .playlist-tracks li .duration, .playlist-tracks li .remove').live 'mousemove mouseover mouseout', (e) ->
$('.playlist li .fade, .playlist li .duration, .playlist li .remove').live 'mousemove mouseover mouseout', (e) ->
if e.type in ['mouseover', 'mousemove'] and ($(window).width() - e.clientX) < 60
$(this).parent().find('.duration').hide()
$(this).parent().find('.remove').show()
@ -208,7 +208,7 @@ $('.playlist-tracks li .fade, .playlist-tracks li .duration, .playlist-tracks li
$(this).parent().find('.duration').show()
false
$('.playlist-tracks li .remove').live 'click', ->
$('.playlist li .remove').live 'click', ->
$li = $(this).parent().parent()
if $li.hasClass 'now'
$('#jplayer').jPlayer 'clearMedia'
@ -217,7 +217,7 @@ $('.playlist-tracks li .remove').live 'click', ->
$li.remove()
false
$('.playlist-tracks li .title .playtrack').live 'click', ->
$('.playlist li .title .playtrack').live 'click', ->
_player.setTrack $(this).parent().parent().parent().attr('id').split('i')[1]
false

View File

@ -9,7 +9,7 @@ class window.Vkontakte
@api_id
init: ->
@qr = []
@qr = {}
window.vkAsyncInit = ->
VK.init apiId: _vkontakte.getApiId()
@ -118,11 +118,11 @@ class window.Vkontakte
return best_result.url
addQR: (query, url) ->
@qr[query] = url;
_vkontakte.qr[query] = url;
getQR: (query) ->
if @qr[query]?
@qr[query]
if _vkontakte.qr[query]?
_vkontakte.qr[query]
false
$('#login').live 'click', ->

View File

@ -2,6 +2,9 @@
.buttons {
text-align: center;
}
.pause {
display: none;
}
.now-playing {
text-align: center;
}

View File

@ -56,9 +56,10 @@
.loaded
.played
.buttons
%a.btn.small-round &laquo;
%a.btn.large.large-round ►
%a.btn.small-round &raquo;
%a.btn.small-round.prev &laquo;
%a.btn.large.large-round.play ►
%a.btn.large.large-round.pause II
%a.btn.small-round.next &raquo;
%ul.playlist
@ -67,3 +68,4 @@
= image_tag "loader.gif"
#vk_api_transport
#jplayer