use prototype in form editor

This commit is contained in:
Andrew Dolgov 2006-05-20 12:16:16 +01:00
parent c6932f8da2
commit 14f69488da
6 changed files with 1849 additions and 132 deletions

View File

@ -1401,33 +1401,32 @@
print "<div class=\"infoBoxContents\">"; print "<div class=\"infoBoxContents\">";
# print "<h1>$feed_icon $title</h1>"; print "<form id=\"edit_feed_form\">";
print "<input type=\"hidden\" name=\"id\" value=\"$feed_id\">";
print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
print "<input type=\"hidden\" name=\"subop\" value=\"editSave\">";
print "<table width='100%'>"; print "<table width='100%'>";
# $row_class = "odd"; print "<tr><td>Title:</td>";
print "<td><input class=\"iedit\" name=\"title\" value=\"$title\"></td></tr>";
print "<tr class='$row_class'><td>Title:</td>";
print "<td><input id=\"iedit_title\" value=\"$title\"></td></tr>";
$feed_url = db_fetch_result($result, 0, "feed_url"); $feed_url = db_fetch_result($result, 0, "feed_url");
$feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result, $feed_url = htmlspecialchars(db_unescape_string(db_fetch_result($result,
0, "feed_url"))); 0, "feed_url")));
# $row_class = toggleEvenOdd($row_class);
print "<tr><td>Feed URL:</td>";
print "<tr class='$row_class'><td>Feed URL:</td>"; print "<td><input class=\"iedit\" name=\"feed_url\" value=\"$feed_url\"></td></tr>";
print "<td><input id=\"iedit_link\" value=\"$feed_url\"></td></tr>";
if (get_pref($link, 'ENABLE_FEED_CATS')) { if (get_pref($link, 'ENABLE_FEED_CATS')) {
$cat_id = db_fetch_result($result, 0, "cat_id"); $cat_id = db_fetch_result($result, 0, "cat_id");
# $row_class = toggleEvenOdd($row_class); print "<tr><td>Category:</td>";
print "<tr class='$row_class'><td>Category:</td>";
print "<td>"; print "<td>";
print_feed_cat_select($link, "iedit_fcat", $cat_id); print_feed_cat_select($link, "cat_id", $cat_id);
print "</td>"; print "</td>";
print "</td></tr>"; print "</td></tr>";
@ -1435,13 +1434,12 @@
} }
$update_interval = db_fetch_result($result, 0, "update_interval"); $update_interval = db_fetch_result($result, 0, "update_interval");
# $row_class = toggleEvenOdd($row_class);
print "<tr class='$row_class'><td>Update Interval:</td>"; print "<tr><td>Update Interval:</td>";
print "<td>"; print "<td>";
print "<select id=\"iedit_updintl\">"; print "<select name=\"update_interval\">";
foreach (array_keys($update_intervals) as $i) { foreach (array_keys($update_intervals) as $i) {
@ -1450,16 +1448,14 @@
} else { } else {
$selected = ""; $selected = "";
} }
print "<option $selected id=\"$i\">" . $update_intervals[$i] . "</option>"; print "<option $selected value=\"$i\">" . $update_intervals[$i] . "</option>";
} }
print "</select>"; print "</select>";
print "</td>"; print "</td>";
# $row_class = toggleEvenOdd($row_class); print "<tr><td>Link to:</td><td>";
print "<tr class='$row_class'><td>Link to:</td><td>";
$tmp_result = db_query($link, "SELECT COUNT(id) AS count $tmp_result = db_query($link, "SELECT COUNT(id) AS count
FROM ttrss_feeds WHERE parent_feed = '$feed_id'"); FROM ttrss_feeds WHERE parent_feed = '$feed_id'");
@ -1472,9 +1468,9 @@
$disabled = "disabled"; $disabled = "disabled";
} }
print "<select $disabled id=\"iedit_parent_feed\">"; print "<select $disabled name=\"parent_feed\">";
print "<option id=\"0\">Not linked</option>"; print "<option value=\"0\">Not linked</option>";
if (get_pref($link, 'ENABLE_FEED_CATS')) { if (get_pref($link, 'ENABLE_FEED_CATS')) {
if ($cat_id) { if ($cat_id) {
@ -1498,7 +1494,7 @@
} else { } else {
$is_selected = ""; $is_selected = "";
} }
printf("<option $is_selected id='%d'>%s</option>", printf("<option $is_selected value='%d'>%s</option>",
$tmp_line["id"], $tmp_line["title"]); $tmp_line["id"], $tmp_line["title"]);
} }
@ -1506,15 +1502,12 @@
print "</td></tr>"; print "</td></tr>";
$purge_interval = db_fetch_result($result, 0, "purge_interval"); $purge_interval = db_fetch_result($result, 0, "purge_interval");
# $row_class = toggleEvenOdd($row_class);
print "<tr class='$row_class'><td>Article purging:</td>"; print "<tr><td>Article purging:</td>";
// print "<td><input id=\"iedit_purgintl\"
// value=\"$purge_interval\"></td></tr>";
print "<td>"; print "<td>";
print "<select id=\"iedit_purgintl\">"; print "<select name=\"purge_interval\">";
foreach (array_keys($purge_intervals) as $i) { foreach (array_keys($purge_intervals) as $i) {
@ -1523,30 +1516,24 @@
} else { } else {
$selected = ""; $selected = "";
} }
print "<option $selected id=\"$i\">" . $purge_intervals[$i] . "</option>"; print "<option $selected value=\"$i\">" . $purge_intervals[$i] . "</option>";
} }
print "</select>"; print "</select>";
print "</td>"; print "</td>";
// print "<tr><td colspan=\"2\"><b>Authentication</b></td></tr>";
# $row_class = toggleEvenOdd($row_class);
$auth_login = db_fetch_result($result, 0, "auth_login"); $auth_login = db_fetch_result($result, 0, "auth_login");
print "<tr class='$row_class'><td>Login:</td>"; print "<tr><td>Login:</td>";
print "<td><input id=\"iedit_login\" print "<td><input class=\"iedit\" name=\"auth_login\" value=\"$auth_login\"></td></tr>";
value=\"$auth_login\"></td></tr>";
# $row_class = toggleEvenOdd($row_class);
$auth_pass = db_fetch_result($result, 0, "auth_pass"); $auth_pass = db_fetch_result($result, 0, "auth_pass");
print "<tr class='$row_class'><td>Password:</td>"; print "<tr><td>Password:</td>";
print "<td><input type=\"password\" id=\"iedit_pass\" print "<td><input class=\"iedit\" type=\"password\" name=\"auth_pass\"
value=\"$auth_pass\"></td></tr>"; value=\"$auth_pass\"></td></tr>";
# $row_class = toggleEvenOdd($row_class);
$private = sql_bool_to_bool(db_fetch_result($result, 0, "private")); $private = sql_bool_to_bool(db_fetch_result($result, 0, "private"));
if ($private) { if ($private) {
@ -1555,9 +1542,9 @@
$checked = ""; $checked = "";
} }
print "<tr class='$row_class'><td valign='top'>Options:</td>"; print "<tr><td valign='top'>Options:</td>";
print "<td><input type=\"checkbox\" id=\"iedit_private\" print "<td><input type=\"checkbox\" name=\"private\" id=\"private\"
$checked><label for=\"iedit_private\">Hide from feed browser</label>"; $checked><label for=\"private\">Hide from feed browser</label>";
$rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content")); $rtl_content = sql_bool_to_bool(db_fetch_result($result, 0, "rtl_content"));
@ -1567,12 +1554,15 @@
$checked = ""; $checked = "";
} }
print "<br><input type=\"checkbox\" id=\"iedit_rtl\" print "<br><input type=\"checkbox\" id=\"rtl_content\" name=\"rtl_content\"
$checked><label for=\"iedit_rtl\">Right-to-left content</label>"; $checked><label for=\"rtl_content\">Right-to-left content</label>";
print "</td></tr>"; print "</td></tr>";
print "</table>"; print "</table>";
print "</form>";
print "</div>"; print "</div>";
print "<div align='center'> print "<div align='center'>
@ -1584,37 +1574,26 @@
} }
if ($subop == "editSave") { if ($subop == "editSave") {
$feed_title = db_escape_string(trim($_POST["t"]));
$feed_link = db_escape_string(trim($_POST["l"])); $feed_title = db_escape_string(trim($_POST["title"]));
$upd_intl = db_escape_string($_POST["ui"]); $feed_link = db_escape_string(trim($_POST["feed_url"]));
$purge_intl = db_escape_string($_POST["pi"]); $upd_intl = db_escape_string($_POST["update_interval"]);
$purge_intl = db_escape_string($_POST["purge_interval"]);
$feed_id = db_escape_string($_POST["id"]); $feed_id = db_escape_string($_POST["id"]);
$cat_id = db_escape_string($_POST["catid"]); $cat_id = db_escape_string($_POST["cat_id"]);
$auth_login = db_escape_string(trim($_POST["login"])); $auth_login = db_escape_string(trim($_POST["auth_login"]));
$auth_pass = db_escape_string(trim($_POST["pass"])); $auth_pass = db_escape_string(trim($_POST["auth_pass"]));
$parent_feed = db_escape_string($_POST["pfeed"]); $parent_feed = db_escape_string($_POST["parent_feed"]);
$private = db_escape_string($_POST["is_pvt"]); $private = checkbox_to_sql_bool(db_escape_string($_POST["private"]));
$rtl_content = db_escape_string($_POST["is_rtl"]); $rtl_content = checkbox_to_sql_bool(db_escape_string($_POST["rtl_content"]));
if (strtoupper($upd_intl) == "DEFAULT") if ($cat_id && $cat_id != 0) {
$upd_intl = 0;
if (strtoupper($upd_intl) == "DISABLED")
$upd_intl = -1;
if (strtoupper($purge_intl) == "DEFAULT")
$purge_intl = 0;
if (strtoupper($purge_intl) == "DISABLED")
$purge_intl = -1;
if ($cat_id != 0) {
$category_qpart = "cat_id = '$cat_id'"; $category_qpart = "cat_id = '$cat_id'";
} else { } else {
$category_qpart = 'cat_id = NULL'; $category_qpart = 'cat_id = NULL';
} }
if ($parent_feed != 0) { if ($parent_feed && $parent_feed != 0) {
$parent_qpart = "parent_feed = '$parent_feed'"; $parent_qpart = "parent_feed = '$parent_feed'";
} else { } else {
$parent_qpart = 'parent_feed = NULL'; $parent_qpart = 'parent_feed = NULL';

View File

@ -1610,10 +1610,10 @@
function print_feed_cat_select($link, $id, $default_id = "", function print_feed_cat_select($link, $id, $default_id = "",
$attributes = "", $include_all_cats = true) { $attributes = "", $include_all_cats = true) {
print "<select id=\"$id\" $attributes>"; print "<select name=\"$id\" $attributes>";
if ($include_all_cats) { if ($include_all_cats) {
print "<option id=\"0\">Uncategorized</option>"; print "<option value=\"0\">Uncategorized</option>";
} }
$result = db_query($link, "SELECT id,title FROM ttrss_feed_categories $result = db_query($link, "SELECT id,title FROM ttrss_feed_categories
@ -1629,11 +1629,14 @@
} else { } else {
$is_selected = ""; $is_selected = "";
} }
printf("<option $is_selected id='%d'>%s</option>", printf("<option $is_selected value='%d'>%s</option>",
$line["id"], $line["title"]); $line["id"], $line["title"]);
} }
print "</select>"; print "</select>";
} }
function checkbox_to_sql_bool($val) {
return ($val == "on") ? "true" : "false";
}
?> ?>

View File

@ -690,75 +690,20 @@ function feedEditSave() {
printLockingError(); printLockingError();
return return
} }
var link = document.getElementById("iedit_link").value;
var title = document.getElementById("iedit_title").value;
var upd_intl = document.getElementById("iedit_updintl");
upd_intl = upd_intl[upd_intl.selectedIndex].id; // FIXME: add parameter validation
var purge_intl = document.getElementById("iedit_purgintl");
purge_intl = purge_intl[purge_intl.selectedIndex].id; var query = Form.serialize("edit_feed_form");
var fcat = document.getElementById("iedit_fcat");
var is_pvt = document.getElementById("iedit_private");
var is_rtl = document.getElementById("iedit_rtl");
if (is_pvt) {
is_pvt = is_pvt.checked;
}
if (is_rtl) {
is_rtl = is_rtl.checked;
}
var fcat_id = 0;
if (fcat) {
fcat_id = fcat[fcat.selectedIndex].id;
}
var pfeed = document.getElementById("iedit_parent_feed");
var parent_feed_id = pfeed[pfeed.selectedIndex].id;
if (link.length == 0) {
notify("Feed link cannot be blank.");
return;
}
if (title.length == 0) {
notify("Feed title cannot be blank.");
return;
}
if (!isValidURL(link)) {
alert("Feed URL is invalid.");
return;
}
var auth_login = document.getElementById("iedit_login").value;
var auth_pass = document.getElementById("iedit_pass").value;
active_feed = false; active_feed = false;
notify("Saving feed..."); notify("Saving feed...");
var query = "op=pref-feeds&subop=editSave&id=" +
feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
"&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
"&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
"&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass) +
"&is_pvt=" + param_escape(is_pvt) + "&is_rtl=" + param_escape(is_rtl);
selectPrefRows('feed', false); // cleanup feed selection
xmlhttp.open("POST", "backend.php", true); xmlhttp.open("POST", "backend.php", true);
xmlhttp.onreadystatechange=feedlist_callback; xmlhttp.onreadystatechange=feedlist_callback;
xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xmlhttp.send(query); xmlhttp.send(query);
} catch (e) { } catch (e) {
exception_error("feedEditSave", e); exception_error("feedEditSave", e);
} }

View File

@ -43,7 +43,8 @@
<? } ?> <? } ?>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript" src="functions.js?<?= $dt_add ?>"></script> <script type="text/javascript" src="functions.js?<?= $dt_add ?>"></script>
<script type="text/javascript" src="prefs.js?<?= $dt_add ?>"></script> <script type="text/javascript" src="prefs.js?<?= $dt_add ?>"></script>

1781
prototype.js vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -278,12 +278,18 @@ a:hover {
opacity : 0.8; opacity : 0.8;
} }
/*
#iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl, #iedit_title, #iedit_link, #iedit_regexp, #iedit_descr, #iedit_expr, #iedit_updintl,
#iedit_purgintl, #iedit_ulogin, #iedit_ulevel, #iedit_match, #iedit_feed, #iedit_purgintl, #iedit_ulogin, #iedit_ulevel, #iedit_match, #iedit_feed,
#iedit_fcat, #iedit_filter_action, #iedit_login, #iedit_pass, #iedit_email, #iedit_fcat, #iedit_filter_action, #iedit_login, #iedit_pass, #iedit_email,
#iedit_parent_feed { #iedit_parent_feed {
width : 100%; width : 100%;
padding-left : 2px; padding-left : 2px;
} */
input.iedit {
width : 100%;
padding-left : 2px;
} }
input.editbox { input.editbox {
@ -1092,3 +1098,5 @@ div.noDaemonWarning {
#qafInput { #qafInput {
width : 100%; width : 100%;
} }