create label now uses dialog, code cleanups
This commit is contained in:
parent
60a2080f9a
commit
f156fd00ee
63
backend.php
63
backend.php
|
@ -2395,22 +2395,21 @@
|
||||||
if (!WEB_DEMO_MODE) {
|
if (!WEB_DEMO_MODE) {
|
||||||
|
|
||||||
// no escaping is done here on purpose
|
// no escaping is done here on purpose
|
||||||
$exp = trim($_GET["exp"]);
|
$sql_exp = trim($_GET["sql_exp"]);
|
||||||
|
$description = db_escape_string($_GET["description"]);
|
||||||
|
|
||||||
$result = db_query($link,
|
$result = db_query($link,
|
||||||
"INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
|
"INSERT INTO ttrss_labels (sql_exp,description,owner_uid)
|
||||||
VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')");
|
VALUES ('$sql_exp', '$description', '".$_SESSION["uid"]."')");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print "<div class=\"prefGenericAddBox\">
|
print "<div class=\"prefGenericAddBox\">";
|
||||||
<input size=\"40\"
|
|
||||||
onkeyup=\"toggleSubmitNotEmpty(this, 'label_create_btn')\"
|
|
||||||
id=\"ladd_expr\"> ";
|
|
||||||
|
|
||||||
print"<input type=\"submit\" class=\"button\"
|
print"<input type=\"submit\" class=\"button\"
|
||||||
disabled=\"true\" id=\"label_create_btn\"
|
id=\"label_create_btn\"
|
||||||
onclick=\"javascript:addLabel()\" value=\"Create label\"></div>";
|
onclick=\"return displayDlg('quickAddLabel', false)\"
|
||||||
|
value=\"Create label\"></div>";
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
id,sql_exp,description
|
id,sql_exp,description
|
||||||
|
@ -2665,6 +2664,52 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($id == "quickAddLabel") {
|
||||||
|
print "<div id=\"infoBoxTitle\">Create label</div>";
|
||||||
|
print "<div class=\"infoBoxContents\">";
|
||||||
|
|
||||||
|
print "<form id=\"label_edit_form\">";
|
||||||
|
|
||||||
|
print "<input type=\"hidden\" name=\"op\" value=\"pref-labels\">";
|
||||||
|
print "<input type=\"hidden\" name=\"subop\" value=\"add\">";
|
||||||
|
|
||||||
|
print "<table width='100%'>";
|
||||||
|
|
||||||
|
print "<tr><td>Caption:</td>
|
||||||
|
<td><input onkeypress=\"return filterCR(event)\"
|
||||||
|
onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
|
||||||
|
name=\"description\" class=\"iedit\">";
|
||||||
|
|
||||||
|
print "</td></tr>";
|
||||||
|
|
||||||
|
print "<tr><td colspan=\"2\">
|
||||||
|
<p>SQL Expression:</p>";
|
||||||
|
|
||||||
|
print "<textarea onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
|
||||||
|
rows=\"4\" name=\"sql_exp\" class=\"iedit\"></textarea>";
|
||||||
|
|
||||||
|
print "</td></tr></table>";
|
||||||
|
|
||||||
|
print "</form>";
|
||||||
|
|
||||||
|
print "<div style=\"display : none\" id=\"label_test_result\"></div>";
|
||||||
|
|
||||||
|
print "<div align='right'>";
|
||||||
|
|
||||||
|
print "<input type=\"submit\" onclick=\"labelTest()\" value=\"Test\">
|
||||||
|
";
|
||||||
|
|
||||||
|
print "<input type=\"submit\"
|
||||||
|
id=\"infobox_submit\"
|
||||||
|
disabled=\"true\"
|
||||||
|
class=\"button\" onclick=\"return addLabel()\"
|
||||||
|
value=\"Create\"> ";
|
||||||
|
|
||||||
|
print "<input class=\"button\"
|
||||||
|
type=\"submit\" onclick=\"return labelEditCancel()\"
|
||||||
|
value=\"Cancel\">";
|
||||||
|
}
|
||||||
|
|
||||||
if ($id == "quickAddFilter") {
|
if ($id == "quickAddFilter") {
|
||||||
|
|
||||||
$active_feed_id = db_escape_string($_GET["param"]);
|
$active_feed_id = db_escape_string($_GET["param"]);
|
||||||
|
|
61
prefs.js
61
prefs.js
|
@ -63,8 +63,8 @@ function filterlist_callback() {
|
||||||
function labellist_callback() {
|
function labellist_callback() {
|
||||||
var container = document.getElementById('prefContent');
|
var container = document.getElementById('prefContent');
|
||||||
if (xmlhttp.readyState == 4) {
|
if (xmlhttp.readyState == 4) {
|
||||||
|
closeInfoBox();
|
||||||
container.innerHTML=xmlhttp.responseText;
|
container.innerHTML=xmlhttp.responseText;
|
||||||
|
|
||||||
if (active_label) {
|
if (active_label) {
|
||||||
var row = document.getElementById("LILRR-" + active_label);
|
var row = document.getElementById("LILRR-" + active_label);
|
||||||
if (row) {
|
if (row) {
|
||||||
|
@ -181,55 +181,26 @@ function addLabel() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var sqlexp = document.getElementById("ladd_expr");
|
var form = document.forms['label_edit_form'];
|
||||||
|
|
||||||
if (sqlexp.value.length == 0) {
|
var sql_exp = form.sql_exp.value;
|
||||||
alert("Can't add label: missing SQL expression.");
|
var description = form.description.value;
|
||||||
} else {
|
|
||||||
notify("Adding label...");
|
|
||||||
|
|
||||||
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
|
if (sql_exp == "") {
|
||||||
param_escape(sqlexp.value), true);
|
alert("Can't create label: missing SQL expression.");
|
||||||
|
return false;
|
||||||
xmlhttp.onreadystatechange=labellist_callback;
|
|
||||||
xmlhttp.send(null);
|
|
||||||
|
|
||||||
sqlexp.value = "";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
if (description == "") {
|
||||||
|
alert("Can't create label: missing caption.");
|
||||||
function addFilter() {
|
return false;
|
||||||
|
|
||||||
if (!xmlhttp_ready(xmlhttp)) {
|
|
||||||
printLockingError();
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var regexp = document.getElementById("fadd_regexp");
|
var query = Form.serialize("label_edit_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("Can't add filter: missing filter expression.");
|
|
||||||
} else {
|
|
||||||
notify("Adding filter...");
|
|
||||||
|
|
||||||
var v_match = match[match.selectedIndex].text;
|
|
||||||
var feed_id = feed[feed.selectedIndex].id;
|
|
||||||
var action_id = action[action.selectedIndex].id;
|
|
||||||
|
|
||||||
xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
|
|
||||||
param_escape(regexp.value) + "&match=" + v_match +
|
|
||||||
"&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
|
|
||||||
|
|
||||||
xmlhttp.onreadystatechange=filterlist_callback;
|
|
||||||
xmlhttp.send(null);
|
|
||||||
|
|
||||||
regexp.value = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);
|
||||||
|
xmlhttp.onreadystatechange=infobox_submit_callback;
|
||||||
|
xmlhttp.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function addFeed() {
|
function addFeed() {
|
||||||
|
@ -315,6 +286,8 @@ function editLabel(id) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById("label_create_btn").disabled = true;
|
||||||
|
|
||||||
active_label = id;
|
active_label = id;
|
||||||
|
|
||||||
selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
|
selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
|
||||||
|
@ -709,6 +682,8 @@ function labelEditCancel() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.getElementById("label_create_btn").disabled = false;
|
||||||
|
|
||||||
active_label = false;
|
active_label = false;
|
||||||
|
|
||||||
selectPrefRows('label', false); // cleanup feed selection
|
selectPrefRows('label', false); // cleanup feed selection
|
||||||
|
|
Loading…
Reference in New Issue