if (xmlhttp_rpc.readyState == 4) {
try {
debug("catchup_callback");
- if (_catchup_callback_func) {
- setTimeout(_catchup_callback_func, 100);
- }
notify("");
all_counters_callback();
+ if (_catchup_callback_func) {
+ setTimeout(_catchup_callback_func, 10);
+ }
} catch (e) {
exception_error("catchup_callback", e);
}
debug("headlines_callback");
var f = document.getElementById("headlines-frame");
try {
- f.scrollTop = 0;
+ if (feed_cur_page == 0) {
+ debug("resetting headlines scrollTop");
+ f.scrollTop = 0;
+ }
} catch (e) { };
if (xmlhttp.responseXML) {
var headlines = xmlhttp.responseXML.getElementsByTagName("headlines")[0];
var counters = xmlhttp.responseXML.getElementsByTagName("counters")[0];
+ var articles = xmlhttp.responseXML.getElementsByTagName("article");
+ var runtime_info = xmlhttp.responseXML.getElementsByTagName("runtime-info");
- f.innerHTML = headlines.firstChild.nodeValue;
+ if (feed_cur_page == 0) {
+ if (headlines) {
+ f.innerHTML = headlines.firstChild.nodeValue;
+ } else {
+ debug("headlines_callback: returned no data");
+ f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML data)') + "</div>";
+
+ }
+ } else {
+ if (headlines) {
+ debug("adding some more headlines...");
+
+ var c = document.getElementById("headlinesList");
+
+ if (!c) {
+ c = document.getElementById("headlinesInnerContainer");
+ }
+
+ c.innerHTML = c.innerHTML + headlines.firstChild.nodeValue;
+ } else {
+ debug("headlines_callback: returned no data");
+ notify_error("Error while trying to load more headlines");
+ }
+
+ }
+
+ if (articles) {
+ for (var i = 0; i < articles.length; i++) {
+ var a_id = articles[i].getAttribute("id");
+ debug("found id: " + a_id);
+ cache_inject(a_id, articles[i].firstChild.nodeValue);
+ }
+ } else {
+ debug("no cached articles received");
+ }
if (counters) {
debug("parsing piggybacked counters: " + counters);
parse_counters(counters, false);
+ } else {
+ debug("counters container not found in reply");
}
+
+ if (runtime_info) {
+ debug("parsing runtime info: " + runtime_info[0]);
+ parse_runtime_info(runtime_info[0]);
+ } else {
+ debug("counters container not found in reply");
+ }
+
} else {
debug("headlines_callback: returned no XML object");
- f.innerHTML = xmlhttp.responseText;
- update_all_counters();
+ f.innerHTML = "<div class='whiteBox'>" + __('Could not update headlines (missing XML object)') + "</div>";
}
if (typeof correctPNG != 'undefined') {
try {
document.getElementById("headlinesInnerContainer").scrollTop = _tag_cdm_scroll;
_tag_cdm_scroll = false;
+ debug("resetting headlinesInner scrollTop");
+
} catch (e) { }
}
} else {
debug("article_callback: returned no XML object");
+ var f = document.getElementById("content-frame");
+ f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
}
} catch (e) {
exception_error("article_callback", e);
debug("parsing piggybacked counters: " + counters);
parse_counters(counters, false);
} else {
- update_all_counters();
+ debug("counters container not found in reply");
}
}
var cached_article = cache_find(id);
debug("cache check result: " + (cached_article != false));
-
-/* if (!skip_history) {
- history_push("ARTICLE:" + id + ":" + feed_id);
- } */
enableHotkeys();
- active_post_id = id;
//setActiveFeedId(feed_id);
var query = "backend.php?op=view&id=" + param_escape(id) +
if (!xmlhttp_ready(xmlhttp) && last_article_view < date.getTime() / 1000 - 15) {
debug("<b>xmlhttp seems to be stuck at view, aborting</b>");
xmlhttp.abort();
+ if (is_safari()) {
+ debug("trying alternative reset method for Safari");
+ xmlhttp = Ajax.getTransport();
+ }
}
- if (cached_article || xmlhttp_ready(xmlhttp)) {
+ if (xmlhttp_ready(xmlhttp)) {
+
+ active_post_id = id;
cleanSelected("headlinesList");
} else if (cached_article) {
+ query = query + "&mode=prefetch_old";
+
+ debug(query);
+
+ xmlhttp.open("GET", query, true);
+ xmlhttp.onreadystatechange=article_callback;
+ xmlhttp.send(null);
+
render_article(cached_article);
}
}
}
+function tMark(id) {
+ return toggleMark(id);
+}
+
function toggleMark(id) {
if (!xmlhttp_ready(xmlhttp_rpc)) {
var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
- var mark_img = document.getElementById("FMARKPIC-" + id);
+ var mark_img = document.getElementById("FMPIC-" + id);
var vfeedu = document.getElementById("FEEDU--1");
var crow = document.getElementById("RROW-" + id);
}
+function correctHeadlinesOffset(id) {
+
+ try {
+
+ var hlist = document.getElementById("headlinesList");
+ var container = document.getElementById("headlinesInnerContainer");
+ var row = document.getElementById("RROW-" + id);
+
+ var viewport = container.offsetHeight;
+
+ var rel_offset_top = row.offsetTop - container.scrollTop;
+ var rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
+
+ debug("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
+ debug("Vport: " + viewport);
+
+ if (rel_offset_top <= 0 || rel_offset_top > viewport) {
+ container.scrollTop = row.offsetTop;
+ } else if (rel_offset_bottom > viewport) {
+
+ /* doesn't properly work with Opera in some cases because
+ Opera fucks up element scrolling */
+
+ container.scrollTop = row.offsetTop + row.offsetHeight - viewport;
+ }
+
+ } catch (e) {
+ exception_error("correctHeadlinesOffset", e);
+ }
+
+}
+
function moveToPost(mode) {
// check for combined mode
var rows = getVisibleHeadlineIds();
- var prev_id;
- var next_id;
+ var prev_id = false;
+ var next_id = false;
if (!document.getElementById('RROW-' + active_post_id)) {
active_post_id = false;
}
if (mode == "next") {
- if (next_id != undefined) {
+ if (next_id) {
+ correctHeadlinesOffset(next_id);
view(next_id, getActiveFeedId());
}
}
if (mode == "prev") {
- if ( prev_id != undefined) {
+ if (prev_id) {
+ correctHeadlinesOffset(prev_id);
view(prev_id, getActiveFeedId());
}
}
function catchupPage() {
+ var fn = getFeedName(getActiveFeedId(), active_feed_is_cat);
+
+ var str = "Mark all visible articles in " + fn + " as read?";
+
+ if (getInitParam("confirm_feed_catchup") == 1 && !confirm(str)) {
+ return;
+ }
+
if (document.getElementById("headlinesList")) {
selectTableRowsByIdPrefix('headlinesList', 'RROW-', 'RCHK-', true, 'Unread', true);
selectionToggleUnread(false, false, 'viewCurrentFeed()', true);
_tag_active_post_id = id;
_tag_active_feed_id = feed_id;
_tag_active_cdm = cdm_enabled;
+
+ cache_invalidate(id);
+
try {
_tag_cdm_scroll = document.getElementById("headlinesInnerContainer").scrollTop;
} catch (e) { }
var query = Form.serialize("tag_edit_form");
- xmlhttp_rpc.open("GET", "backend.php?op=rpc&subop=setArticleTags&" + query, true);
+ query = "backend.php?op=rpc&subop=setArticleTags&" + query;
+
+ debug(query);
+
+ xmlhttp_rpc.open("GET", query, true);
xmlhttp_rpc.onreadystatechange=tag_saved_callback;
xmlhttp_rpc.send(null);
var cache_obj = new Array();
- var d = new Date();
-
cache_obj["id"] = id;
- cache_obj["entered"] = d.getTime() / 1000;
cache_obj["data"] = article;
- cache_obj["last_access"] = 0;
-
- //article_cache[id] = cache_obj;
article_cache.push(cache_obj);
function cache_find(id) {
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id) {
- var d = new Date();
- article_cache[i]["last_access"] = d.getTime() / 1000;
return article_cache[i]["data"];
}
}
}
function cache_expire() {
- while (article_cache.length > 30) {
+ while (article_cache.length > 20) {
article_cache.shift();
}
}
+
+function cache_invalidate(id) {
+ var i = 0
+
+ try {
+
+ while (i < article_cache.length) {
+ if (article_cache[i]["id"] == id) {
+ debug("cache_invalidate: removed id " + id);
+ article_cache.splice(i, 1);
+ return true;
+ }
+ i++;
+ }
+ debug("cache_invalidate: id not found: " + id);
+ return false;
+ } catch (e) {
+ exception_error("cache_invalidate", e);
+ }
+}
+
+function getActiveArticleId() {
+ return active_post_id;
+}
+
+function cdmMouseIn(elem) {
+ try {
+ if (elem.id && elem.id.match("RROW-")) {
+ var id = elem.id.replace("RROW-", "");
+ active_post_id = id;
+ }
+ } catch (e) {
+ exception_error("cdmMouseIn", e);
+ }
+
+}
+
+function cdmMouseOut(elem) {
+ active_post_id = false;
+}
+
+function headlines_scroll_handler() {
+ try {
+
+ var e = document.getElementById("headlinesInnerContainer");
+
+ if (e.scrollTop + e.offsetHeight == e.scrollHeight) {
+ debug("more cowbell!");
+
+ viewNextFeedPage();
+ }
+
+ } catch (e) {
+ exception_error("headlines_scroll_handler", e);
+ }
+}