query = query + "&omode=flc";
}
- if (!page_offset) {
- notify_progress("Loading, please wait...", true);
- }
-
var container = document.getElementById("headlinesInnerContainer");
if (container && page_offset == 0 && !isCdmMode()) {
queue: { position:'end', scope: 'FEEDL-' + feed, limit: 1 } } );
}
- new Ajax.Request(query, {
- onComplete: function(transport) {
- headlines_callback2(transport, feed, is_cat, page_offset);
- } });
+ var unread_ctr = document.getElementById("FEEDU-" + feed);
+ var cache_check = false;
+
+ if (unread_ctr && !page_offset) {
+ unread_ctr = unread_ctr.innerHTML;
+ cache_check = cache_check_param("F:" + feed, unread_ctr);
+ debug("headline cache check: " + cache_check);
+ }
+
+ if (cache_check) {
+ var f = document.getElementById("headlines-frame");
+
+ clean_feed_selections();
+
+ setActiveFeedId(feed);
+
+ if (is_cat != undefined) {
+ active_feed_is_cat = is_cat;
+ }
+
+ if (!is_cat) {
+ var feedr = document.getElementById("FEEDR-" + feed);
+ if (feedr && !feedr.className.match("Selected")) {
+ feedr.className = feedr.className + "Selected";
+ }
+ }
+
+ f.innerHTML = cache_find("F:" + feed);
+
+ var query = "backend.php?op=rpc&subop=getAllCounters";
+
+ if (tagsAreDisplayed()) {
+ query = query + "&omode=tl";
+ } else {
+ query = query + "&omode=flc";
+ }
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ try {
+ all_counters_callback2(transport);
+ } catch (e) {
+ exception_error("viewfeed/getcounters", e);
+ }
+ } });
+
+ } else {
+
+ if (!page_offset) {
+ notify_progress("Loading, please wait...", true);
+ }
+
+ new Ajax.Request(query, {
+ onComplete: function(transport) {
+ headlines_callback2(transport, feed, is_cat, page_offset);
+ } });
+ }
} catch (e) {
exception_error("viewfeed", e);
}
}
-function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) {
+function clean_feed_selections() {
try {
-
- debug("headlines_callback2 [page=" + feed_cur_page + "]");
-
var feeds = document.getElementById("feedList").getElementsByTagName("LI");
for (var i = 0; i < feeds.length; i++) {
feeds[i].className = feeds[i].className.replace("Selected", "");
}
}
+ } catch (e) {
+ exception_error("clean_feed_selections", e);
+ }
+}
+
+function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) {
+ try {
+
+ debug("headlines_callback2 [page=" + feed_cur_page + "]");
+
+ clean_feed_selections();
setActiveFeedId(active_feed_id);
if (transport.responseXML) {
var headlines = transport.responseXML.getElementsByTagName("headlines")[0];
var headlines_count_obj = transport.responseXML.getElementsByTagName("headlines-count")[0];
-
+ var headlines_unread_obj = transport.responseXML.getElementsByTagName("headlines-unread")[0];
+
var headlines_count = headlines_count_obj.getAttribute("value");
-
+ var headlines_unread = headlines_unread_obj.getAttribute("value");
+
if (headlines_count == 0) _infscroll_disable = 1;
var counters = transport.responseXML.getElementsByTagName("counters")[0];
if (feed_cur_page == 0) {
if (headlines) {
f.innerHTML = headlines.firstChild.nodeValue;
+
+ cache_inject("F:" + active_feed_id,
+ headlines.firstChild.nodeValue, headlines_unread);
+
} else {
debug("headlines_callback: returned no data");
f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
}
-function cache_inject(id, article) {
- if (!cache_check(id)) {
- debug("cache_article: miss: " + id);
+function cache_inject(id, article, param) {
+ if (!cache_check(id, param)) {
+ debug("cache_article: miss: " + id + " [p=" + param + "]");
var cache_obj = new Array();
cache_obj["id"] = id;
cache_obj["data"] = article;
+ cache_obj["param"] = param;
article_cache.push(cache_obj);
} else {
- debug("cache_article: hit: " + id);
+ debug("cache_article: hit: " + id + " [p=" + param + "]");
}
}
return false;
}
+function cache_get_param(id) {
+ for (var i = 0; i < article_cache.length; i++) {
+ if (article_cache[i]["id"] == id) {
+ return article_cache[i]["param"];
+ }
+ }
+ return false;
+}
+
function cache_check(id) {
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id) {
return false;
}
+function cache_check_param(id, param) {
+ for (var i = 0; i < article_cache.length; i++) {
+ if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
+ return true;
+ }
+ }
+ return false;
+}
+
function cache_expire() {
while (article_cache.length > 20) {
article_cache.shift();