- var hsp = $("headlines-spacer");
-
- unpackVisibleHeadlines();
-
- // set topmost child in the buffer as active
- if (isCdmMode() && getInitParam("cdm_auto_catchup") == 1 &&
- getSelectedArticleIds2().length <= 1 &&
- getInitParam("cdm_expanded")) {
-
- var rows = $$("#headlines-frame > div[id*=RROW]");
-
- for (var i = 0; i < rows.length; i++) {
- var child = rows[i];
-
- if ($("headlines-frame").scrollTop <= child.offsetTop &&
- child.offsetTop - $("headlines-frame").scrollTop < 100 &&
- child.getAttribute("data-article-id") != _active_article_id) {
-
- if (_active_article_id) {
- var row = $("RROW-" + _active_article_id);
- if (row) row.removeClassName("active");
- }
-
- _active_article_id = child.getAttribute("data-article-id");
- showArticleInHeadlines(_active_article_id, true);
- updateSelectedPrompt();
- break;
- }
- }
- }
-
- if (!_infscroll_disable) {
- if (hsp && hsp.offsetTop - 250 <= e.scrollTop + e.offsetHeight) {
-
- hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
- __("Loading, please wait...") + "</span>";
-
- loadMoreHeadlines();
- return;
-
- }
- }
-
- if (isCdmMode()) {
- updateFloatingTitle();
- }
-
- catchupCurrentBatchIfNeeded();
-
- if (getInitParam("cdm_auto_catchup") == 1) {
-
- // let's get DOM some time to settle down
- var ts = new Date().getTime();
- if (ts - _last_headlines_update < 100) return;
-
- $$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
- function(child) {
- if (child.hasClassName("Unread") && $("headlines-frame").scrollTop >
- (child.offsetTop + child.offsetHeight/2)) {
-
- var id = child.getAttribute("data-article-id")
-
- if (catchup_id_batch.indexOf(id) == -1)
- catchup_id_batch.push(id);
-
- //console.log("auto_catchup_batch: " + catchup_id_batch.toString());
- }
-
- });
-
- if (_infscroll_disable) {
- var child = $$("#headlines-frame div[id*=RROW]").last();
-
- if (child && $("headlines-frame").scrollTop >
- (child.offsetTop + child.offsetHeight - 50)) {
-
- console.log("we seem to be at an end");
-
- if (getInitParam("on_catchup_show_next_feed") == "1") {
- openNextUnreadFeed();
- }
- }
- }
- }
-
- } catch (e) {
- console.warn("headlines_scroll_handler: " + e);
- }
-}
-
-function openNextUnreadFeed() {
- try {
- var is_cat = activeFeedIsCat();
- var nuf = getNextUnreadFeed(getActiveFeedId(), is_cat);
- if (nuf) viewfeed({feed: nuf, is_cat: is_cat});
- } catch (e) {
- exception_error("openNextUnreadFeed", e);
- }
-}
-
-function catchupBatchedArticles() {
- try {
- if (catchup_id_batch.length > 0 && !_infscroll_request_sent && !_catchup_request_sent) {
-
- console.log("catchupBatchedArticles: working");
-
- // make a copy of the array
- var batch = catchup_id_batch.slice();
- var query = "?op=rpc&method=catchupSelected" +
- "&cmode=0&ids=" + param_escape(batch.toString());
-
- console.log(query);
-
- _catchup_request_sent = true;
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- handle_rpc_json(transport);
-
- _catchup_request_sent = false;
-
- reply = JSON.parse(transport.responseText);
- var batch = reply.ids;
-
- batch.each(function(id) {
- console.log(id);
- var elem = $("RROW-" + id);
- if (elem) elem.removeClassName("Unread");
- catchup_id_batch.remove(id);
- });
-
- updateFloatingTitle(true);
-
- } });
- }
-
- } catch (e) {
- exception_error("catchupBatchedArticles", e);
- }
-}
-
-function catchupRelativeToArticle(below, id) {
-
- try {
-
- if (!id) id = getActiveArticleId();