]> git.wh0rd.org Git - tt-rss.git/commitdiff
edit filter dialog: code cleanup
authorAndrew Dolgov <fox@fakecake.org>
Sun, 21 Nov 2010 09:08:03 +0000 (12:08 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sun, 21 Nov 2010 09:08:03 +0000 (12:08 +0300)
modules/pref-filters.php
prefs.js

index 5d4b60bc40525e976d0cd6eb108bfd1993b3fe7e..168afb82081ce4d0be6b3afd6fd42c20dc7f96d8 100644 (file)
 
                        print "<div class=\"dlgButtons\">";
 
-                       $reg_exp = htmlspecialchars($reg_exp, ENT_QUOTES); // second escaping seems to be needed for javascript
-
                        print "<div style=\"float : left\">";
-                       print "<button dojoType=\"dijit.form.Button\" onclick='return removeFilter($filter_id, \"$reg_exp\")'>".
+                       print "<button dojoType=\"dijit.form.Button\" onclick=\"return dijit.byId('filterEditDlg').removeFilter()\">".
                                __('Remove')."</button>";
                        print "</div>";
 
                        foreach ($ids as $id) {
                                db_query($link, "DELETE FROM ttrss_filters WHERE id = '$id' AND owner_uid = ". $_SESSION["uid"]);
                        }
+                       return;
                }
 
                if ($subop == "add") {
index bb8286d05168283e94ca404e3cd6f29a7d997788..d8276160989a800748ff0af04f603d90b2d17a08 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -265,6 +265,28 @@ function editFilter(id, event) {
                        id: "filterEditDlg",
                        title: __("Edit Filter"),
                        style: "width: 600px",
+                       removeFilter: function() {
+                               var title = this.attr('value').reg_exp;
+                               var msg = __("Remove filter %s?").replace("%s", title);
+               
+                               if (confirm(msg)) {
+                                       this.hide();
+
+                                       notify_progress("Removing filter...");
+               
+                                       var id = this.attr('value').id;
+
+                                       var query = "?op=pref-filters&subop=remove&ids="+
+                                               param_escape(id);
+
+                                       new Ajax.Request("backend.php", {
+                                               parameters: query,
+                                               onComplete: function(transport) {
+                                                       updateFilterList();
+                                               } });
+                               }
+                       },
+
                        execute: function() {
                                if (this.validate()) {
 
@@ -1437,39 +1459,6 @@ function rescore_all_feeds() {
        }
 }
 
-function removeFilter(id, title) {
-
-       try {
-
-               var msg = __("Remove filter %s?").replace("%s", title);
-       
-               var ok = confirm(msg);
-       
-               if (ok) {
-
-                       if (dijit.byId("filterEditDlg"))
-                               dijit.byId("filterEditDlg").hide();
-
-                       notify_progress("Removing filter...");
-               
-                       var query = "?op=pref-filters&subop=remove&ids="+
-                               param_escape(id);
-
-                       new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                               filterlist_callback2(transport);
-                       } });
-
-               }
-
-       } catch (e) {
-               exception_error("removeFilter", e);
-       }
-
-       return false;
-}
-
 function labelColorReset() {
        try {
                var labels = getSelectedLabels();