]> git.wh0rd.org Git - tt-rss.git/commitdiff
filterEditDlg: add regexp verification; js: code cleanup
authorAndrew Dolgov <fox@fakecake.org>
Sat, 20 Nov 2010 12:02:20 +0000 (15:02 +0300)
committerAndrew Dolgov <fox@fakecake.org>
Sat, 20 Nov 2010 12:02:52 +0000 (15:02 +0300)
functions.js
prefs.js

index e9a1f70b60d3d049119eb531b3a18e1598cb5a0c..946e29a9a9512917b226168a6910875857e6cb0b 100644 (file)
@@ -1184,18 +1184,43 @@ function quickAddFilter() {
                        style: "width: 600px",
                        execute: function() {
                                if (this.validate()) {
-                                       console.log(dojo.objectToQuery(this.attr('value')));
-                                       new Ajax.Request("backend.php", {
-                                               parameters: dojo.objectToQuery(this.attr('value')),
+
+                                       var query = "?op=rpc&subop=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) {
-                                                       this.hide();
-                                                       notify_progress("Savind data...", true);
-                                                       notify_info(transport.responseText);
-                                                       if (inPreferences()) {
-                                                               updateFilterList();                             
+                                                       handle_rpc_reply(transport);
+                                                       var response = transport.responseXML;
+
+                                                       if (response) {
+                                                               var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
+       
+                                                               notify('');
+
+                                                               if (s == "INVALID") {
+                                                                       alert("Match regular expression seems to be invalid.");
+                                                                       return;
+                                                               } else {
+                                                                       notify_progress("Saving data...", true);
+
+                                                                       console.log(dojo.objectToQuery(dialog.attr('value')));
+
+                                                                       new Ajax.Request("backend.php", {
+                                                                               parameters: dojo.objectToQuery(dialog.attr('value')),
+                                                                               onComplete: function(transport) {
+                                                                                       dialog.hide();
+                                                                                       notify_info(transport.responseText);
+                                                                                       if (inPreferences()) {
+                                                                                               updateFilterList();                             
+                                                                                       }
+                                                                       }})
+                                                               }       
                                                        }
                                        }});
-
                                }
                        },
                        href: query});
index fdcf28e873cee2fde3d60254b88616ee48e3b1b3..14af5b6078f8d628b0b15a96130b94fbb66da6cf 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -301,12 +301,39 @@ function editFilter(id, event) {
                        style: "width: 600px",
                        execute: function() {
                                if (this.validate()) {
-                                       this.hide();
-                                       notify_progress("Savind data...", true);
-                                       new Ajax.Request("backend.php", {
-                                               parameters: dojo.objectToQuery(this.attr('value')),
+
+                                       var query = "?op=rpc&subop=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) {
-                                                       updateFilterList();                             
+                                                       handle_rpc_reply(transport);
+                                                       var response = transport.responseXML;
+
+                                                       if (response) {
+                                                               var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
+       
+                                                               notify('');
+
+                                                               if (s == "INVALID") {
+                                                                       alert("Match regular expression seems to be invalid.");
+                                                                       return;
+                                                               } else {
+                                                                       notify_progress("Saving data...", true);
+
+                                                                       console.log(dojo.objectToQuery(dialog.attr('value')));
+
+                                                                       new Ajax.Request("backend.php", {
+                                                                               parameters: dojo.objectToQuery(dialog.attr('value')),
+                                                                               onComplete: function(transport) {
+                                                                                       dialog.hide();
+                                                                                       updateFilterList();                             
+                                                                       }})
+                                                               }       
+                                                       }
                                        }});
                                }
                        },
@@ -687,11 +714,6 @@ function userEditCancel() {
        return false;
 }
 
-function filterEditCancel() {
-       closeInfoBox();
-       return false;
-}
-
 function userEditSave() {
 
        try {
@@ -724,55 +746,6 @@ function userEditSave() {
 }
 
 
-function filterEditSave() {
-       try {
-               var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
-
-               var query = "?op=rpc&subop=verifyRegexp&reg_exp=" + param_escape(reg_exp);
-
-               notify_progress("Verifying regular expression...");
-
-               new Ajax.Request("backend.php", {
-                               parameters: query,
-                               onComplete: function(transport) {
-                                       handle_rpc_reply(transport);
-
-                                       var response = transport.responseXML;
-
-                                       if (response) {
-                                               var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
-       
-                                               notify('');
-
-                                               if (s == "INVALID") {
-                                                       alert("Match regular expression seems to be invalid.");
-                                                       return;
-                                               } else {
-
-                                                       var query = "?" + Form.serialize("filter_edit_form");
-                                       
-                                                       notify_progress("Saving filter...");
-                       
-                                                       Form.disable("filter_edit_form");
-
-                                                       new Ajax.Request("backend.php", {
-                                                                       parameters: query,
-                                                                       onComplete: function(transport) {
-                                                                                       closeInfoBox();
-                                                                                       filterlist_callback2(transport);
-                                                               } });
-                                               }
-                                       }
-                       } });
-
-       } catch (e) {
-               exception_error("filterEditSave", e);
-       }
-
-       return false;
-}
-
-
 function editSelectedUser() {
        var rows = getSelectedUsers();
 
@@ -2002,29 +1975,4 @@ function editLabel(id, event) {
        }
 }
 
-function editLabelSave() {
-       try {
-               var form = document.forms['label_edit_form'];
-
-               var id = form.id.value;
-               var caption = form.caption.value;
-               var fg_color = form.fg_color.value;
-               var bg_color = form.bg_color.value;
-
-               var query = Form.serialize('label_edit_form');
 
-               dijit.byId('labelTree').setNameById(id, caption);
-               setLabelColor(id, fg_color, bg_color);
-
-               closeInfoBox();
-               updateFilterList();
-
-               new Ajax.Request("backend.php", {
-                       parameters: query,
-                       onComplete: function(transport) { 
-                       } });
-
-       } catch (e) {
-               exception_error("editLabelSave", e);
-       }
-}