- 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();
-
- if (!id) {
- alert(__("No article is selected."));
- return;
- }
-
- var visible_ids = getLoadedArticleIds();
-
- var ids_to_mark = new Array();
-
- if (!below) {
- for (var i = 0; i < visible_ids.length; i++) {
- if (visible_ids[i] != id) {
- var e = $("RROW-" + visible_ids[i]);
-
- if (e && e.hasClassName("Unread")) {
- ids_to_mark.push(visible_ids[i]);
- }
- } else {
- break;
- }
- }
- } else {
- for (var i = visible_ids.length-1; i >= 0; i--) {
- if (visible_ids[i] != id) {
- var e = $("RROW-" + visible_ids[i]);
-
- if (e && e.hasClassName("Unread")) {
- ids_to_mark.push(visible_ids[i]);
- }
- } else {
- break;
- }
- }
- }
-
- if (ids_to_mark.length == 0) {
- alert(__("No articles found to mark"));
- } else {
- var msg = ngettext("Mark %d article as read?", "Mark %d articles as read?", ids_to_mark.length).replace("%d", ids_to_mark.length);
-
- if (getInitParam("confirm_feed_catchup") != 1 || confirm(msg)) {
-
- for (var i = 0; i < ids_to_mark.length; i++) {
- var e = $("RROW-" + ids_to_mark[i]);
- e.removeClassName("Unread");
- }
-
- var query = "?op=rpc&method=catchupSelected" +
- "&cmode=0" + "&ids=" + param_escape(ids_to_mark.toString());
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- handle_rpc_json(transport);
- } });
-
- }
- }
-
- } catch (e) {
- exception_error("catchupRelativeToArticle", e);
- }
-}
-
-function cdmCollapseArticle(event, id, unmark) {
- try {
- if (unmark == undefined) unmark = true;