From 79f3553b8b82e9b62b82456bdcdf74a4abe162fe Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 May 2006 12:39:22 +0100 Subject: [PATCH] create filter dialog uses prototype --- backend.php | 34 +++++++++++++++++++++------------- functions.js | 30 +++++++----------------------- functions.php | 14 +++++++------- prefs.js | 2 +- tt-rss.css | 9 ++++++--- 5 files changed, 42 insertions(+), 47 deletions(-) diff --git a/backend.php b/backend.php index 8c4dbcfe3..24b738204 100644 --- a/backend.php +++ b/backend.php @@ -2146,10 +2146,10 @@ if (!WEB_DEMO_MODE) { - $regexp = db_escape_string(trim($_GET["regexp"])); - $match = db_escape_string(trim($_GET["match"])); - $feed_id = db_escape_string($_GET["fid"]); - $action_id = db_escape_string($_GET["aid"]); + $regexp = db_escape_string(trim($_GET["reg_exp"])); + $match_id = db_escape_string(trim($_GET["match_id"])); + $feed_id = db_escape_string($_GET["feed_id"]); + $action_id = db_escape_string($_GET["action_id"]); if (!$feed_id) { $feed_id = 'NULL'; @@ -2161,8 +2161,7 @@ "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, action_id) VALUES - ('$regexp', (SELECT id FROM ttrss_filter_types WHERE - description = '$match'),'".$_SESSION["uid"]."', + ('$regexp', '$match_id','".$_SESSION["uid"]."', $feed_id, '$action_id')"); } } @@ -2742,41 +2741,48 @@ print "
Create filter
"; print "
"; + print "
"; + + print ""; + print ""; + print ""; + // print "
Note: filter will only apply to new articles.
"; - $result = db_query($link, "SELECT description + $result = db_query($link, "SELECT id,description FROM ttrss_filter_types ORDER BY description"); $filter_types = array(); while ($line = db_fetch_assoc($result)) { - array_push($filter_types, $line["description"]); + //array_push($filter_types, $line["description"]); + $filter_types[$line["id"]] = $line["description"]; } print ""; print ""; print ""; print ""; - print "
Match:  "; + name=\"reg_exp\" size=\"30\"> "; - print_select("fadd_match", "Title", $filter_types); + print_select_hash("match_id", 1, $filter_types); print "
Feed:"; - print_feed_select($link, "fadd_feed"); + print_feed_select($link, "feed_id"); print "
Action:"; @@ -2794,6 +2800,8 @@ print "
"; + print "
"; + } print "
"; diff --git a/functions.js b/functions.js index ee26d0a92..627eb287a 100644 --- a/functions.js +++ b/functions.js @@ -992,13 +992,15 @@ function displayDlg(id, param) { function infobox_submit_callback() { if (xmlhttp.readyState == 4) { - notify(xmlhttp.responseText); closeInfoBox(); // called from prefs, reload tab if (active_tab) { selectTab(active_tab, false); } + + notify(xmlhttp.responseText); + } } @@ -1024,29 +1026,11 @@ function qaddFilter() { 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"); + var query = Form.serialize("filter_add_form"); - if (regexp.value.length == 0) { - alert("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=infobox_submit_callback; - xmlhttp.send(null); - - regexp.value = ""; - } + xmlhttp.open("GET", "backend.php?" + query, true); + xmlhttp.onreadystatechange=infobox_submit_callback; + xmlhttp.send(null); } diff --git a/functions.php b/functions.php index 0f05f8aec..d9df9ca3a 100644 --- a/functions.php +++ b/functions.php @@ -653,7 +653,7 @@ } function print_select($id, $default, $values, $attributes = "") { - print ""; foreach ($values as $v) { if ($v == $default) $sel = " selected"; @@ -665,8 +665,8 @@ print ""; } - function print_select_hash($id, $values, $default, $attributes = "") { - print ""; foreach (array_keys($values) as $v) { if ($v == $default) $sel = "selected"; @@ -1582,9 +1582,9 @@ function print_feed_select($link, $id, $default_id = "", $attributes = "", $include_all_feeds = true) { - print ""; if ($include_all_feeds) { - print ""; + print ""; } $result = db_query($link, "SELECT id,title FROM ttrss_feeds @@ -1600,7 +1600,7 @@ } else { $is_selected = ""; } - printf("", + printf("", $line["id"], db_unescape_string($line["title"])); } @@ -1610,7 +1610,7 @@ function print_feed_cat_select($link, $id, $default_id = "", $attributes = "", $include_all_cats = true) { - print ""; if ($include_all_cats) { print ""; diff --git a/prefs.js b/prefs.js index c9001e8a0..e8c36bc7c 100644 --- a/prefs.js +++ b/prefs.js @@ -1313,7 +1313,7 @@ function categorizeSelectedFeeds() { var sel_rows = getSelectedFeeds(); var cat_sel = document.getElementById("sfeed_set_fcat"); - var cat_id = cat_sel[cat_sel.selectedIndex].id; + var cat_id = cat_sel[cat_sel.selectedIndex].value; if (sel_rows.length > 0) { diff --git a/tt-rss.css b/tt-rss.css index 6c4a86367..56edc7e93 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -278,14 +278,14 @@ a:hover { opacity : 0.8; } -/* #iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl, #iedit_purgintl, #iedit_ulogin, #iedit_ulevel, #iedit_match, #iedit_feed, #iedit_fcat, #iedit_filter_action, #iedit_login, #iedit_pass, #iedit_email, #iedit_parent_feed { width : 100%; padding-left : 2px; -} */ + background-color : #f0fff0; +} input.iedit { width : 100%; @@ -1099,4 +1099,7 @@ div.noDaemonWarning { width : 100%; } - +form { + margin : 0px; + padding : 0px; +}