summaryrefslogtreecommitdiff
path: root/tt-rss.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2005-08-25 12:20:50 +0100
committerAndrew Dolgov <[email protected]>2005-08-25 12:20:50 +0100
commit9cfc649af5e3a397f530475a16a2ae51965e948b (patch)
tree01bae7fb4b9ae3a80ff0c9de6be969175a9b4e82 /tt-rss.js
parente695fdc83ef295fd18e9757ff5b12f3d9a8d213c (diff)
keyboard navigation and cute active headline selection
Diffstat (limited to 'tt-rss.js')
-rw-r--r--tt-rss.js107
1 files changed, 99 insertions, 8 deletions
diff --git a/tt-rss.js b/tt-rss.js
index 455a202c9..5f34f311a 100644
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -9,6 +9,9 @@ var xmlhttp_rpc = false;
var total_unread = 0;
var first_run = true;
+var active_post_id = false;
+var active_feed_id = false;
+
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
@@ -32,13 +35,6 @@ if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
}
-function notify_callback() {
- var container = document.getElementById('notify');
- if (xmlhttp.readyState == 4) {
- container.innerHTML=xmlhttp.responseText;
- }
-}
-
function feedlist_callback() {
var container = document.getElementById('feeds');
if (xmlhttp.readyState == 4) {
@@ -228,6 +224,9 @@ function viewfeed(feed, skip, subop) {
printLockingError();
return
}
+
+ active_feed_id = feed;
+ active_post_id = false;
xmlhttp.open("GET", "backend.php?op=viewfeed&feed=" + param_escape(feed) +
"&skip=" + param_escape(skip) + "&subop=" + param_escape(subop) , true);
@@ -238,6 +237,17 @@ function viewfeed(feed, skip, subop) {
}
+function cleanSelectedHeadlines() {
+ var content = document.getElementById("headlinesList");
+
+ var rows = new Array();
+
+ for (i = 0; i < content.rows.length; i++) {
+ content.rows[i].className = content.rows[i].className.replace("Selected", "");
+ }
+
+}
+
function view(id,feed_id) {
if (xmlhttp.readyState != 4 && xmlhttp.readyState != 0) {
@@ -256,12 +266,16 @@ function view(id,feed_id) {
var feedr = document.getElementById("FEEDR-" + feed_id);
feedr.className = feedr.className.replace("Unread", "");
}
-
+
total_unread--;
update_title();
}
+ cleanSelectedHeadlines();
+
+ crow.className = crow.className + "Selected";
+
var upd_img_pic = document.getElementById("FUPDPIC-" + id);
if (upd_img_pic) {
@@ -270,6 +284,8 @@ function view(id,feed_id) {
document.getElementById('content').innerHTML='Loading, please wait...';
+ active_post_id = id;
+
xmlhttp.open("GET", "backend.php?op=view&id=" + param_escape(id), true);
xmlhttp.onreadystatechange=view_callback;
xmlhttp.send(null);
@@ -320,6 +336,81 @@ function localPiggieFunction(enable) {
}
}
+function relativeid_callback() {
+
+ if (xmlhttp_rpc.readyState == 4) {
+ notify(xmlhttp_rpc.responseText);
+ }
+
+}
+
+function getVisibleHeadlineIds() {
+
+ var content = document.getElementById("headlinesList");
+
+ var rows = new Array();
+
+ for (i = 0; i < content.rows.length; i++) {
+ var row_id = content.rows[i].id.replace("RROW-", "");
+ if (row_id.length > 0) {
+ rows.push(row_id);
+ }
+ }
+
+ return rows;
+
+}
+
+function moveToPost(mode) {
+
+/* var query_str = "backend.php?op=rpc&subop=getRelativeId&mode=" + mode +
+ "&feed=" + active_feed_id + "&id=" + active_post_id;
+
+// notify(query_str);
+
+ if (xmlhttp_rpc.readyState == 4 || xmlhttp_rpc.readyState == 0) {
+ xmlhttp_rpc.open("GET", query_str, true);
+ xmlhttp_rpc.onreadystatechange=relativeid_callback;
+ xmlhttp_rpc.send(null);
+ } else {
+ printLockingError();
+ } */
+
+ var rows = getVisibleHeadlineIds();
+
+ var prev_id;
+ var next_id;
+
+ for (var i = 0; i < rows.length; i++) {
+ if (rows[i] == active_post_id) {
+ prev_id = rows[i-1];
+ next_id = rows[i+1];
+ }
+ }
+
+ if (mode == "next" && next_id != undefined) {
+ view(next_id, active_feed_id);
+ }
+
+ if (mode == "prev" && prev_id != undefined) {
+ view(prev_id, active_feed_id);
+ }
+
+}
+
+function localHotkeyHandler(keycode) {
+
+// notify(keycode);
+
+ if (keycode == 78) {
+ moveToPost('next');
+ }
+
+ if (keycode == 80) {
+ moveToPost('prev');
+ }
+}
+
function init() {
updateFeedList(false, false);