create filter dialog uses prototype

master
Andrew Dolgov 19 years ago
parent 14f69488da
commit 79f3553b8b

@ -2146,10 +2146,10 @@
if (!WEB_DEMO_MODE) { if (!WEB_DEMO_MODE) {
$regexp = db_escape_string(trim($_GET["regexp"])); $regexp = db_escape_string(trim($_GET["reg_exp"]));
$match = db_escape_string(trim($_GET["match"])); $match_id = db_escape_string(trim($_GET["match_id"]));
$feed_id = db_escape_string($_GET["fid"]); $feed_id = db_escape_string($_GET["feed_id"]);
$action_id = db_escape_string($_GET["aid"]); $action_id = db_escape_string($_GET["action_id"]);
if (!$feed_id) { if (!$feed_id) {
$feed_id = 'NULL'; $feed_id = 'NULL';
@ -2161,8 +2161,7 @@
"INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id, "INSERT INTO ttrss_filters (reg_exp,filter_type,owner_uid,feed_id,
action_id) action_id)
VALUES VALUES
('$regexp', (SELECT id FROM ttrss_filter_types WHERE ('$regexp', '$match_id','".$_SESSION["uid"]."',
description = '$match'),'".$_SESSION["uid"]."',
$feed_id, '$action_id')"); $feed_id, '$action_id')");
} }
} }
@ -2742,41 +2741,48 @@
print "<div id=\"infoBoxTitle\">Create filter</div>"; print "<div id=\"infoBoxTitle\">Create filter</div>";
print "<div class=\"infoBoxContents\">"; print "<div class=\"infoBoxContents\">";
print "<form id=\"filter_add_form\">";
print "<input type=\"hidden\" name=\"op\" value=\"pref-filters\">";
print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
// print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>"; // print "<div class=\"notice\"><b>Note:</b> filter will only apply to new articles.</div>";
$result = db_query($link, "SELECT description $result = db_query($link, "SELECT id,description
FROM ttrss_filter_types ORDER BY description"); FROM ttrss_filter_types ORDER BY description");
$filter_types = array(); $filter_types = array();
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
array_push($filter_types, $line["description"]); //array_push($filter_types, $line["description"]);
$filter_types[$line["id"]] = $line["description"];
} }
print "<table width='100%'>"; print "<table width='100%'>";
print "<tr><td>Match:</td> print "<tr><td>Match:</td>
<td><input onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\" <td><input onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
id=\"fadd_regexp\" size=\"30\">&nbsp;"; name=\"reg_exp\" size=\"30\">&nbsp;";
print_select("fadd_match", "Title", $filter_types); print_select_hash("match_id", 1, $filter_types);
print "</td></tr>"; print "</td></tr>";
print "<tr><td>Feed:</td><td>"; print "<tr><td>Feed:</td><td>";
print_feed_select($link, "fadd_feed"); print_feed_select($link, "feed_id");
print "</td></tr>"; print "</td></tr>";
print "<tr><td>Action:</td>"; print "<tr><td>Action:</td>";
print "<td><select id=\"fadd_action\">"; print "<td><select name=\"action_id\">";
$result = db_query($link, "SELECT id,description FROM ttrss_filter_actions $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions
ORDER BY name"); ORDER BY name");
while ($line = db_fetch_assoc($result)) { while ($line = db_fetch_assoc($result)) {
printf("<option id='%d'>%s</option>", $line["id"], $line["description"]); printf("<option value='%d'>%s</option>", $line["id"], $line["description"]);
} }
print "</select>"; print "</select>";
@ -2794,6 +2800,8 @@
print "</td></tr></table>"; print "</td></tr></table>";
print "</form>";
} }
print "</div>"; print "</div>";

@ -992,13 +992,15 @@ function displayDlg(id, param) {
function infobox_submit_callback() { function infobox_submit_callback() {
if (xmlhttp.readyState == 4) { if (xmlhttp.readyState == 4) {
notify(xmlhttp.responseText);
closeInfoBox(); closeInfoBox();
// called from prefs, reload tab // called from prefs, reload tab
if (active_tab) { if (active_tab) {
selectTab(active_tab, false); selectTab(active_tab, false);
} }
notify(xmlhttp.responseText);
} }
} }
@ -1024,29 +1026,11 @@ function qaddFilter() {
return return
} }
var regexp = document.getElementById("fadd_regexp"); var query = Form.serialize("filter_add_form");
var match = document.getElementById("fadd_match");
var feed = document.getElementById("fadd_feed");
var action = document.getElementById("fadd_action");
if (regexp.value.length == 0) {
alert("Missing filter expression.");
} else {
notify("Adding filter...");
var v_match = match[match.selectedIndex].text; xmlhttp.open("GET", "backend.php?" + query, true);
var feed_id = feed[feed.selectedIndex].id; xmlhttp.onreadystatechange=infobox_submit_callback;
var action_id = action[action.selectedIndex].id; xmlhttp.send(null);
xmlhttp.open("GET", "backend.php?op=pref-filters&quiet=1&subop=add&regexp=" +
param_escape(regexp.value) + "&match=" + v_match +
"&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
xmlhttp.onreadystatechange=infobox_submit_callback;
xmlhttp.send(null);
regexp.value = "";
}
} }

@ -653,7 +653,7 @@
} }
function print_select($id, $default, $values, $attributes = "") { function print_select($id, $default, $values, $attributes = "") {
print "<select id=\"$id\" $attributes>"; print "<select name=\"$id\" id=\"$id\" $attributes>";
foreach ($values as $v) { foreach ($values as $v) {
if ($v == $default) if ($v == $default)
$sel = " selected"; $sel = " selected";
@ -665,8 +665,8 @@
print "</select>"; print "</select>";
} }
function print_select_hash($id, $values, $default, $attributes = "") { function print_select_hash($id, $default, $values, $attributes = "") {
print "<select id='$id' $attributes>"; print "<select name=\"$id\" id='$id' $attributes>";
foreach (array_keys($values) as $v) { foreach (array_keys($values) as $v) {
if ($v == $default) if ($v == $default)
$sel = "selected"; $sel = "selected";
@ -1582,9 +1582,9 @@
function print_feed_select($link, $id, $default_id = "", function print_feed_select($link, $id, $default_id = "",
$attributes = "", $include_all_feeds = true) { $attributes = "", $include_all_feeds = true) {
print "<select id=\"$id\" $attributes>"; print "<select id=\"$id\" name=\"$id\" $attributes>";
if ($include_all_feeds) { if ($include_all_feeds) {
print "<option id=\"0\">All feeds</option>"; print "<option value=\"0\">All feeds</option>";
} }
$result = db_query($link, "SELECT id,title FROM ttrss_feeds $result = db_query($link, "SELECT id,title FROM ttrss_feeds
@ -1600,7 +1600,7 @@
} else { } else {
$is_selected = ""; $is_selected = "";
} }
printf("<option $is_selected id='%d'>%s</option>", printf("<option $is_selected value='%d'>%s</option>",
$line["id"], db_unescape_string($line["title"])); $line["id"], db_unescape_string($line["title"]));
} }
@ -1610,7 +1610,7 @@
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 name=\"$id\" $attributes>"; print "<select id=\"$id\" name=\"$id\" $attributes>";
if ($include_all_cats) { if ($include_all_cats) {
print "<option value=\"0\">Uncategorized</option>"; print "<option value=\"0\">Uncategorized</option>";

@ -1313,7 +1313,7 @@ function categorizeSelectedFeeds() {
var sel_rows = getSelectedFeeds(); var sel_rows = getSelectedFeeds();
var cat_sel = document.getElementById("sfeed_set_fcat"); var cat_sel = document.getElementById("sfeed_set_fcat");
var cat_id = cat_sel[cat_sel.selectedIndex].id; var cat_id = cat_sel[cat_sel.selectedIndex].value;
if (sel_rows.length > 0) { if (sel_rows.length > 0) {

@ -278,14 +278,14 @@ 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;
} */ background-color : #f0fff0;
}
input.iedit { input.iedit {
width : 100%; width : 100%;
@ -1099,4 +1099,7 @@ div.noDaemonWarning {
width : 100%; width : 100%;
} }
form {
margin : 0px;
padding : 0px;
}

Loading…
Cancel
Save