From 7b5c6012d12c35f900dc8f20fdc103cc14959f3a Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Thu, 18 May 2006 03:48:33 +0100 Subject: [PATCH] unify create filter interface --- backend.php | 20 ++++++++++--- functions.js | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tt-rss.js | 74 ------------------------------------------------ tt-rss.php | 4 +-- 4 files changed, 98 insertions(+), 80 deletions(-) diff --git a/backend.php b/backend.php index 3a62fe684..c9d86ee0b 100644 --- a/backend.php +++ b/backend.php @@ -2233,6 +2233,8 @@ if ($quiet) return; + print "
PLACEHOLDER
"; + $result = db_query($link, "SELECT description FROM ttrss_filter_types ORDER BY description"); @@ -2242,7 +2244,7 @@ array_push($filter_types, $line["description"]); } - print "
+/* print "
 "; print_select("fadd_match", "Title", $filter_types); @@ -2282,11 +2284,16 @@ class=\"button\" onclick=\"javascript:testFilter()\" value=\"Test filter\"> "; */ - print ""; + value=\"Create filter\">"; */ - print "
"; + print ""; + +// print "
"; $result = db_query($link, "SELECT ttrss_filters.id AS id,reg_exp, @@ -2743,6 +2750,8 @@ $id = $_GET["id"]; $param = $_GET["param"]; + print "
"; + if ($id == "quickAddFeed") { print " Feed URL: "; } + + print "
"; + } // update feeds of all users, may be used anonymously diff --git a/functions.js b/functions.js index 7e7b395fd..5d010c6e3 100644 --- a/functions.js +++ b/functions.js @@ -917,3 +917,83 @@ function center_element(e) { exception_error("center_element", e); } } + +function displayDlg(id, param) { + + if (!xmlhttp_ready(xmlhttp)) { + printLockingError(); + return + } + + notify(""); + + xmlhttp.open("GET", "backend.php?op=dlg&id=" + + param_escape(id) + "¶m=" + param_escape(param), true); + xmlhttp.onreadystatechange=dlg_display_callback; + xmlhttp.send(null); + + disableHotkeys(); +} + +function closeDlg() { + var dlg = document.getElementById("infoBoxShadow"); + dlg.style.display = "none"; + enableHotkeys(); +} + +function dlg_submit_callback() { + if (xmlhttp.readyState == 4) { + notify(xmlhttp.responseText); + closeDlg(); + + // called from prefs, reload tab + if (active_tab) { + selectTab(active_tab, false); + } + } +} + +function dlg_display_callback() { + if (xmlhttp.readyState == 4) { + var dlg = document.getElementById("infoBox"); + var dlg_s = document.getElementById("infoBoxShadow"); + + dlg.innerHTML = xmlhttp.responseText; + dlg_s.style.display = "block"; + } +} + +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 = ""; + } + +} + + diff --git a/tt-rss.js b/tt-rss.js index 81c1c40fe..31ad8a962 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -58,23 +58,6 @@ function dlg_frefresh_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"); - - dlg.innerHTML = xmlhttp.responseText; - dlg_s.style.display = "block"; - } -} - function hide_unread_callback() { if (xmlhttp.readyState == 4) { @@ -578,63 +561,6 @@ 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) { - - if (!xmlhttp_ready(xmlhttp)) { - printLockingError(); - return - } - - notify(""); - - xmlhttp.open("GET", "backend.php?op=dlg&id=" + - param_escape(id) + "¶m=" + param_escape(param), true); - xmlhttp.onreadystatechange=dlg_display_callback; - xmlhttp.send(null); - - disableHotkeys(); -} - -function closeDlg() { - var dlg = document.getElementById("userDlgShadow"); - dlg.style.display = "none"; - enableHotkeys(); -} - function qfdDelete(feed_id) { notify("Removing feed..."); diff --git a/tt-rss.php b/tt-rss.php index 4828e2a4d..ef8f6c45a 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -96,7 +96,7 @@ window.onload = init;
 
-
 
+
 
@@ -240,7 +240,7 @@ window.onload = init; - +