last_requested_article = 0;
- var cached_headlines = false;
-
- if (feed == getActiveFeedId() && activeFeedIsCat() == is_cat) {
- cache_delete("feed:" + feed + ":" + is_cat);
- } else {
- cached_headlines = cache_get("feed:" + feed + ":" + is_cat);
-
+ if (feed != getActiveFeedId() || activeFeedIsCat() != is_cat) {
if (!background && _search_query) _search_query = false;
-
- // switching to a different feed, we might as well catchup stuff visible
- // in headlines buffer (if any)
- // disabled for now because this behavior is considered confusing -fox
- /* if (!background && isCdmMode() && getInitParam("cdm_auto_catchup") == 1 && parseInt(getActiveFeedId()) > 0) {
-
- $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
- function(child) {
- var hf = $("headlines-frame");
-
- if (hf.scrollTop + hf.offsetHeight >=
- child.offsetTop + child.offsetHeight) {
-
- var id = child.id.replace("RROW-", "");
-
- if (catchup_id_batch.indexOf(id) == -1)
- catchup_id_batch.push(id);
-
- }
-
- if (catchup_id_batch.length > 0) {
- window.clearTimeout(catchup_timeout_id);
-
- if (!_infscroll_request_sent) {
- catchup_timeout_id = window.setTimeout('catchupBatchedArticles()',
- 2000);
- }
- }
-
- });
- } */
}
if (!background) {
_infscroll_disable = 0;
}
- if (!offset && !method && cached_headlines && !background) {
- try {
- render_local_headlines(feed, is_cat, JSON.parse(cached_headlines));
- return;
- } catch (e) {
- console.warn("render_local_headlines failed: " + e);
- }
- }
-
if (offset != 0 && !method) {
var timestamp = get_timestamp();
request_counters(true);
timeout();
- setTimeout("precache_headlines_idle()", 15000);
} catch (e) {
exception_error("feedlist/init", e);
if (getFeedUnread(id, (kind == "cat")) != ctr ||
(kind == "cat")) {
-
- cache_delete("feed:" + id + ":" + (kind == "cat"));
}
setFeedUnread(id, (kind == "cat"), ctr);
}
}
- cache_delete("feed:" + feed + ":" + is_cat);
-
} catch (e) {
exception_error("decrement_feed_counter", e);
}
var catchup_id_batch = [];
var catchup_timeout_id = false;
-var feed_precache_timeout_id = false;
-var precache_idle_timeout_id = false;
var cids_requested = [];
var loaded_article_ids = [];
if (getInitParam("cdm_auto_catchup") == 1) {
content = content + "<div id='headlines-spacer'></div>";
}
-
- cache_headlines(feed_id, is_cat, reply['headlines']['toolbar'], content);
return;
}
}
}
- if (headlines_count > 0)
- cache_headlines(feed_id, is_cat, reply['headlines']['toolbar'], $("headlines-frame").innerHTML);
-
if (articles) {
for (var i = 0; i < articles.length; i++) {
var a_id = articles[i]['id'];
console.log("no cached articles received");
}
- // do not precache stuff after fresh feed
- if (feed_id != -3)
- precache_headlines();
-
if (counters)
parse_counters(counters);
else
//
}
- if (article_is_unread && view_mode == "all_articles") {
- cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
- }
-
markHeadline(id);
if (article_is_unread)
setActiveArticleId(id);
showArticleInHeadlines(id);
- precache_headlines();
-
if (cached_article && article_is_unread) {
query = query + "&mode=prefetch";
query = query + "&mark=0";
}
- cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
-
if (!client_only) {
new Ajax.Request("backend.php", {
parameters: query,
query = query + "&pub=0";
}
- cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
-
if (!client_only) {
new Ajax.Request("backend.php", {
parameters: query,
if (ctr) ctr.innerHTML = elem.labels;
});
-
- cache_headlines(getActiveFeedId(), activeFeedIsCat(), null, $("headlines-frame").innerHTML);
-
}
} catch (e) {
exception_error("show_labels_in_headlines", e);
sessionStorage.removeItem(id);
}
-function cache_headlines(feed, is_cat, toolbar_obj, content_obj) {
- if (toolbar_obj && content_obj) {
- cache_set("feed:" + feed + ":" + is_cat,
- JSON.stringify({toolbar: toolbar_obj, content: content_obj}));
- } else {
- try {
- obj = cache_get("feed:" + feed + ":" + is_cat);
-
- if (obj) {
- obj = JSON.parse(obj);
-
- if (toolbar_obj) obj.toolbar = toolbar_obj;
- if (content_obj) obj.content = content_obj;
-
- cache_set("feed:" + feed + ":" + is_cat, JSON.stringify(obj));
- }
-
- } catch (e) {
- console.warn("cache_headlines failed: " + e);
- }
- }
-}
-
-function render_local_headlines(feed, is_cat, obj) {
- try {
-
- dijit.byId("headlines-toolbar").attr('content',
- obj.toolbar);
-
- dijit.byId("headlines-frame").attr('content',
- obj.content);
-
- dojo.parser.parse('headlines-toolbar');
-
- $("headlines-frame").scrollTop = 0;
- selectArticles('none');
- setActiveFeedId(feed, is_cat);
- initHeadlinesMenu();
-
- dijit.getEnclosingWidget(
- document.forms["main_toolbar_form"].update).attr('disabled',
- is_cat || feed <= 0);
-
- precache_headlines();
-
- } catch (e) {
- exception_error("render_local_headlines", e);
- }
-}
-
-function precache_headlines_idle() {
- try {
- if (getInitParam("bw_limit") != "1" && !feed_precache_timeout_id) {
- if (get_timestamp() - _viewfeed_last > 120) {
-
- var feeds = dijit.byId("feedTree").getVisibleUnreadFeeds();
- var uncached = [];
-
- feeds.each(function(item) {
- if (parseInt(item[0]) > 0 && !cache_get("feed:" + item[0] + ":" + item[1]))
- uncached.push(item);
- });
-
- if (uncached.length > 0) {
- var rf = uncached[Math.floor(Math.random()*uncached.length)];
- viewfeed(rf[0], '', rf[1], 0, true);
- }
- }
- }
- precache_idle_timeout_id = setTimeout("precache_headlines_idle()", 1000*30);
-
- } catch (e) {
- exception_error("precache_headlines_idle", e);
- }
-}
-
-function precache_headlines() {
- try {
- if (getInitParam("bw_limit") != "1" && !feed_precache_timeout_id) {
-
- feed_precache_timeout_id = window.setTimeout(function() {
- var nuf = getNextUnreadFeed(getActiveFeedId(), activeFeedIsCat());
- var nf = dijit.byId("feedTree").getNextFeed(getActiveFeedId(), activeFeedIsCat());
-
- if (nuf && !cache_get("feed:" + nuf + ":" + activeFeedIsCat()))
- viewfeed(nuf, '', activeFeedIsCat(), 0, true);
-
- if (nf && nf[0] != nuf && !cache_get("feed:" + nf[0] + ":" + nf[1]))
- viewfeed(nf[0], '', nf[1], 0, true);
-
- window.setTimeout(function() {
- feed_precache_timeout_id = false;
- }, 3000);
- }, 1000);
- }
-
- } catch (e) {
- exception_error("precache_headlines", e);
- }
-}
-
function cancelSearch() {
try {
_search_query = "";