- }
-
- 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.id.replace("RROW-", "");
-
- 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 = getVisibleArticleIds();
-
- 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;
-
- var row = $("RROW-" + id);
- var elem = $("CICD-" + id);
-
- if (elem && row) {
- var collapse = $$("div#RROW-" + id +
- " span[class='collapseBtn']")[0];
-
- Element.hide(elem);
- Element.show("CEXC-" + id);
- Element.hide(collapse);
-
- if (unmark) {
- row.removeClassName("active");
-
- markHeadline(id, false);
-
- if (id == getActiveArticleId()) {
- setActiveArticleId(0);
- }
-
- updateSelectedPrompt();
- }
-
- if (event) Event.stop(event);
-
- PluginHost.run(PluginHost.HOOK_ARTICLE_COLLAPSED, id);
-
- if (row.offsetTop < $("headlines-frame").scrollTop)
- scrollToRowId(row.id);
-
- $("floatingTitle").style.visibility = "hidden";
- $("floatingTitle").setAttribute("rowid", false);
- }
-
- } catch (e) {
- exception_error("cdmCollapseArticle", e);
- }
-}
-
-function cdmExpandArticle(id, noexpand) {
- try {
- console.log("cdmExpandArticle " + id);
-
- if (!$("RROW-" + id)) return false;
-
- var oldrow = $("RROW-" + getActiveArticleId());
-
- var elem = $("CICD-" + getActiveArticleId());
-
- if (id == getActiveArticleId() && Element.visible(elem))
- return true;
-
- selectArticles("none");
-
- var old_offset = $("RROW-" + id).offsetTop;
-
- if (getActiveArticleId() && elem && !getInitParam("cdm_expanded")) {
- var collapse = $$("div#RROW-" + getActiveArticleId() +
- " span[class='collapseBtn']")[0];
-
- Element.hide(elem);
- Element.show("CEXC-" + getActiveArticleId());
- Element.hide(collapse);
- }
-
- if (oldrow) oldrow.removeClassName("active");
-
- setActiveArticleId(id);
-
- elem = $("CICD-" + id);
-
- var collapse = $$("div#RROW-" + id +
- " span[class='collapseBtn']")[0];
-
- var cencw = $("CENCW-" + id);
-
- if (!Element.visible(elem) && !noexpand) {
- if (cencw) {
- cencw.innerHTML = htmlspecialchars_decode(cencw.innerHTML);
- cencw.setAttribute('id', '');
- Element.show(cencw);
- }
-
- Element.show(elem);
- Element.hide("CEXC-" + id);
- Element.show(collapse);
- }
-
- var new_offset = $("RROW-" + id).offsetTop;
-
- if (old_offset > new_offset)
- $("headlines-frame").scrollTop -= (old_offset-new_offset);
-
- if (!noexpand) {
- if (catchup_id_batch.indexOf(id) == -1)
- catchup_id_batch.push(id);
-
- catchupCurrentBatchIfNeeded();
- }
-
- toggleSelected(id);
- $("RROW-" + id).addClassName("active");
-
- PluginHost.run(PluginHost.HOOK_ARTICLE_EXPANDED, id);
-
- } catch (e) {
- exception_error("cdmExpandArticle", e);
- }
-
- return false;
-}
-
-function getArticleUnderPointer() {
- return post_under_pointer;
-}
-
-function scrollArticle(offset) {
- try {
- if (!isCdmMode()) {
- var ci = $("content-insert");
- if (ci) {
- ci.scrollTop += offset;
- }
- } else {
- var hi = $("headlines-frame");
- if (hi) {
- hi.scrollTop += offset;
- }