better getRelativeFeedId algorithm
This commit is contained in:
parent
12c6fa1868
commit
1da76274eb
110
functions.js
110
functions.js
|
@ -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;
|
||||||
|
|
||||||
if (this_cat && this_cat.nextSibling) {
|
e = false;
|
||||||
while (this_cat = this_cat.nextSibling) {
|
|
||||||
if (this_cat.firstChild && this_cat.firstChild.firstChild) {
|
if (this_cat && this_cat.nextSibling) {
|
||||||
var next_feed = this_cat.firstChild.firstChild;
|
while (!e && this_cat.nextSibling) {
|
||||||
if (getCookie("ttrss_vf_hreadf") == 1) {
|
this_cat = this_cat.nextSibling;
|
||||||
while (next_feed && next_feed.className == "feed") {
|
if (this_cat.id == "feedCatHolder") {
|
||||||
next_feed = next_feed.nextSibling;
|
e = this_cat.firstChild.firstChild;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
e = e.previousSibling;
|
||||||
|
|
||||||
|
} else if (e.parentNode.parentNode.previousSibling) {
|
||||||
|
|
||||||
|
var this_cat = e.parentNode.parentNode;
|
||||||
|
|
||||||
|
e = false;
|
||||||
|
|
||||||
|
if (this_cat && this_cat.previousSibling) {
|
||||||
|
while (!e && this_cat.previousSibling) {
|
||||||
|
this_cat = this_cat.previousSibling;
|
||||||
|
if (this_cat.id == "feedCatHolder") {
|
||||||
|
e = this_cat.firstChild.lastChild;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!prev_feed.id && prev_feed.previousSibling) {
|
} else {
|
||||||
prev_feed = prev_feed.previousSibling;
|
e = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prev_feed && prev_feed.id.match("FEEDR-")) {
|
if (e) {
|
||||||
return prev_feed.id.replace("FEEDR-", "");
|
if (!unread_only || (unread_only && e.className != "feed")) {
|
||||||
}
|
return e.id.replace("FEEDR-", "");
|
||||||
}
|
|
||||||
|
|
||||||
var this_cat = feed.parentNode.parentNode;
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (prev_feed && prev_feed.id.match("FEEDR-")) {
|
|
||||||
return prev_feed.id.replace("FEEDR-", "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue