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

39 lines
1.0 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;
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-27 20:43:54 +00:00
q_params = this.vk_params;
2011-06-29 00:25:36 +00:00
$.each(params, function(key, val) {
return q_params[key] = val;
});
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() {
return _session.query('/user/auth', {}, function(ar) {
return _session.setUser(ar.user);
});
};
2011-06-27 20:43:54 +00:00
return Session;
})();