]> git.wh0rd.org - tt-rss.git/commitdiff
filterEditDlg: automatically open new rule dialog when active feed or article title...
authorAndrew Dolgov <fox@fakecake.org>
Fri, 31 Aug 2012 13:33:22 +0000 (17:33 +0400)
committerAndrew Dolgov <fox@fakecake.org>
Fri, 31 Aug 2012 13:33:22 +0000 (17:33 +0400)
classes/pref/filters.php
js/functions.js

index 53f7d396a9c4be797f2d07aca22d1c845c846157..c91b190acdd1a02335626f7164f80e3127045ea1 100644 (file)
@@ -615,9 +615,6 @@ class Pref_Filters extends Handler_Protected {
 
                print "<form name='filter_new_form' id='filter_new_form'>";
 
-               $active_feed_id = (int) db_escape_string($_REQUEST["feed"]);
-               $cat_filter = db_escape_string($_REQUEST["is_cat"]) == "true";
-
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"op\" value=\"pref-filters\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"method\" value=\"add\">";
                print "<input dojoType=\"dijit.form.TextBox\" style=\"display : none\" name=\"csrf_token\" value=\"".$_SESSION['csrf_token']."\">";
index a01ce3cad01abcb89cd06c369f7ff6d140efc90b..313cbe5c9bbf98819469dbc4a74b3c2a59fe3adf 100644 (file)
@@ -1169,6 +1169,27 @@ function quickAddFilter() {
                        },
                        href: query});
 
+               if (!inPreferences()) {
+                       var lh = dojo.connect(dialog, "onLoad", function(){
+                               dojo.disconnect(lh);
+
+                               var title = $("PTITLE-FULL-" + active_post_id);
+
+                               if (title || getActiveFeedId() || activeFeedIsCat()) {
+                                       if (title) title = title.innerHTML;
+
+                                       console.log(title + " " + getActiveFeedId());
+
+                                       var feed_id = activeFeedIsCat() ? 'CAT:' + parseInt(getActiveFeedId()) :
+                                               getActiveFeedId();
+
+                                       var rule = { reg_exp: title, feed_id: feed_id, filter_type: 1 };
+
+                                       addFilterRule(null, dojo.toJson(rule));
+                               }
+                       });
+               }
+
                dialog.show();
 
        } catch (e) {