From 8be83f424aafbcb652ae26354e3725f8f10b55d7 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Wed, 22 Aug 2007 05:45:01 +0100 Subject: implement catchup above/below (refs #140) --- functions.php | 6 ++- localized_js.php | 6 +-- tt-rss.css | 6 +-- viewfeed.js | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+), 7 deletions(-) diff --git a/functions.php b/functions.php index fd8f4da00..d9ae31ab7 100644 --- a/functions.php +++ b/functions.php @@ -3184,7 +3184,11 @@
  •  
  • ".__('Mark as read')."
  • "; diff --git a/localized_js.php b/localized_js.php index d2ab94670..77b9ea2f5 100644 --- a/localized_js.php +++ b/localized_js.php @@ -116,9 +116,9 @@ print T_js_decl("Save current configuration?"); print T_js_decl("Old password cannot be blank."); print T_js_decl("New password cannot be blank."); print T_js_decl("Entered passwords do not match."); -#print T_js_decl( -#print T_js_decl( -#print T_js_decl( +print T_js_decl("No articles found to mark"); +print T_js_decl("Mark %d article(s) as read?"); +print T_js_decl("No article is selected."); #print T_js_decl( #print T_js_decl( #print T_js_decl( diff --git a/tt-rss.css b/tt-rss.css index 7efc0142f..ba1d4070e 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -668,7 +668,7 @@ span.feed_error { color : red; } -span.insensitive, div.insensitive { +span.insensitive, div.insensitive, li.insensitive { color : gray; } @@ -1552,7 +1552,7 @@ ul.headlineDropdownMenu { ul.headlineDropdownMenu li.top { float : left; - width : 11em; + width : 12em; background-image : url("images/down_arrow.png"); background-position : center right; background-repeat : no-repeat; @@ -1604,7 +1604,7 @@ ul.headlineDropdownMenu ul { padding : 0px; display : none; background-color : white; - width : 11em; + width : 12em; z-index : 3; top : auto; left : auto; diff --git a/viewfeed.js b/viewfeed.js index b1fbdd800..c7a85fdb6 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -871,6 +871,39 @@ function cdmGetSelectedArticles() { return sel_articles; } +function cdmGetVisibleArticles() { + var sel_articles = new Array(); + var container = document.getElementById("headlinesInnerContainer"); + + for (i = 0; i < container.childNodes.length; i++) { + var child = container.childNodes[i]; + + if (child.id.match("RROW-")) { + var c_id = child.id.replace("RROW-", ""); + sel_articles.push(c_id); + } + } + + return sel_articles; +} + +function cdmGetUnreadArticles() { + var sel_articles = new Array(); + var container = document.getElementById("headlinesInnerContainer"); + + for (i = 0; i < container.childNodes.length; i++) { + var child = container.childNodes[i]; + + if (child.id.match("RROW-") && child.className.match("Unread")) { + var c_id = child.id.replace("RROW-", ""); + sel_articles.push(c_id); + } + } + + return sel_articles; +} + + // mode = all,none,unread function cdmSelectArticles(mode) { var container = document.getElementById("headlinesInnerContainer"); @@ -1253,3 +1286,79 @@ function headlines_scroll_handler() { exception_error("headlines_scroll_handler", e); } } + +function catchupRelativeToArticle(below) { + + try { + + if (!xmlhttp_ready(xmlhttp_rpc)) { + printLockingError(); + } + + if (!getActiveArticleId()) { + alert(__("No article is selected.")); + return; + } + + var visible_ids; + + if (document.getElementById("headlinesList")) { + visible_ids = getVisibleHeadlineIds(); + } else { + visible_ids = cdmGetVisibleArticles(); + } + + var ids_to_mark = new Array(); + + if (!below) { + for (var i = 0; i < visible_ids.length; i++) { + if (visible_ids[i] != getActiveArticleId()) { + var e = document.getElementById("RROW-" + visible_ids[i]); + + if (e && e.className.match("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] != getActiveArticleId()) { + var e = document.getElementById("RROW-" + visible_ids[i]); + + if (e && e.className.match("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 = __("Mark %d article(s) as read?").replace("%d", ids_to_mark.length); + + if (confirm(msg)) { + + for (var i = 0; i < ids_to_mark.length; i++) { + var e = document.getElementById("RROW-" + ids_to_mark[i]); + e.className = e.className.replace("Unread", ""); + } + + var query = "backend.php?op=rpc&subop=catchupSelected&ids=" + + param_escape(ids_to_mark.toString()) + "&cmode=0"; + + xmlhttp_rpc.open("GET", query, true); + xmlhttp_rpc.onreadystatechange=catchup_callback; + xmlhttp_rpc.send(null); + + } + } + + } catch (e) { + exception_error("catchupRelativeToArticle", e); + } +} -- cgit v1.2.3