VK auth fix
This commit is contained in:
parent
16a52c9346
commit
afdd9885bf
|
@ -51,7 +51,7 @@ class window.Player
|
|||
addTracks: (tracks, autoplay) ->
|
||||
if not autoplay?
|
||||
autoplay = false
|
||||
initial_count = $('.playlist-tracks li').length
|
||||
initial_count = $('.playlist li').length
|
||||
for item in tracks
|
||||
$('.playlist').append '
|
||||
<li id="i' +Math.round(Math.random() * 999999)+ '" data-id="'+item.id+'">
|
||||
|
@ -62,11 +62,10 @@ class window.Player
|
|||
</li>'
|
||||
_player.playlist.push item
|
||||
$('.playlist').sortable axis: 'y', handle: '.drag'
|
||||
|
||||
# if autoplay
|
||||
# _player.setTrack($('.playlist-tracks li').last().attr('id').split('i')[1])
|
||||
# else if initial_count == 0 and not _player.hasTrack()
|
||||
# _player.setTrack($('.playlist-tracks li').first().attr('id').split('i')[1])
|
||||
if autoplay?
|
||||
_player.setTrack($('.playlist li').last().attr('id').split('i')[1])
|
||||
else if initial_count == 0 and not _player.hasTrack()
|
||||
_player.setTrack($('.playlist li').first().attr('id').split('i')[1])
|
||||
false
|
||||
|
||||
getDataFromLi: (obj) ->
|
||||
|
@ -77,18 +76,23 @@ class window.Player
|
|||
|
||||
setTrack: (id) ->
|
||||
$obj = $('#i' +id)
|
||||
query = $obj.attr('data-artist')+ ' — ' +$obj.attr('data-track')
|
||||
track = _player.getTrackInfo $obj.attr('data-id')
|
||||
query = track.artist+ ' — ' +track.name
|
||||
|
||||
$('.player .loaded, .player .played').width 0
|
||||
$('.player .now-playing').html query+'<div class="fade"></div>'
|
||||
$('.playlist-tracks li').removeClass 'now'
|
||||
$('.player .now-playing').html query
|
||||
$('.playlist li').removeClass 'now'
|
||||
$obj.addClass 'now'
|
||||
$('.tracklist li').removeClass 'now'
|
||||
$('.tracklist li[data-id="'+$obj.attr('data-id')+'"]').addClass 'now'
|
||||
|
||||
_vkontakte.loadTracksData $obj.attr('data-artist'), $obj.attr('data-track'), $obj.attr('data-length'), (url) ->
|
||||
console.log(track)
|
||||
_vkontakte.loadTracksData track.artist, track.name, track.duration, (url) ->
|
||||
_player.playSource url
|
||||
this.updateNowListening $obj.attr('data-artist'), $obj.attr('data-album'), $obj.attr('data-track')
|
||||
this.updateNowListening track.artist, track.album, track.name
|
||||
false
|
||||
|
||||
getTrackInfo: (id) ->
|
||||
for track in _player.playlist
|
||||
if track.id == parseInt(id, 10)
|
||||
return track
|
||||
false
|
||||
|
||||
hasTrack: ->
|
||||
|
|
|
@ -24,9 +24,6 @@ class window.Vkontakte
|
|||
authInfo: (response) ->
|
||||
if typeof response isnt 'undefined' and response.session
|
||||
_session = new Session(response.session)
|
||||
|
||||
$('#vk_login, .auth-notice').hide()
|
||||
|
||||
_session.query '/user/auth', {}, (ar) ->
|
||||
if ar.newbie
|
||||
VK.Api.call 'getVariable', key: 1281, (r) ->
|
||||
|
@ -37,11 +34,15 @@ class window.Vkontakte
|
|||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
$('.fullscreen').hide();
|
||||
$('#login').hide()
|
||||
$('#authorized').css display: 'block'
|
||||
else
|
||||
_session.setUser ar.user
|
||||
|
||||
$('#username')
|
||||
.html (if _session.getUser().name then _session.getUser().name else '%username%')
|
||||
$('#login').hide()
|
||||
$('#authorized').css display: 'block'
|
||||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
$('.fullscreen').hide();
|
||||
|
@ -54,9 +55,8 @@ class window.Vkontakte
|
|||
else
|
||||
_session = new Session({})
|
||||
_session.setUser {}
|
||||
$('#vk_login').css display: 'block'
|
||||
$('.auth-notice').css('left', $('#vk_login').offset().left).show()
|
||||
$('.header-container .hello').hide()
|
||||
$('#login').css display: 'block'
|
||||
$('#authorized').hide()
|
||||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
$('.fullscreen').hide();
|
||||
|
@ -125,13 +125,13 @@ class window.Vkontakte
|
|||
@qr[query]
|
||||
false
|
||||
|
||||
$('#vk_login, .auth-notice').live 'click', ->
|
||||
$('#login').live 'click', ->
|
||||
VK.Auth.login (response) ->
|
||||
_vkontakte.authInfo(response)
|
||||
false
|
||||
, 8
|
||||
false
|
||||
$('#vk_logout').live 'click', ->
|
||||
$('#logout').live 'click', ->
|
||||
_ajax.go '/search/';
|
||||
VK.Auth.logout (response) ->
|
||||
_vkontakte.authInfo(response)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#main {
|
||||
margin-top: 60px;
|
||||
}
|
||||
|
||||
#authorized {
|
||||
display: none;
|
||||
}
|
|
@ -47,5 +47,8 @@
|
|||
float: right;
|
||||
margin: 10px 5px 0 0;
|
||||
}
|
||||
&.now {
|
||||
background-color: #DEF;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,9 @@
|
|||
#artist-load-spinner
|
||||
= image_tag "artist_loader.gif"
|
||||
%ul.nav.secondary-nav
|
||||
%li.dropdown
|
||||
%li
|
||||
%a#login{ :href => "#/login/" }= I18n.t 'global.login'
|
||||
%li.dropdown#authorized
|
||||
%a.dropdown-toggle#username{ :href => "#/" } %username%
|
||||
%ul.dropdown-menu
|
||||
%li
|
||||
|
|
Loading…
Reference in New Issue