48 lines
1.1 KiB
CoffeeScript
48 lines
1.1 KiB
CoffeeScript
class window.Session
|
|
|
|
vk_params: null
|
|
user: null
|
|
|
|
constructor: (params) ->
|
|
attrs = ['expire', 'mid', 'secret', 'sid', 'sig']
|
|
_params = {}
|
|
for key in attrs
|
|
if params[key]?
|
|
_params[key] = params[key]
|
|
@vk_params = _params
|
|
|
|
setUser: (user) ->
|
|
@user = user
|
|
_beathaven.lang = @user.lang || 'ru'
|
|
_beathaven.localizeHTML()
|
|
false
|
|
|
|
getUser: ->
|
|
@user
|
|
|
|
query: (url, params, callback) ->
|
|
q_params = $.extend {}, @vk_params, params
|
|
$.post url, q_params, callback
|
|
false
|
|
|
|
secureLoad: (url, callback) ->
|
|
q_params = $.extend {}, @vk_params
|
|
$('#content').load url, q_params, callback
|
|
false
|
|
|
|
reloadSession: ->
|
|
_session.query '/user/auth', {}, (ar) ->
|
|
_session.setUser ar.user
|
|
false
|
|
false
|
|
|
|
displayAuthorizedContent: ->
|
|
$('.playlist, .player').show()
|
|
$('.ad_here, #login').hide()
|
|
$('#authorized').css display: 'block'
|
|
|
|
hideAuthorizedContent: ->
|
|
$('.playlist, .player, #authorized').hide()
|
|
$('.ad_here').show()
|
|
$('#login').css display: 'block'
|