]> git.wh0rd.org Git - tt-rss.git/commitdiff
inline filter editor uses prototype
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 20 May 2006 12:26:07 +0000 (13:26 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 20 May 2006 12:26:07 +0000 (13:26 +0100)
backend.php
prefs.js
tt-rss.css

index f51e9c1a73d47ffbac678070f7499f5116ef886d..4645759ea8b3488b6da9c3db0af7933ecc96a466 100644 (file)
 
                if ($subop == "editSave") {
 
-                       $regexp = db_escape_string(trim($_GET["r"]));
-                       $match = db_escape_string(trim($_GET["m"]));
+                       $reg_exp = db_escape_string(trim($_GET["reg_exp"]));
+                       $filter_type = db_escape_string(trim($_GET["filter_type"]));
                        $filter_id = db_escape_string($_GET["id"]);
-                       $feed_id = db_escape_string($_GET["fid"]);
-                       $action_id = db_escape_string($_GET["aid"]); 
+                       $feed_id = db_escape_string($_GET["feed_id"]);
+                       $action_id = db_escape_string($_GET["action_id"]); 
 
                        if (!$feed_id) {
                                $feed_id = 'NULL';
                        }
                        
                        $result = db_query($link, "UPDATE ttrss_filters SET 
-                               reg_exp = '$regexp', 
-                               feed_id = $feed_id,
-                               action_id = '$action_id',
-                               filter_type = (SELECT id FROM ttrss_filter_types WHERE
-                                       description = '$match')
+                                       reg_exp = '$reg_exp', 
+                                       feed_id = $feed_id,
+                                       action_id = '$action_id',
+                                       filter_type = '$filter_type'
                                WHERE id = '$filter_id'");
                }
 
                print "<div id=\"infoBoxShadow\">
                        <div id=\"infoBox\">PLACEHOLDER</div></div>";
 
-               $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 "<input type=\"submit\" 
 
                if (db_num_rows($result) != 0) {
 
+                       print "<form id=\"filter_edit_form\">";                 
+
                        print "<p><table width=\"100%\" cellspacing=\"0\" class=\"prefFilterList\" 
                                id=\"prefFilterList\">";
 
                                if (!$line["feed_title"]) $line["feed_title"] = "All feeds";
        
                                if (!$edit_filter_id || $subop != "edit") {
-       
+
                                        print "<td align='center'><input onclick='toggleSelectPrefRow(this, \"filter\");' 
                                        type=\"checkbox\" id=\"FICHK-".$line["id"]."\"></td>";
        
 
                                } else {
        
-                                       print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked></td>";
+                                       print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked>";
+                                       
+                                       print "<input type=\"hidden\" name=\"id\" value=\"$filter_id\">";
+                                       print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
+                                       print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
+
+                                       print "</td>";
        
-                                       print "<td><input id=\"iedit_regexp\" value=\"".$line["reg_exp"].
+                                       print "<td><input class=\"iedit\" name=\"reg_exp\" value=\"".$line["reg_exp"].
                                                "\"></td>";
        
                                        print "<td>";   
-                                       print_feed_select($link, "iedit_feed", $line["feed_id"]);                                       
+                                       print_feed_select($link, "feed_id", $line["feed_id"], "class=\"iedit\"");
                                        print "</td>";
                                        
                                        print "<td>";
-                                       print_select("iedit_match", $line["filter_type_descr"], $filter_types);
+                                       print_select_hash("filter_type", $line["filter_type"], $filter_types,   
+                                               "class=\"iedit\"");
                                        print "</td>";
 
                                        print "<td>";
-                                       print "<select id=\"iedit_filter_action\">";
+                                       print "<select name=\"action_id\" class=\"iedit\">";
        
                                        $tmp_result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
                                                ORDER BY description");
                                                } else {
                                                        $is_selected = "";
                                                }
-                                               printf("<option $is_selected id='%d'>%s</option>", 
+                                               printf("<option $is_selected value='%d'>%s</option>", 
                                                        $tmp_line["id"], $tmp_line["description"]);
                                        }
        
                        }
        
                        print "</table>";
+
+                       print "</form>";
        
                        print "<p id=\"filterOpToolbar\">";
        
                                        onclick=\"javascript:editSelectedFilter()\" value=\"Edit\">
                                <input type=\"submit\" class=\"button\" disabled=\"true\"
                                        onclick=\"javascript:removeSelectedFilters()\" value=\"Remove\">";
-                       }
+                       }                       
 
                } else {
 
index 50809d8703a36cc334e5747bafb6a194e908e7f8..7b1e4f0bb816d7b0aaa3d849ba1ffa8c61211a04 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -684,8 +684,6 @@ function feedCatEditCancel() {
 function feedEditSave() {
 
        try {
-
-               var feed = active_feed;
        
                if (!xmlhttp_ready(xmlhttp)) {
                        printLockingError();
@@ -887,39 +885,22 @@ function userEditSave() {
 
 function filterEditSave() {
 
-       var filter = active_filter;
-
        if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
                return
        }
 
-       var regexp = document.getElementById("iedit_regexp").value;
-       var match = document.getElementById("iedit_match");
-
-       var v_match = match[match.selectedIndex].text;
+       // FIXME: input validation
 
-       var feed = document.getElementById("iedit_feed");
-       var feed_id = feed[feed.selectedIndex].id;
-
-       var action = document.getElementById("iedit_filter_action");
-       var action_id = action[action.selectedIndex].id;
-
-       if (regexp.length == 0) {
-               alert("Can't save filter: match expression is blank.");
-               return;
-       }
+       notify("Saving filter...");
 
        active_filter = false;
 
-       xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
-               filter + "&r=" + param_escape(regexp) + "&m=" + param_escape(v_match) + 
-               "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
-
-       notify("Saving filter...");
+       var query = Form.serialize("filter_edit_form");
 
+       xmlhttp.open("GET", "backend.php?" + query, true);
        xmlhttp.onreadystatechange=filterlist_callback;
-       xmlhttp.send(null); 
+       xmlhttp.send(null);
 
 }
 
index 56edc7e9324dead0e607cfd6032d4045b16429e4..f9e109df65859d272a32dfa7d219486e560ce725 100644 (file)
@@ -287,7 +287,7 @@ a:hover {
        background-color : #f0fff0;
 }
 
-input.iedit {
+.iedit {
        width : 100%;
        padding-left : 2px;
 }