inline label editor uses prototype

This commit is contained in:
Andrew Dolgov 2006-05-20 13:40:50 +01:00
parent 7e939457ba
commit f3120e5a8c
2 changed files with 27 additions and 15 deletions

View File

@ -2427,12 +2427,10 @@
if ($subop == "editSave") { if ($subop == "editSave") {
$sql_exp = trim($_GET["s"]); $sql_exp = trim($_GET["sql_exp"]);
$descr = trim($_GET["d"]); $descr = db_escape_string(trim($_GET["description"]));
$label_id = db_escape_string($_GET["id"]); $label_id = db_escape_string($_GET["id"]);
// print "$sql_exp : $descr : $label_id";
$result = db_query($link, "UPDATE ttrss_labels SET $result = db_query($link, "UPDATE ttrss_labels SET
sql_exp = '$sql_exp', sql_exp = '$sql_exp',
description = '$descr' description = '$descr'
@ -2486,6 +2484,8 @@
if (db_num_rows($result) != 0) { if (db_num_rows($result) != 0) {
print "<form id=\"label_edit_form\">";
print "<p><table width=\"100%\" cellspacing=\"0\" print "<p><table width=\"100%\" cellspacing=\"0\"
class=\"prefLabelList\" id=\"prefLabelList\">"; class=\"prefLabelList\" id=\"prefLabelList\">";
@ -2548,12 +2548,18 @@
} else { } else {
print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked></td>"; print "<td align='center'><input disabled=\"true\" type=\"checkbox\" checked>";
print "<td><input id=\"iedit_expr\" value=\"".$line["sql_exp"]. 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 class=\"iedit\" name=\"sql_exp\" value=\"".$line["sql_exp"].
"\"></td>"; "\"></td>";
print "<td><input id=\"iedit_descr\" value=\"".$line["description"]. print "<td><input class=\"iedit\" name=\"description\" value=\"".$line["description"].
"\"></td>"; "\"></td>";
} }
@ -2569,6 +2575,8 @@
print "</table>"; print "</table>";
print "</form>";
print "<p id=\"labelOpToolbar\">"; print "<p id=\"labelOpToolbar\">";
if ($subop == "edit") { if ($subop == "edit") {

View File

@ -734,11 +734,13 @@ function feedCatEditSave() {
function labelTest() { function labelTest() {
var sqlexp = document.getElementById("iedit_expr").value; var form = document.forms['label_edit_form'];
var descr = document.getElementById("iedit_descr").value;
var sql_exp = form.sql_exp.value;
var description = form.description.value;
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" + 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.onreadystatechange=infobox_callback;
xmlhttp.send(null); xmlhttp.send(null);
@ -815,7 +817,7 @@ function labelEditSave() {
return return
} }
var sqlexp = document.getElementById("iedit_expr").value; /* var sqlexp = document.getElementById("iedit_expr").value;
var descr = document.getElementById("iedit_descr").value; var descr = document.getElementById("iedit_descr").value;
// notify("Saving label " + sqlexp + ": " + descr); // notify("Saving label " + sqlexp + ": " + descr);
@ -828,15 +830,17 @@ function labelEditSave() {
if (descr.length == 0) { if (descr.length == 0) {
notify("Caption cannot be blank."); notify("Caption cannot be blank.");
return; return;
} } */
// FIXME: input validation
notify("Saving label..."); notify("Saving label...");
active_label = false; active_label = false;
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" + query = Form.serialize("label_edit_form");
label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
true); xmlhttp.open("GET", "backend.php?" + query, true);
xmlhttp.onreadystatechange=labellist_callback; xmlhttp.onreadystatechange=labellist_callback;
xmlhttp.send(null); xmlhttp.send(null);