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