implement catchup above/below (refs #140)

master
Andrew Dolgov 18 years ago
parent 772e5b5ce6
commit 8be83f424a

@ -3184,7 +3184,11 @@
<li class=\"vsep\">&nbsp;</li>
<li class=\"top\"><a href=\"$catchup_page_link\">".__('Mark as read')."</a><ul>
<li onclick=\"$catchup_sel_link\">".__('Selection')."</li>
<li onclick=\"$catchup_page_link\">".__('This page')."</li>
<!-- <li onclick=\"$catchup_page_link\">".__('This page')."</li> -->
<li><span class=\"insensitive\">--------</span></li>
<li onclick=\"catchupRelativeToArticle(0)\">".__("Above active article")."</li>
<li onclick=\"catchupRelativeToArticle(1)\">".__("Below active article")."</li>
<li><span class=\"insensitive\">--------</span></li>
<li onclick=\"$catchup_feed_link\">".__('Entire feed')."</li></ul></li>
";

@ -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(

@ -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;

@ -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);
}
}

Loading…
Cancel
Save