From 0e091d38cf6419edf5e623a584dc28a404fc2613 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 22 Aug 2005 06:38:07 +0100 Subject: [PATCH] prefs RPC optimizations --- backend.php | 23 +++++++++++++++++------ prefs.js | 19 +++++++++++++------ prefs.php | 2 ++ 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/backend.php b/backend.php index 4a1d52ce..d6e45098 100644 --- a/backend.php +++ b/backend.php @@ -207,19 +207,17 @@ } - if ($op == "pref-feeds") { - - $subop = $_GET["subop"]; + if ($op == "pref-rpc") { - if ($subop == "edit") { - print "

[Edit feed placeholder]

"; - } + $subop = $_GET["subop"]; if ($subop == "unread") { $ids = split(",", $_GET["ids"]); foreach ($ids as $id) { pg_query("UPDATE ttrss_entries SET unread = true WHERE feed_id = '$id'"); } + + print "Marked selected feeds as read."; } if ($subop == "read") { @@ -227,6 +225,19 @@ foreach ($ids as $id) { pg_query("UPDATE ttrss_entries SET unread = false WHERE feed_id = '$id'"); } + + print "Marked selected feeds as unread."; + + } + + } + + if ($op == "pref-feeds") { + + $subop = $_GET["subop"]; + + if ($subop == "edit") { + print "

[Edit feed placeholder]

"; } if ($subop == "remove") { diff --git a/prefs.js b/prefs.js index 001d5b0a..192e194f 100644 --- a/prefs.js +++ b/prefs.js @@ -32,7 +32,14 @@ function feedlist_callback() { } } -function update_feeds() { +function notify_callback() { + var container = document.getElementById('notify'); + if (xmlhttp.readyState == 4) { + container.innerHTML=xmlhttp.responseText; + } +} + +function updateFeedList() { document.getElementById("feeds").innerHTML = "Loading feeds, please wait..."; @@ -111,9 +118,9 @@ function readSelectedFeeds() { notify("Marking selected feeds as read..."); - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=unread&ids="+ + xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ param_escape(sel_rows.toString()), true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.onreadystatechange=notify_callback; xmlhttp.send(null); } else { @@ -131,9 +138,9 @@ function unreadSelectedFeeds() { notify("Marking selected feeds as unread..."); - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=unread&ids="+ + xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+ param_escape(sel_rows.toString()), true); - xmlhttp.onreadystatechange=feedlist_callback; + xmlhttp.onreadystatechange=notify_callback; xmlhttp.send(null); } else { @@ -166,7 +173,7 @@ function removeSelectedFeeds() { function init() { - update_feeds(); + updateFeedList(); notify(""); diff --git a/prefs.php b/prefs.php index 79ffcf11..1d3755a6 100644 --- a/prefs.php +++ b/prefs.php @@ -42,6 +42,8 @@ href="javascript:readSelectedFeeds()">Mark as read  Mark as unread  + Refresh 
-- 2.39.5