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