]> git.wh0rd.org - tt-rss.git/blobdiff - js/functions.js
properly handle invalid regular expressions supplied when testing filters, add some...
[tt-rss.git] / js / functions.js
index bd0d5fb731743bdb94cd123be7d44c8ad4926031..4a4602f9ed42fbe7d801e3cf6fc8d2322274fb91 100644 (file)
@@ -982,19 +982,39 @@ function quickAddFilter() {
                        test: function() {
                                if (this.validate()) {
 
-                                       if (dijit.byId("filterTestDlg"))
-                                               dijit.byId("filterTestDlg").destroyRecursive();
+                                       var query = "?op=rpc&method=verifyRegexp&reg_exp=" +
+                                               param_escape(dialog.attr('value').reg_exp);
+
+                                       notify_progress("Verifying regular expression...");
+
+                                       new Ajax.Request("backend.php", {
+                                               parameters: query,
+                                               onComplete: function(transport) {
+                                                       var reply = JSON.parse(transport.responseText);
+
+                                                       if (reply) {
+                                                               notify('');
+
+                                                               if (!reply['status']) {
+                                                                       alert("Invalid regular expression.");
+                                                                       return;
+                                                               } else {
 
-                                       tdialog = new dijit.Dialog({
-                                               id: "filterTestDlg",
-                                               title: __("Filter Test Results"),
-                                               style: "width: 600px",
-                                               href: "backend.php?savemode=test&" +
-                                                       dojo.objectToQuery(dialog.attr('value')),
-                                               });
+                                                                       if (dijit.byId("filterTestDlg"))
+                                                                               dijit.byId("filterTestDlg").destroyRecursive();
 
-                                       tdialog.show();
+                                                                       tdialog = new dijit.Dialog({
+                                                                               id: "filterTestDlg",
+                                                                               title: __("Filter Test Results"),
+                                                                               style: "width: 600px",
+                                                                               href: "backend.php?savemode=test&" +
+                                                                               dojo.objectToQuery(dialog.attr('value')),
+                                                                       });
 
+                                                                       tdialog.show();
+                                                               }
+                                                       }
+                                       }});
                                }
                        },
                        execute: function() {
@@ -1014,7 +1034,7 @@ function quickAddFilter() {
                                                                notify('');
 
                                                                if (!reply['status']) {
-                                                                       alert("Match regular expression seems to be invalid.");
+                                                                       alert("Invalid regular expression.");
                                                                        return;
                                                                } else {
                                                                        notify_progress("Saving data...", true);