1
0
Fork 0
oldhaven/public/javascripts/coffee/session.js

40 lines
1.1 KiB
JavaScript
Raw Normal View History

2011-06-27 20:43:54 +00:00
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];
2011-06-27 18:41:36 +00:00
}
2011-06-27 20:43:54 +00:00
}
this.vk_params = _params;
}
Session.prototype.setUser = function(user) {
this.user = user;
2011-07-02 14:10:59 +00:00
_beathaven.lang = this.user.lang || 'ru';
2011-06-30 05:12:52 +00:00
_beathaven.localizeHTML();
2011-06-27 20:43:54 +00:00
return false;
};
Session.prototype.getUser = function() {
return this.user;
};
Session.prototype.query = function(url, params, callback) {
2011-06-29 00:25:36 +00:00
var q_params;
2011-06-29 13:54:55 +00:00
q_params = $.extend({}, this.vk_params, params);
2011-06-27 20:43:54 +00:00
$.post(url, q_params, callback);
return false;
};
2011-06-29 04:11:54 +00:00
Session.prototype.reloadSession = function() {
2011-06-29 13:54:55 +00:00
_session.query('/user/auth', {}, function(ar) {
_session.setUser(ar.user);
return false;
2011-06-29 04:11:54 +00:00
});
2011-06-29 13:54:55 +00:00
return false;
2011-06-29 04:11:54 +00:00
};
2011-06-27 20:43:54 +00:00
return Session;
})();