From a24f525cce32a6515532ac9392a5b02838ff82be Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 9 Dec 2005 20:48:13 +0100 Subject: [PATCH] quick action to add filter, misc backend improvements --- backend.php | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++ functions.js | 1 + tt-rss.js | 52 +++++++++++++++++++++++++++++++++++--- tt-rss.php | 7 ++++-- 4 files changed, 126 insertions(+), 5 deletions(-) diff --git a/backend.php b/backend.php index b1c57c3a..a31afb61 100644 --- a/backend.php +++ b/backend.php @@ -1268,6 +1268,7 @@ if ($op == "pref-feeds") { $subop = $_GET["subop"]; + $quiet = $_GET["quiet"]; if ($subop == "editSave") { $feed_title = db_escape_string($_GET["t"]); @@ -1442,6 +1443,8 @@ } + if ($quiet) return; + // print "

Edit Feeds

"; $result = db_query($link, "SELECT id,title,feed_url,last_error @@ -1896,6 +1899,7 @@ if ($op == "pref-filters") { $subop = $_GET["subop"]; + $quiet = $_GET["quiet"]; if ($subop == "editSave") { @@ -1960,6 +1964,8 @@ } } + if ($quiet) return; + $result = db_query($link, "SELECT description FROM ttrss_filter_types ORDER BY description"); @@ -2529,6 +2535,71 @@ } + if ($id == "quickAddFilter") { + + $result = db_query($link, "SELECT description + FROM ttrss_filter_types ORDER BY description"); + + $filter_types = array(); + + while ($line = db_fetch_assoc($result)) { + array_push($filter_types, $line["description"]); + } + + print ""; + + print ""; + print ""; + + print ""; + + print "
Match: "; + + print_select("fadd_match", "Title", $filter_types); + + print "
Feed:
Action:"; + + print "
"; + + print " "; + + print ""; + + print "
"; + } } // update feeds of all users, may be used anonymously diff --git a/functions.js b/functions.js index 17cab9d7..d901cbb9 100644 --- a/functions.js +++ b/functions.js @@ -689,3 +689,4 @@ function showBlockElement(id) { } } + diff --git a/tt-rss.js b/tt-rss.js index bb0f13c7..c8e1c3e3 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -46,12 +46,20 @@ function toggleTags() { function dlg_frefresh_callback() { if (xmlhttp.readyState == 4) { + notify(xmlhttp.responseText); updateFeedList(false, false); closeDlg(); } } -function dialog_refresh_callback() { +function dlg_submit_callback() { + if (xmlhttp.readyState == 4) { + notify(xmlhttp.responseText); + closeDlg(); + } +} + +function dlg_display_callback() { if (xmlhttp.readyState == 4) { var dlg = document.getElementById("userDlg"); var dlg_s = document.getElementById("userDlgShadow"); @@ -450,6 +458,10 @@ function quickMenuGo() { return; } + if (opid == "qmcAddFilter") { + displayDlg("quickAddFilter", getActiveFeedId()); + } + } function qafAdd() { @@ -470,7 +482,7 @@ function qafAdd() { feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + + xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" + param_escape(link.value), true); xmlhttp.onreadystatechange=dlg_frefresh_callback; xmlhttp.send(null); @@ -480,13 +492,47 @@ function qafAdd() { } } +function qaddFilter() { + + if (!xmlhttp_ready(xmlhttp)) { + printLockingError(); + return + } + + var regexp = document.getElementById("fadd_regexp"); + var match = document.getElementById("fadd_match"); + var feed = document.getElementById("fadd_feed"); + var action = document.getElementById("fadd_action"); + + if (regexp.value.length == 0) { + notify("Missing filter expression."); + } else { + notify("Adding filter..."); + + var v_match = match[match.selectedIndex].text; + var feed_id = feed[feed.selectedIndex].id; + var action_id = action[action.selectedIndex].id; + + xmlhttp.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add®exp=" + + param_escape(regexp.value) + "&match=" + v_match + + "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true); + + xmlhttp.onreadystatechange=dlg_submit_callback; + xmlhttp.send(null); + + regexp.value = ""; + } + +} + + function displayDlg(id, param) { notify(""); xmlhttp.open("GET", "backend.php?op=dlg&id=" + param_escape(id) + "¶m=" + param_escape(param), true); - xmlhttp.onreadystatechange=dialog_refresh_callback; + xmlhttp.onreadystatechange=dlg_display_callback; xmlhttp.send(null); } diff --git a/tt-rss.php b/tt-rss.php index 89feb857..5c15a507 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -194,14 +194,17 @@ - - + + + + + -- 2.39.2