]> git.wh0rd.org Git - tt-rss.git/commitdiff
preliminary UI work on date checking filter (refs #225)
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 13 Dec 2008 11:57:53 +0000 (12:57 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 13 Dec 2008 11:57:53 +0000 (12:57 +0100)
functions.js
modules/backend-rpc.php
modules/popup-dialog.php
sanity_check.php

index 77c5c13b12e96ab8453de8101632bcd60a33668f..9456a6a25f9d8256d79126c116cff3e874483b69 100644 (file)
@@ -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);
 }
index 2b3fe8726d128b027b16b835cf7941bef2a1fb7d..75e4f946ed2f093839eafa568223d40850360a5a 100644 (file)
                        return;
                }
 
+               if ($subop == "checkDate") {
+
+                       $date = db_escape_string($_REQUEST["date"]);
+                       $date_parsed = strtotime($date);
+
+                       print "<rpc-reply>";
+
+                       if ($date_parsed) {
+                               print "<result>1</result>";
+                       } else {
+                               print "<result>0</result>";
+                       }
+
+                       print "</rpc-reply>";
+
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>
index f86dd3db0551d207e9166b0e27663651434e7d66..ea74eb583e76ccdb7fc002671313207b86994469 100644 (file)
 
                        print "<div class=\"dlgSecCont\">";
 
+                       print "<span id=\"filter_dlg_date_mod_box\" style=\"display : none\">";
+                       print "<select name=\"filter_date_modifier\">";
+                       print "<option name=\"before\">".__('Before')."</option>";
+                       print "<option name=\"after\">".__('After')."</option>";
+                       print "</select>&nbsp;</span>";
+
                        print "<input onkeypress=\"return filterCR(event, createFilter)\"
                                         onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
                                         onchange=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
                                         name=\"reg_exp\" size=\"30\" value=\"$reg_exp\">";
 
-                       print " " . __("on field") . " ";
-                       print_select_hash("filter_type", 1, $filter_types);
+                       print "<span id=\"filter_dlg_date_chk_box\" style=\"display : none\">";                 
+                       print "&nbsp;<input class=\"button\"
+                               type=\"submit\" onclick=\"return filterDlgCheckDate()\" 
+                               value=\"".__('Check Date')."\">";
+                       print "</span>";
+
+                       print "<br/> " . __("on field") . " ";
+                       print_select_hash("filter_type", 1, $filter_types,
+                               'onchange="filterDlgCheckType(this)"');
 
                        print "<br/>";
 
index e84fb9f86b5d450ae23ac3cf3e45db0c30c34edf..16819fa6ab530adbf627cadd0308e3020278f263 100644 (file)
@@ -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 __("<b>Fatal Error</b>: You forgot to copy