summaryrefslogtreecommitdiff
path: root/functions.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-11-28 07:28:33 +0100
committerAndrew Dolgov <[email protected]>2005-11-28 07:28:33 +0100
commit7b433d8c0262419b6e83bbae6bc8ddcc5ea20f36 (patch)
tree641298aef2450f534e7806151e67fa7c814c7c81 /functions.js
parentad3dee9113b47fe51165998bc307f2d47a852487 (diff)
j,k navigate between feeds
Diffstat (limited to 'functions.js')
-rw-r--r--functions.js129
1 files changed, 128 insertions, 1 deletions
diff --git a/functions.js b/functions.js
index 3aef7befa..c696ae3e8 100644
--- a/functions.js
+++ b/functions.js
@@ -130,7 +130,11 @@ function hotkey_handler(e) {
}
if (typeof localHotkeyHandler != 'undefined') {
- localHotkeyHandler(keycode);
+ try {
+ localHotkeyHandler(keycode);
+ } catch (e) {
+ exception_error(e);
+ }
}
}
@@ -545,3 +549,126 @@ function openExternalUrl(url) {
var w = window.open(url);
}
+
+function getRelativeFeedId(list, id, direction) {
+ if (!id) {
+ if (direction == "next") {
+ for (i = 0; i < list.childNodes.length; i++) {
+ var child = list.childNodes[i];
+ if (child.id == "feedCatHolder") {
+ if (child.firstChild) {
+ var cr = getRelativeFeedId(child.firstChild, id, direction);
+ if (cr) return cr;
+ }
+ } else if (child.id.match("FEEDR-")) {
+ return child.id.replace('FEEDR-', '');
+ }
+ }
+ }
+
+ // FIXME select last feed doesn't work when only unread feeds are visible
+
+ if (direction == "prev") {
+ for (i = list.childNodes.length-1; i >= 0; i--) {
+ var child = list.childNodes[i];
+ if (child.id == "feedCatHolder") {
+ if (child.firstChild) {
+ var cr = getRelativeFeedId(child.firstChild, id, direction);
+ if (cr) return cr;
+ }
+ } else if (child.id.match("FEEDR-")) {
+
+ if (getCookie("ttrss_vf_hreadf") == 1) {
+ if (child.className != "feed") {
+ alert(child.className);
+ return child.id.replace('FEEDR-', '');
+ }
+ } else {
+ return child.id.replace('FEEDR-', '');
+ }
+ }
+ }
+ }
+ } else {
+
+ var feed = list.ownerDocument.getElementById("FEEDR-" + getActiveFeedId());
+
+ if (direction == "next") {
+
+ if (feed.nextSibling) {
+
+ var next_feed = feed.nextSibling;
+
+ while (!next_feed.id && next_feed.nextSibling) {
+ next_feed = next_feed.nextSibling;
+ }
+
+ 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-", "");
+ }
+ }
+
+ var this_cat = feed.parentNode.parentNode;
+
+ 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-", "");
+ }
+ }
+ }
+ }
+ } else if (direction == "prev") {
+
+ if (feed.previousSibling) {
+
+ var prev_feed = feed.previousSibling;
+
+ if (getCookie("ttrss_vf_hreadf") == 1) {
+ while (prev_feed && prev_feed.className == "feed") {
+ prev_feed = prev_feed.previousSibling;
+ }
+ }
+
+ while (!prev_feed.id && prev_feed.previousSibling) {
+ prev_feed = prev_feed.previousSibling;
+ }
+
+ if (prev_feed && prev_feed.id.match("FEEDR-")) {
+ return prev_feed.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-", "");
+ }
+ }
+ }
+ }
+ }
+ }
+}