dijit.byId("headlines-toolbar").attr('content',
reply['headlines']['toolbar']);
+ $$("#headlines-frame > div[id*=RROW]").each(function(row) {
+ if ($$("#headlines-frame DIV[id="+row.id+"]").length > 1) {
+ row.parentNode.removeChild(row);
+ }
+ });
if (getInitParam("cdm_auto_catchup") == 1) {
var hsp = $("headlines-spacer");
} else {
if (headlines_count > 0 && feed_id == getActiveFeedId() && is_cat == activeFeedIsCat()) {
- console.log("adding some more headlines...");
+ console.log("adding some more headlines: " + headlines_count);
var c = dijit.byId("headlines-frame");
var ids = getSelectedArticleIds2();
+ var num_added = 0;
$("headlines-tmp").innerHTML = reply['headlines']['content'];
if ($$("#headlines-frame DIV[id="+row.id+"]").length == 0) {
row.style.display = 'none';
c.domNode.appendChild(row);
+ ++num_added;
} else {
row.parentNode.removeChild(row);
}
c.domNode.appendChild(hsp);
}
+ console.log("added " + num_added + " headlines");
+
+ if (num_added == 0)
+ _infscroll_disable = true;
+
console.log("restore selected ids: " + ids);
for (var i = 0; i < ids.length; i++) {
request_counters();
- try {
+ headlines_scroll_handler($("headlines-frame"));
+
+/* try {
if (!_infscroll_disable &&
$$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
}
} catch (e) {
console.warn(e);
- }
+ } */
notify("");
} catch (e) {
// the server roundtrip altogether
if (cids_to_request.length == 0) {
- try {
+/* try {
if (!_infscroll_disable &&
$$("#headlines-frame > div[id*=RROW]").last().hasClassName("Selected")) {
}
} catch (e) {
console.warn(e);
- }
+ } */
+
+ headlines_scroll_handler($("headlines-frame"));
return;
}
}
-// mode = all,none,unread,invert
+// mode = all,none,unread,invert,marked,published
function selectArticles(mode) {
try {
child.removeClassName("Selected");
cb.checked = false;
}
+ } else if (mode == "marked") {
+ var img = $("FMPIC-" + child.id.replace("RROW-", ""));
+
+ if (img && img.src.match("mark_set")) {
+ child.addClassName("Selected");
+ cb.checked = true;
+ } else {
+ child.removeClassName("Selected");
+ cb.checked = false;
+ }
+ } else if (mode == "published") {
+ var img = $("FPPIC-" + child.id.replace("RROW-", ""));
+
+ if (img && img.src.match("pub_set")) {
+ child.addClassName("Selected");
+ cb.checked = true;
+ } else {
+ child.removeClassName("Selected");
+ cb.checked = false;
+ }
+
} else if (mode == "invert") {
if (child.hasClassName("Selected")) {
child.removeClassName("Selected");
var hsp = $("headlines-spacer");
if (!_infscroll_disable) {
- if (hsp && (e.scrollTop + e.offsetHeight > hsp.offsetTop) ||
- e.scrollTop + e.offsetHeight > e.scrollHeight - 100) {
+ if ((hsp && e.scrollTop + e.offsetHeight >= hsp.offsetTop - hsp.offsetHeight) ||
+ (e.scrollHeight != 0 &&
+ ((e.scrollTop + e.offsetHeight) / e.scrollHeight >= 0.7))) {
if (hsp)
hsp.innerHTML = "<img src='images/indicator_tiny.gif'> " +
try {
if (catchup_id_batch.length > 0 && !_infscroll_request_sent) {
+ // make a copy of the array
+ var batch = catchup_id_batch.slice();
var query = "?op=rpc&method=catchupSelected" +
- "&cmode=0&ids=" + param_escape(catchup_id_batch.toString());
+ "&cmode=0&ids=" + param_escape(batch.toString());
+
+ console.log(query);
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
handle_rpc_json(transport);
- catchup_id_batch.each(function(id) {
+ batch.each(function(id) {
var elem = $("RROW-" + id);
if (elem) elem.removeClassName("Unread");
+ catchup_id_batch.remove(id);
});
- catchup_id_batch = [];
} });
}
var container = $("headlines-frame");
var row = $("RROW-" + id);
+ if (!container || !row) return;
+
var viewport = container.offsetHeight;
var rel_offset_top = row.offsetTop - container.scrollTop;
label: name,
labelId: bare_id,
onClick: function(event) {
- selectionAssignLabel(this.labelId,
- [this.getParent().ownerMenu.callerRowId]);
+ var ids = getSelectedArticleIds2();
+ // cast to string
+ var id = this.getParent().ownerMenu.callerRowId + "";
+
+ ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
+
+ selectionAssignLabel(this.labelId, ids);
}}));
labelDelMenu.addChild(new dijit.MenuItem({
label: name,
labelId: bare_id,
onClick: function(event) {
- selectionRemoveLabel(this.labelId,
- [this.getParent().ownerMenu.callerRowId]);
+ var ids = getSelectedArticleIds2();
+ // cast to string
+ var id = this.getParent().ownerMenu.callerRowId + "";
+
+ ids = ids.size() != 0 && ids.indexOf(id) != -1 ? ids : [id];
+
+ selectionRemoveLabel(this.labelId, ids);
}}));
});
function precache_headlines_idle() {
try {
if (!feed_precache_timeout_id) {
- var feeds = dijit.byId("feedTree").getVisibleUnreadFeeds();
- var uncached = [];
+ if (get_timestamp() - _viewfeed_last > 120) {
- feeds.each(function(item) {
- if (parseInt(item[0]) > 0 && !cache_get("feed:" + item[0] + ":" + item[1]))
- uncached.push(item);
- });
+ var feeds = dijit.byId("feedTree").getVisibleUnreadFeeds();
+ var uncached = [];
+
+ feeds.each(function(item) {
+ if (parseInt(item[0]) > 0 && !cache_get("feed:" + item[0] + ":" + item[1]))
+ uncached.push(item);
+ });
- if (uncached.length > 0) {
- var rf = uncached[Math.floor(Math.random()*uncached.length)];
- viewfeed(rf[0], '', rf[1], 0, true);
+ if (uncached.length > 0) {
+ var rf = uncached[Math.floor(Math.random()*uncached.length)];
+ viewfeed(rf[0], '', rf[1], 0, true);
+ }
}
}
precache_idle_timeout_id = setTimeout("precache_headlines_idle()", 1000*30);