summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend.php25
-rw-r--r--functions.js18
-rw-r--r--tt-rss.js107
3 files changed, 142 insertions, 8 deletions
diff --git a/backend.php b/backend.php
index 0105253dc..bc8524742 100644
--- a/backend.php
+++ b/backend.php
@@ -109,6 +109,31 @@
$subop = $_GET["subop"];
+ if ($subop == "getRelativeId") {
+ $mode = $_GET["mode"];
+ $id = $_GET["id"];
+ $feed_id = $_GET["feed"];
+
+ if ($id != 'false' && $feed_id != 'false') {
+
+ if ($mode == 'next') {
+ $check_qpart = "updated >= ";
+ } else {
+ $idcheck_qpart = "id < '$id'";
+ }
+
+ $result = pg_query("SELECT id FROM ttrss_entries WHERE
+ $check_qpart AND
+ feed_id = '$feed_id'
+ ORDER BY updated DESC LIMIT 1");
+
+ $result_id = pg_fetch_result($result, 0, "id");
+
+ print "M $mode : P $id -> P $result_id : F $feed_id";
+
+ }
+ }
+
if ($subop == "forceUpdateAllFeeds") {
update_all_feeds($link, true);
outputFeedList($link);
diff --git a/functions.js b/functions.js
index 8cd5b47ca..0b05ae2e8 100644
--- a/functions.js
+++ b/functions.js
@@ -1,3 +1,17 @@
+function notify_callback() {
+ var container = document.getElementById('notify');
+ if (xmlhttp.readyState == 4) {
+ container.innerHTML=xmlhttp.responseText;
+ }
+}
+
+function rpc_notify_callback() {
+ var container = document.getElementById('notify');
+ if (xmlhttp_rpc.readyState == 4) {
+ container.innerHTML=xmlhttp_rpc.responseText;
+ }
+}
+
function param_escape(arg) {
if (typeof encodeURIComponent != 'undefined')
return encodeURIComponent(arg);
@@ -64,6 +78,10 @@ function hotkey_handler(e) {
localPiggieFunction(false);
}
+ if (typeof localHotkeyHandler != 'undefined') {
+ localHotkeyHandler(keycode);
+ }
+
}
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);