var cache_added = [];
-function headlines_callback2(transport, feed_cur_page) {
+var catchup_id_batch = [];
+var catchup_timeout_id = false;
+
+function headlines_callback2(transport, offset) {
try {
handle_rpc_json(transport);
loading_set_progress(25);
- console.log("headlines_callback2 [page=" + feed_cur_page + "]");
+ console.log("headlines_callback2 [offset=" + offset + "]");
var is_cat = false;
var feed_id = false;
update_btn.disabled = !(feed_id >= 0 && !is_cat);
try {
- if (feed_cur_page == 0) {
+ if (offset == 0) {
$("headlines-frame").scrollTop = 0;
}
} catch (e) { };
var articles = reply['articles'];
var runtime_info = reply['runtime-info'];
- if (feed_cur_page == 0) {
+ if (offset == 0) {
dijit.byId("headlines-frame").attr('content',
reply['headlines']['content']);
dijit.byId("headlines-toolbar").attr('content',
reply['headlines']['toolbar']);
+ var hsp = $("headlines-spacer");
+ if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
+
+/* if (!_infscroll_disable)
+ hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
+ __("Loading, please wait..."); */
+
+ dijit.byId('headlines-frame').domNode.appendChild(hsp);
+
initHeadlinesMenu();
} else {
$("headlines-tmp").innerHTML = reply['headlines']['content'];
+ var hsp = $("headlines-spacer");
+
+ if (hsp)
+ c.domNode.removeChild(hsp);
+
$$("#headlines-tmp > div").each(function(row) {
+ row.style.display = 'none';
c.domNode.appendChild(row);
});
+ if (!hsp) hsp = new Element("DIV", {"id": "headlines-spacer"});
+
+/* if (!_infscroll_disable)
+ hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
+ __("Loading, please wait..."); */
+
+ fixHeadlinesOrder(getLoadedArticleIds());
+
+ c.domNode.appendChild(hsp);
+
console.log("restore selected ids: " + ids);
for (var i = 0; i < ids.length; i++) {
initHeadlinesMenu();
+ $$("#headlines-frame > div[id*=RROW]").each(
+ function(child) {
+ if (!Element.visible(child))
+ new Effect.Appear(child, { duration : 0.5 });
+ });
+
} else {
console.log("no new headlines received");
+
+ var hsp = $("headlines-spacer");
+
+ if (hsp) hsp.innerHTML = "";
}
}
__('Could not update headlines (invalid object received)') + "</div>");
}
- _feed_cur_page = feed_cur_page;
+ //_feed_cur_page = feed_cur_page;
_infscroll_request_sent = 0;
notify("");
last_requested_article = id;
+ console.log(query);
+
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
var id = tags_str.id;
var tags = $("ATSTR-" + id);
+ var tooltip = dijit.byId("ATSTRTIP-" + id);
- if (tags) {
- tags.innerHTML = tags_str.content;
- }
+ if (tags) tags.innerHTML = tags_str.content;
+ if (tooltip) tooltip.attr('label', tags_str.content_full);
cache_invalidate(id);
}
var id = articles[i]['id'];
if (!cache_check(id)) {
cache_inject(id, articles[i]['content']);
- console.log("preloaded article: " + id);
+ //console.log("preloaded article: " + id);
}
}
} });
if (post_under_pointer == id && !cache_check(id)) {
- console.log("trying to preload article " + id);
+ //console.log("trying to preload article " + id);
var neighbor_ids = getRelativePostIds(id, 1);
function headlines_scroll_handler(e) {
try {
+ var hsp = $("headlines-spacer");
+
+ if (!_infscroll_disable) {
+ if (hsp && (e.scrollTop + e.offsetHeight > hsp.offsetTop) ||
+ e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
+
+ hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
+ __("Loading, please wait...");
+
+ loadMoreHeadlines();
- if (e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
- if (!_infscroll_disable) {
- viewNextFeedPage();
+ //viewNextFeedPage();
}
+ } else {
+ if (hsp) hsp.innerHTML = "";
}
-
if (getInitParam("cdm_auto_catchup") == 1) {
- var ids = [];
-
$$("#headlines-frame > div[id*=RROW][class*=Unread]").each(
function(child) {
if ($("headlines-frame").scrollTop >
- (child.offsetTop + child.offsetHeight)) {
+ (child.offsetTop + child.offsetHeight/2)) {
- ids.push(child.id.replace("RROW-", ""));
+ var id = child.id.replace("RROW-", "");
+
+ if (catchup_id_batch.indexOf(id) == -1)
+ catchup_id_batch.push(id);
}
});
- if (ids.length > 0) {
+ if (catchup_id_batch.length > 0 && !_infscroll_request_sent) {
+ window.clearTimeout(catchup_timeout_id);
+ catchup_timeout_id = window.setTimeout('catchupBatchedArticles()',
+ 1000);
+ }
+ }
- var query = "?op=rpc&subop=catchupSelected" +
- "&cmode=0&ids=" + param_escape(ids.toString());
+ } catch (e) {
+ exception_error("headlines_scroll_handler", e);
+ }
+}
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- handle_rpc_json(transport);
+function catchupBatchedArticles() {
+ try {
+ if (catchup_id_batch.length > 0 && !_infscroll_request_sent) {
- ids.each(function(id) {
- var elem = $("RROW-" + id);
- if (elem) elem.removeClassName("Unread");
- });
- } });
- }
+ var query = "?op=rpc&subop=catchupSelected" +
+ "&cmode=0&ids=" + param_escape(catchup_id_batch.toString());
+
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ handle_rpc_json(transport);
+
+ catchup_id_batch.each(function(id) {
+ var elem = $("RROW-" + id);
+ if (elem) elem.removeClassName("Unread");
+ });
+
+ catchup_id_batch = [];
+ } });
}
+
} catch (e) {
- exception_error("headlines_scroll_handler", e);
+ exception_error("catchupBatchedArticles", e);
}
}
if (!event || !event.shiftKey)
return dijit.byId("content-tabs").selectChild(dijit.byId("ATAB-" + id));
+ if (dijit.byId("ATSTRTIP-" + id))
+ dijit.byId("ATSTRTIP-" + id).destroyRecursive();
+
if (cached_article) {
//closeArticlePanel();