better getRelativeFeedId algorithm

This commit is contained in:
Andrew Dolgov 2006-05-17 13:09:22 +01:00
parent 12c6fa1868
commit 1da76274eb
1 changed files with 58 additions and 60 deletions

View File

@ -720,18 +720,17 @@ function openExternalUrl(url) {
var w = window.open(url); var w = window.open(url);
} }
function getRelativeFeedId(list, id, direction, unread_only) {
function getRelativeFeedId(list, id, direction) {
if (!id) { if (!id) {
if (direction == "next") { if (direction == "next") {
for (i = 0; i < list.childNodes.length; i++) { for (i = 0; i < list.childNodes.length; i++) {
var child = list.childNodes[i]; var child = list.childNodes[i];
if (child.id == "feedCatHolder") { if (child.id && child.id == "feedCatHolder") {
if (child.lastChild) { if (child.lastChild) {
var cr = getRelativeFeedId(child.firstChild, id, direction); var cr = getRelativeFeedId(child.firstChild, id, direction);
if (cr) return cr; if (cr) return cr;
} }
} else if (child.id.match("FEEDR-")) { } else if (child.id && child.id.match("FEEDR-")) {
return child.id.replace('FEEDR-', ''); return child.id.replace('FEEDR-', '');
} }
} }
@ -764,79 +763,78 @@ function getRelativeFeedId(list, id, direction) {
var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId()); var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId());
if (getCookie("ttrss_vf_hreadf") == 1) {
unread_only = true;
}
if (direction == "next") { if (direction == "next") {
if (feed.nextSibling) { var e = feed;
var next_feed = feed.nextSibling; while (e) {
while (!next_feed.id && next_feed.nextSibling) { if (e.nextSibling) {
next_feed = next_feed.nextSibling;
}
if (getCookie("ttrss_vf_hreadf") == 1) { e = e.nextSibling;
while (next_feed && next_feed.className == "feed") {
next_feed = next_feed.nextSibling;
}
}
if (next_feed && next_feed.id.match("FEEDR-")) { } else if (e.parentNode.parentNode.nextSibling) {
return next_feed.id.replace("FEEDR-", "");
}
}
var this_cat = feed.parentNode.parentNode; var this_cat = e.parentNode.parentNode;
e = false;
if (this_cat && this_cat.nextSibling) { if (this_cat && this_cat.nextSibling) {
while (this_cat = this_cat.nextSibling) { while (!e && this_cat.nextSibling) {
if (this_cat.firstChild && this_cat.firstChild.firstChild) { this_cat = this_cat.nextSibling;
var next_feed = this_cat.firstChild.firstChild; if (this_cat.id == "feedCatHolder") {
if (getCookie("ttrss_vf_hreadf") == 1) { e = this_cat.firstChild.firstChild;
while (next_feed && next_feed.className == "feed") {
next_feed = next_feed.nextSibling;
}
}
if (next_feed && next_feed.id.match("FEEDR-")) {
return next_feed.id.replace("FEEDR-", "");
} }
} }
} }
} else {
e = false;
} }
if (e) {
if (!unread_only || (unread_only && e.className != "feed")) {
return e.id.replace("FEEDR-", "");
}
}
}
} else if (direction == "prev") { } else if (direction == "prev") {
if (feed.previousSibling) { var e = feed;
var prev_feed = feed.previousSibling; while (e) {
if (getCookie("ttrss_vf_hreadf") == 1) { if (e.previousSibling) {
while (prev_feed && prev_feed.className == "feed") {
prev_feed = prev_feed.previousSibling;
}
}
while (!prev_feed.id && prev_feed.previousSibling) { e = e.previousSibling;
prev_feed = prev_feed.previousSibling;
}
if (prev_feed && prev_feed.id.match("FEEDR-")) { } else if (e.parentNode.parentNode.previousSibling) {
return prev_feed.id.replace("FEEDR-", "");
}
}
var this_cat = feed.parentNode.parentNode; var this_cat = e.parentNode.parentNode;
e = false;
if (this_cat && this_cat.previousSibling) { if (this_cat && this_cat.previousSibling) {
while (this_cat = this_cat.previousSibling) { while (!e && this_cat.previousSibling) {
if (this_cat.lastChild && this_cat.firstChild.lastChild) { this_cat = this_cat.previousSibling;
var prev_feed = this_cat.firstChild.lastChild; if (this_cat.id == "feedCatHolder") {
if (getCookie("ttrss_vf_hreadf") == 1) { e = this_cat.firstChild.lastChild;
while (prev_feed && prev_feed.className == "feed") {
prev_feed = prev_feed.previousSibling;
} }
} }
if (prev_feed && prev_feed.id.match("FEEDR-")) {
return prev_feed.id.replace("FEEDR-", "");
} }
} else {
e = false;
}
if (e) {
if (!unread_only || (unread_only && e.className != "feed")) {
return e.id.replace("FEEDR-", "");
} }
} }
} }