From: Andrew Dolgov Date: Thu, 17 Aug 2006 04:54:57 +0000 (+0100) Subject: create label now uses dialog, code cleanups X-Git-Tag: schema_freeze_for_1.2.2_(take_2)~30 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=f156fd00ee99338d1824d20f65f0fe30d03c4f9e;p=tt-rss.git create label now uses dialog, code cleanups --- diff --git a/backend.php b/backend.php index 7155846b..8b31297f 100644 --- a/backend.php +++ b/backend.php @@ -2395,22 +2395,21 @@ if (!WEB_DEMO_MODE) { // 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, "INSERT INTO ttrss_labels (sql_exp,description,owner_uid) - VALUES ('$exp', '$exp', '".$_SESSION["uid"]."')"); + VALUES ('$sql_exp', '$description', '".$_SESSION["uid"]."')"); } } - print "
-  "; - + print "
"; + print"
"; + id=\"label_create_btn\" + onclick=\"return displayDlg('quickAddLabel', false)\" + value=\"Create label\">
"; $result = db_query($link, "SELECT id,sql_exp,description @@ -2665,6 +2664,52 @@ } + if ($id == "quickAddLabel") { + print "
Create label
"; + print "
"; + + print "
"; + + print ""; + print ""; + + print ""; + + print " + "; + + print "
Caption:"; + + print "
+

SQL Expression:

"; + + print ""; + + print "
"; + + print "
"; + + print "
"; + + print "
"; + + print " + "; + + print " "; + + print ""; + } + if ($id == "quickAddFilter") { $active_feed_id = db_escape_string($_GET["param"]); diff --git a/prefs.js b/prefs.js index 28e54ee4..2ac772fc 100644 --- a/prefs.js +++ b/prefs.js @@ -63,8 +63,8 @@ function filterlist_callback() { function labellist_callback() { var container = document.getElementById('prefContent'); if (xmlhttp.readyState == 4) { + closeInfoBox(); container.innerHTML=xmlhttp.responseText; - if (active_label) { var row = document.getElementById("LILRR-" + active_label); if (row) { @@ -181,55 +181,26 @@ function addLabel() { return } - var sqlexp = document.getElementById("ladd_expr"); - - if (sqlexp.value.length == 0) { - alert("Can't add label: missing SQL expression."); - } else { - notify("Adding label..."); + var form = document.forms['label_edit_form']; - xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" + - param_escape(sqlexp.value), true); - - xmlhttp.onreadystatechange=labellist_callback; - xmlhttp.send(null); + var sql_exp = form.sql_exp.value; + var description = form.description.value; - sqlexp.value = ""; + if (sql_exp == "") { + alert("Can't create label: missing SQL expression."); + return false; } -} - -function addFilter() { - - if (!xmlhttp_ready(xmlhttp)) { - printLockingError(); - return + if (description == "") { + alert("Can't create label: missing caption."); + return false; } - var regexp = document.getElementById("fadd_regexp"); - 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 = ""; - } + var query = Form.serialize("label_edit_form"); + xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true); + xmlhttp.onreadystatechange=infobox_submit_callback; + xmlhttp.send(null); } function addFeed() { @@ -315,6 +286,8 @@ function editLabel(id) { return } + document.getElementById("label_create_btn").disabled = true; + active_label = id; selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false); @@ -709,6 +682,8 @@ function labelEditCancel() { return } + document.getElementById("label_create_btn").disabled = false; + active_label = false; selectPrefRows('label', false); // cleanup feed selection