summaryrefslogtreecommitdiff
path: root/digest.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2010-09-22 14:17:26 +0400
committerAndrew Dolgov <[email protected]>2010-09-22 14:17:26 +0400
commit58226f869cfc0f35bb22c4f5afc5c3d892dc3c54 (patch)
treedcfce69a84387264cb08093ab20b392a621743cd /digest.js
parentb8a1b2ae945d4295971c72aad53fcf5841eb76c7 (diff)
digest: do not show catchup/loadmore prompt when there's nothing to load
Diffstat (limited to 'digest.js')
-rw-r--r--digest.js45
1 files changed, 31 insertions, 14 deletions
diff --git a/digest.js b/digest.js
index 3fe85f68e..98ae14d8c 100644
--- a/digest.js
+++ b/digest.js
@@ -47,9 +47,8 @@ function catchup_feed(feed_id, callback) {
}
}
-function catchup_visible_articles(callback) {
+function get_visible_article_ids() {
try {
-
var elems = $("headlines-content").getElementsByTagName("LI");
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))) {
var query = "?op=rpc&subop=catchupSelected" +
@@ -565,19 +576,25 @@ function parse_headlines(transport, replace, no_effects) {
}
}
- if (pr) {
- $('headlines-content').appendChild(pr);
- if (!no_effects) new Effect.ScrollTo(inserted);
- } else {
- $('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" +
- "<div class='body'>" +
- "<a href=\"javascript:catchup_visible_articles()\">" +
- __("Mark as read") + "</a> | " +
- "<a href=\"javascript:load_more()\">" +
- __("Load more...") + "</a>" +
- "<img style=\"display : none\" "+
+ var ids = get_visible_article_ids();
+
+ if (ids.length > 0) {
+ if (pr) {
+ $('headlines-content').appendChild(pr);
+ if (!no_effects) new Effect.ScrollTo(inserted);
+ } else {
+ $('headlines-content').innerHTML += "<li id='H-MORE-PROMPT'>" +
+ "<div class='body'>" +
+ "<a href=\"javascript:catchup_visible_articles()\">" +
+ __("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'>" +
- "</div></li>";
+ "</div></li>";
+ }
+ } else {
+ // FIXME : display some kind of "nothing to see here" prompt here
}
if (replace && !no_effects)