40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
var Session;
|
|
Session = (function() {
|
|
Session.prototype.vk_params = null;
|
|
Session.prototype.user = null;
|
|
function Session(params) {
|
|
var attrs, key, _i, _len, _params;
|
|
attrs = ['expire', 'mid', 'secret', 'sid', 'sig'];
|
|
_params = {};
|
|
for (_i = 0, _len = attrs.length; _i < _len; _i++) {
|
|
key = attrs[_i];
|
|
if (params[key] != null) {
|
|
_params[key] = params[key];
|
|
}
|
|
}
|
|
this.vk_params = _params;
|
|
}
|
|
Session.prototype.setUser = function(user) {
|
|
this.user = user;
|
|
_beathaven.lang = this.user.lang || 'ru';
|
|
_beathaven.localizeHTML();
|
|
return false;
|
|
};
|
|
Session.prototype.getUser = function() {
|
|
return this.user;
|
|
};
|
|
Session.prototype.query = function(url, params, callback) {
|
|
var q_params;
|
|
q_params = $.extend({}, this.vk_params, params);
|
|
$.post(url, q_params, callback);
|
|
return false;
|
|
};
|
|
Session.prototype.reloadSession = function() {
|
|
_session.query('/user/auth', {}, function(ar) {
|
|
_session.setUser(ar.user);
|
|
return false;
|
|
});
|
|
return false;
|
|
};
|
|
return Session;
|
|
})(); |