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

index 4645759ea8b3488b6da9c3db0af7933ecc96a466..183cacbcd5a0baa12c6e78042437dcf1a7c37ea4 100644 (file)
 
                if ($subop == "editSave") {
 
-                       $sql_exp = trim($_GET["s"]);
-                       $descr = trim($_GET["d"]);
+                       $sql_exp = trim($_GET["sql_exp"]);
+                       $descr = db_escape_string(trim($_GET["description"]));
                        $label_id = db_escape_string($_GET["id"]);
                        
-//                     print "$sql_exp : $descr : $label_id";
-                       
                        $result = db_query($link, "UPDATE ttrss_labels SET 
                                sql_exp = '$sql_exp', 
                                description = '$descr'
 
                if (db_num_rows($result) != 0) {
 
+                       print "<form id=\"label_edit_form\">";
+
                        print "<p><table width=\"100%\" cellspacing=\"0\" 
                                class=\"prefLabelList\" id=\"prefLabelList\">";
 
        
                                } 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=\"$label_id\">";
+                                       print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
+                                       print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
+                                       
+                                       print "</td>";
        
-                                       print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"].
+                                       print "<td><input class=\"iedit\" name=\"sql_exp\" value=\"".$line["sql_exp"].
                                                "\"></td>";
        
-                                       print "<td><input id=\"iedit_descr\" value=\"".$line["description"].
+                                       print "<td><input class=\"iedit\" name=\"description\" value=\"".$line["description"].
                                                "\"></td>";                                                     
                                }
                                        
                        }
        
                        print "</table>";
+
+                       print "</form>";
        
                        print "<p id=\"labelOpToolbar\">";
        
index 7b1e4f0bb816d7b0aaa3d849ba1ffa8c61211a04..ec65e839924b53acd8f40e4e71dd198ac53a12ee 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -734,11 +734,13 @@ function feedCatEditSave() {
 
 function labelTest() {
 
-       var sqlexp = document.getElementById("iedit_expr").value;
-       var descr = document.getElementById("iedit_descr").value;
+       var form = document.forms['label_edit_form'];
+
+       var sql_exp = form.sql_exp.value;
+       var description = form.description.value;
 
        xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
-               param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
+               param_escape(sql_exp) + "&descr=" + param_escape(description), true);
 
        xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
@@ -815,7 +817,7 @@ function labelEditSave() {
                return
        }
 
-       var sqlexp = document.getElementById("iedit_expr").value;
+/*     var sqlexp = document.getElementById("iedit_expr").value;
        var descr = document.getElementById("iedit_descr").value;
 
 //     notify("Saving label " + sqlexp + ": " + descr);
@@ -828,15 +830,17 @@ function labelEditSave() {
        if (descr.length == 0) {
                notify("Caption cannot be blank.");
                return;
-       }
+       } */
+
+       // FIXME: input validation
 
        notify("Saving label...");
 
        active_label = false;
 
-       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
-               label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
-               true);
+       query = Form.serialize("label_edit_form");
+
+       xmlhttp.open("GET", "backend.php?" + query, true);
                
        xmlhttp.onreadystatechange=labellist_callback;
        xmlhttp.send(null);