renamed Followings to Cache and fixed #85

This commit is contained in:
Jeena Paradies 2012-12-07 08:47:19 +01:00
parent 4edf2e6c13
commit 34e3990af6

View file

@ -0,0 +1,49 @@
define([
"helper/Paths",
"lib/URI"
],
function(Paths, URI) {
function Cache() {
this.timeout = 2 * 60 * 1000;
this.before_id = null;
this.followings = {};
var _this = this;
this.intervall = setInterval(function() { _this.getAllFollowings(); }, this.timeout);
this.getAllFollowings();
}
Cache.prototype.getAllFollowings = function() {
var _this = this;
var callback = function(resp) {
var fs = JSON.parse(resp.responseText)
if (fs.length < 1) return;
for (var i = 0; i < fs.length; i++) {
var following = fs[i];
_this.before_id = following.id;
_this.followings[following.entity] = following;
}
}
var url = URI(Paths.mkApiRootPath("/followings"));
if (this.before_id) {
url.addSearch("before_id", this.before_id);
}
Paths.getURL(url, "GET", callback);
}
return Cache;
});