From d0da85c27c2a97173dd997f7f2a29f09556698ed Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 13 Dec 2008 12:57:53 +0100 Subject: [PATCH] preliminary UI work on date checking filter (refs #225) --- functions.js | 82 ++++++++++++++++++++++++++++++++++++++++ modules/backend-rpc.php | 18 +++++++++ modules/popup-dialog.php | 17 ++++++++- sanity_check.php | 2 +- 4 files changed, 116 insertions(+), 3 deletions(-) diff --git a/functions.js b/functions.js index 77c5c13b..9456a6a2 100644 --- a/functions.js +++ b/functions.js @@ -1523,6 +1523,39 @@ function getFeedName(id, is_cat) { } } +function filterDlgCheckType(sender) { + + try { + + var ftype = sender[sender.selectedIndex].value; + + var form = document.forms["filter_add_form"]; + + if (!form) { + form = document.forms["filter_edit_form"]; + } + + if (!form) { + debug("filterDlgCheckType: can't find form!"); + return; + } + + // if selected filter type is 5 (Date) enable the modifier dropbox + if (ftype == 5) { + Element.show("filter_dlg_date_mod_box"); + Element.show("filter_dlg_date_chk_box"); + } else { + Element.hide("filter_dlg_date_mod_box"); + Element.hide("filter_dlg_date_chk_box"); + + } + + } catch (e) { + exception_error("filterDlgCheckType", e); + } + +} + function filterDlgCheckAction(sender) { try { @@ -1560,6 +1593,55 @@ function filterDlgCheckAction(sender) { } +function filterDlgCheckDate() { + try { + var form = document.forms["filter_add_form"]; + + if (!form) { + form = document.forms["filter_edit_form"]; + } + + if (!form) { + debug("filterDlgCheckAction: can't find form!"); + return; + } + + var reg_exp = form.reg_exp.value; + + var query = "backend.php?op=rpc&subop=checkDate&date=" + reg_exp; + + new Ajax.Request(query, { + onComplete: function(transport) { + + var form = document.forms["filter_add_form"]; + + if (!form) { + form = document.forms["filter_edit_form"]; + } + + if (transport.responseXML) { + var result = transport.responseXML.getElementsByTagName("result")[0]; + + if (result && result.firstChild) { + if (result.firstChild.nodeValue == "1") { + + new Effect.Highlight(form.reg_exp, {startcolor : '#00ff00'}); + + return; + } + } + } + + new Effect.Highlight(form.reg_exp, {startcolor : '#ff0000'}); + + } }); + + + } catch (e) { + exception_error("filterDlgCheckDate", e); + } +} + function explainError(code) { return displayDlg("explainError", code); } diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index 2b3fe872..75e4f946 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -429,6 +429,24 @@ return; } + if ($subop == "checkDate") { + + $date = db_escape_string($_REQUEST["date"]); + $date_parsed = strtotime($date); + + print ""; + + if ($date_parsed) { + print "1"; + } else { + print "0"; + } + + print ""; + + return; + } + print "Unknown method: $subop"; } ?> diff --git a/modules/popup-dialog.php b/modules/popup-dialog.php index f86dd3db..ea74eb58 100644 --- a/modules/popup-dialog.php +++ b/modules/popup-dialog.php @@ -358,13 +358,26 @@ print "
"; + print ""; + print " "; + print ""; - print " " . __("on field") . " "; - print_select_hash("filter_type", 1, $filter_types); + print ""; + print " "; + print ""; + + print "
" . __("on field") . " "; + print_select_hash("filter_type", 1, $filter_types, + 'onchange="filterDlgCheckType(this)"'); print "
"; diff --git a/sanity_check.php b/sanity_check.php index e84fb9f8..16819fa6 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -2,7 +2,7 @@ require_once "functions.php"; define('EXPECTED_CONFIG_VERSION', 17); - define('SCHEMA_VERSION', 45); + define('SCHEMA_VERSION', 46); if (!file_exists("config.php")) { print __("Fatal Error: You forgot to copy -- 2.39.2