]> git.wh0rd.org - tt-rss.git/commitdiff
quick action to add filter, misc backend improvements
authorAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Dec 2005 19:48:13 +0000 (20:48 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Fri, 9 Dec 2005 19:48:13 +0000 (20:48 +0100)
backend.php
functions.js
tt-rss.js
tt-rss.php

index b1c57c3a920c0aec2c03cb8a59399175591da138..a31afb61bae85228c38f4066bd283f27779d92d8 100644 (file)
        if ($op == "pref-feeds") {
        
                $subop = $_GET["subop"];
+               $quiet = $_GET["quiet"];
 
                if ($subop == "editSave") {
                        $feed_title = db_escape_string($_GET["t"]);
 
                }
 
+               if ($quiet) return;
+
 //             print "<h3>Edit Feeds</h3>";
 
                $result = db_query($link, "SELECT id,title,feed_url,last_error 
        if ($op == "pref-filters") {
 
                $subop = $_GET["subop"];
+               $quiet = $_GET["quiet"];
 
                if ($subop == "editSave") {
 
                        } 
                }
 
+               if ($quiet) return;
+
                $result = db_query($link, "SELECT description 
                        FROM ttrss_filter_types ORDER BY description");
 
 
                }
 
+               if ($id == "quickAddFilter") {
+
+                       $result = db_query($link, "SELECT description 
+                               FROM ttrss_filter_types ORDER BY description");
+       
+                       $filter_types = array();
+       
+                       while ($line = db_fetch_assoc($result)) {
+                               array_push($filter_types, $line["description"]);
+                       }
+
+                       print "<table>";
+
+                       print "<tr><td>Match:</td><td><input id=\"fadd_regexp\" size=\"40\">&nbsp;";
+                       
+                       print_select("fadd_match", "Title", $filter_types);     
+       
+                       print "</td></tr>";
+                       print "<tr><td>Feed:</td><td><select id=\"fadd_feed\">";
+       
+                       print "<option selected id=\"0\">All feeds</option>";
+       
+                       $result = db_query($link, "SELECT id,title FROM ttrss_feeds
+                               WHERE owner_uid = ".$_SESSION["uid"]." ORDER BY title");
+       
+                       if (db_num_rows($result) > 0) {
+                               print "<option disabled>--------</option>";
+                       }
+       
+                       while ($line = db_fetch_assoc($result)) {
+                               if ($param == $line["id"]) {
+                                       $selected = "selected";
+                               } else {
+                                       $selected = "";
+                               }
+                               printf("<option id='%d' %s>%s</option>", $line["id"], $selected, $line["title"]);
+                       }
+       
+                       print "</select></td></tr>";
+       
+                       print "<tr><td>Action:</td>";
+       
+                       print "<td><select id=\"fadd_action\">";
+       
+                       $result = db_query($link, "SELECT id,description FROM ttrss_filter_actions 
+                               ORDER BY name");
+
+                       while ($line = db_fetch_assoc($result)) {
+                               printf("<option id='%d'>%s</option>", $line["id"], $line["description"]);
+                       }
+       
+                       print "</select>";
+       
+                       print "</td></tr><tr><td colspan=\"2\" align=\"right\">";
+       
+                       print "<input type=\"submit\" 
+                               class=\"button\" onclick=\"javascript:qaddFilter()\" 
+                               value=\"Add filter\"> ";
+
+                       print "<input class=\"button\"
+                               type=\"submit\" onclick=\"javascript:closeDlg()\" 
+                               value=\"Close\">";
+
+                       print "</td></tr></table>";
+               }
        }
 
        // update feeds of all users, may be used anonymously
index 17cab9d7617a554f375570c6f40c2c2d497e4868..d901cbb90f88c27f3e776286f4a76c2716d2ad31 100644 (file)
@@ -689,3 +689,4 @@ function showBlockElement(id) {
        } 
 }
 
+
index bb0f13c7900fd9af0890a7f78046ddc34da825a2..c8e1c3e3f1eca7fa475118d39cbe319a236a5107 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -46,12 +46,20 @@ function toggleTags() {
 
 function dlg_frefresh_callback() {
        if (xmlhttp.readyState == 4) {
+               notify(xmlhttp.responseText);
                updateFeedList(false, false);
                closeDlg();
        } 
 }
 
-function dialog_refresh_callback() {
+function dlg_submit_callback() {
+       if (xmlhttp.readyState == 4) {
+               notify(xmlhttp.responseText);
+               closeDlg();
+       } 
+}
+
+function dlg_display_callback() {
        if (xmlhttp.readyState == 4) {
                var dlg = document.getElementById("userDlg");
                var dlg_s = document.getElementById("userDlgShadow");
@@ -450,6 +458,10 @@ function quickMenuGo() {
                return;
        }
 
+       if (opid == "qmcAddFilter") {
+               displayDlg("quickAddFilter", getActiveFeedId());
+       }
+
 }
 
 function qafAdd() {
@@ -470,7 +482,7 @@ function qafAdd() {
 
                feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
 
-               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
+               xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" +
                        param_escape(link.value), true);
                xmlhttp.onreadystatechange=dlg_frefresh_callback;
                xmlhttp.send(null);
@@ -480,13 +492,47 @@ function qafAdd() {
        }
 }
 
+function qaddFilter() {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       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) {
+               notify("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&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=dlg_submit_callback;
+               xmlhttp.send(null);
+
+               regexp.value = "";
+       }
+
+}
+
+
 function displayDlg(id, param) {
 
        notify("");
 
        xmlhttp.open("GET", "backend.php?op=dlg&id=" +
                param_escape(id) + "&param=" + param_escape(param), true);
-       xmlhttp.onreadystatechange=dialog_refresh_callback;
+       xmlhttp.onreadystatechange=dlg_display_callback;
        xmlhttp.send(null);
 
 }
index 89feb8571f6fc7d33369bbf7ec18161f527463b2..5c15a507baa3f6aa830bd62801ff1958ce81cfc3 100644 (file)
                                <option id="qmcPrefs" selected>Preferences...</option>
                                <option disabled>--------</option>
                                <option style="color : #5050aa" disabled>Feed actions:</option>
-                               <option id="qmcAddFeed">&nbsp;&nbsp;Add new feed</option>
-                               <option id="qmcRemoveFeed">&nbsp;&nbsp;Remove this feed</option>
+                               <option id="qmcAddFeed">&nbsp;&nbsp;Add new feed...</option>
+                               <option id="qmcRemoveFeed">&nbsp;&nbsp;Remove this feed...</option>
                                <!-- <option>Edit this feed</option> -->
                                <option disabled>--------</option>
                                <option style="color : #5050aa" disabled>All feeds:</option>
                                <option id="qmcUpdateFeeds">&nbsp;&nbsp;Update</option>
                                <option id="qmcCatchupAll">&nbsp;&nbsp;Mark as read</option>
                                <option id="qmcShowOnlyUnread">&nbsp;&nbsp;Show only unread</option>
+                               <option disabled>--------</option>
+                               <option style="color : #5050aa" disabled>Other actions:</option>                                
+                               <option id="qmcAddFilter">&nbsp;&nbsp;Add filter...</option>
                        </select>
                        <input type="submit" class="button" onclick="quickMenuGo()" value="Go">
                </td>