This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Bungloo/WebKit/scripts/helper/Cache.js
2012-12-07 08:47:19 +01:00

49 lines
No EOL
1 KiB
JavaScript

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;
});