digest: do not show catchup/loadmore prompt when there's nothing to load

master
Andrew Dolgov 14 years ago
parent b8a1b2ae94
commit 58226f869c

@ -47,9 +47,8 @@ function catchup_feed(feed_id, callback) {
} }
} }
function catchup_visible_articles(callback) { function get_visible_article_ids() {
try { try {
var elems = $("headlines-content").getElementsByTagName("LI"); var elems = $("headlines-content").getElementsByTagName("LI");
var ids = []; var ids = [];
@ -59,6 +58,18 @@ function catchup_visible_articles(callback) {
} }
} }
return ids;
} catch (e) {
exception_error("get_visible_article_ids", e);
}
}
function catchup_visible_articles(callback) {
try {
var ids = get_visible_article_ids();
if (confirm(__("Mark %d displayed articles as read?").replace("%d", ids.length))) { if (confirm(__("Mark %d displayed articles as read?").replace("%d", ids.length))) {
var query = "?op=rpc&subop=catchupSelected" + var query = "?op=rpc&subop=catchupSelected" +
@ -565,19 +576,25 @@ function parse_headlines(transport, replace, no_effects) {
} }
} }
if (pr) { var ids = get_visible_article_ids();
$('headlines-content').appendChild(pr);
if (!no_effects) new Effect.ScrollTo(inserted); if (ids.length > 0) {
} else { if (pr) {
$('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" + $('headlines-content').appendChild(pr);
"<div class='body'>" + if (!no_effects) new Effect.ScrollTo(inserted);
"<a href=\"javascript:catchup_visible_articles()\">" + } else {
__("Mark as read") + "</a> | " + $('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" +
"<a href=\"javascript:load_more()\">" + "<div class='body'>" +
__("Load more...") + "</a>" + "<a href=\"javascript:catchup_visible_articles()\">" +
"<img style=\"display : none\" "+ __("Mark as read") + "</a> | " +
"<a href=\"javascript:load_more()\">" +
__("Load more...") + "</a>" +
"<img style=\"display : none\" "+
"id=\"H-LOADING-IMG\" src='images/indicator_tiny.gif'>" + "id=\"H-LOADING-IMG\" src='images/indicator_tiny.gif'>" +
"</div></li>"; "</div></li>";
}
} else {
// FIXME : display some kind of "nothing to see here" prompt here
} }
if (replace && !no_effects) if (replace && !no_effects)

Loading…
Cancel
Save