]> git.wh0rd.org Git - tt-rss.git/commitdiff
use popup feedbrowser for main UI (2)
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 24 Jan 2009 05:01:17 +0000 (06:01 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 24 Jan 2009 05:01:17 +0000 (06:01 +0100)
functions.js
modules/backend-rpc.php
modules/pref-feeds.php
prefs.js
tt-rss.js

index 0e9ec02a162db1642a124f25246274ee4c018aff..35ca9e77f04e6b2a0337bcc9677784958a4728ec 100644 (file)
@@ -2015,3 +2015,27 @@ function labelFieldsCheck(elem) {
 
        }
 }
+
+function getSelectedFeedsFromBrowser() {
+
+       var list = document.getElementById("browseFeedList");
+       if (!list) list = document.getElementById("browseBigFeedList");
+
+       var selected = new Array();
+       
+       for (i = 0; i < list.childNodes.length; i++) {
+               var child = list.childNodes[i];
+               if (child.id && child.id.match("FBROW-")) {
+                       var id = child.id.replace("FBROW-", "");
+                       
+                       var cb = document.getElementById("FBCHK-" + id);
+
+                       if (cb.checked) {
+                               selected.push(id);
+                       }
+               }
+       }
+
+       return selected;
+}
+
index b26304c2b79ec31dcb5c551e62ebfaa98a13466b..855d54aa79030a421dfbdec12a69bd5ebab8c65b 100644 (file)
                        return;
                }
 
+               if ($subop == "feedBrowser") {
+
+                       $search = db_escape_string($_REQUEST["search"]);
+                       $limit = db_escape_string($_REQUEST["limit"]);
+
+                       print "<rpc-reply>";
+                       print "<content>";
+                       print "<![CDATA[";
+                       $ctr = print_feed_browser($link, $search, $limit);
+                       print "]]>";
+                       print "</content>";
+                       print "<num-results value=\"$ctr\"/>";
+                       print "</rpc-reply>";
+
+                       return;
+               }
+
                print "<rpc-reply><error>Unknown method: $subop</error></rpc-reply>";
        }
 ?>
index 0bdaf4e5535b3cb4d13e02af2b563c633d3efb9d..6c80d69a3b98988ea105f277c95bbd5d0c3c9672 100644 (file)
                        
                        print "<div class=\"infoBoxContents\">";
 
-
                        $browser_search = db_escape_string($_GET["search"]);
 
-                       if (array_key_exists("search", $_GET)) {
-                               $_SESSION["feed_browser_search"] = $browser_search;
-                               } else {
-                               $browser_search = $_SESSION["feed_browser_search"];
-                       }
-
                        //print "<p>".__("Showing top 25 registered feeds, sorted by popularity:")."</p>";
-                       print "<input id=\"feed_browser_search\" size=\"20\" type=\"search\"
+
+                       print "
+                               <div style='float : right'>
+                               <input id=\"feed_browser_search\" size=\"20\" type=\"search\"
                                onfocus=\"javascript:disableHotkeys();\" 
                                onblur=\"javascript:enableHotkeys();\"
                                onchange=\"javascript:updateFeedBrowser()\" value=\"$browser_search\">
                        <input type=\"submit\" class=\"button\" 
-                               onclick=\"javascript:updateFeedBrowser()\" value=\"".__('Search')."\">";
+                               onclick=\"javascript:updateFeedBrowser()\" value=\"".__('Search')."\">
+                       </div>";
+
+                       print __('Top')." <select id=\"feed_browser_limit\">";
+
+                       foreach (array(25, 50, 100, 200) as $l) {
+                               $issel = ($l == $limit) ? "selected" : "";
+                               print "<option $issel>$l</option>";
+                       }
+                       
+                       print "</select>
+                               <input type=\"submit\" class=\"button\"
+                                       onclick=\"updateFeedBrowser()\" value=\"".__('Show')."\">";
 
                        print "<p>";
 
                        $owner_uid = $_SESSION["uid"];
 
                        print "<ul class='browseFeedList' id='browseFeedList'>";
-                       $subscribe_btn_disabled = print_feed_browser($link, $search, $limit) == 0 ? "disabled" : "";
+                       $subscribe_btn_disabled = print_feed_browser($link, $search, 25) == 0 ? "disabled" : "";
                        print "</ul>";
 
                        print "<div align='center'>
-                               <input type=\"submit\" class=\"button\" 
+                               <input type=\"submit\" class=\"button\" id=\"feed_browser_subscribe\"
                                $subscribe_btn_disabled
                                onclick=\"feedBrowserSubscribe()\" value=\"".__('Subscribe')."\">
                                <input type='submit' class='button'                     
 
        function print_feed_browser($link, $search, $limit) {
 
+                       $owner_uid = $_SESSION["uid"];
+
+                       if ($search) {
+                               $search_qpart = "AND (UPPER(feed_url) LIKE UPPER('%$search%') OR 
+                                       UPPER(title) LIKE UPPER('%$search%'))";
+                       } else {
+                               $search_qpart = "";
+                       }
+
                        $result = db_query($link, "SELECT feed_url, subscribers FROM
                                ttrss_feedbrowser_cache WHERE (SELECT COUNT(id) = 0 FROM ttrss_feeds AS tf
-                               WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url 
-                               AND owner_uid = '$owner_uid') ORDER BY subscribers DESC LIMIT 25");
+                               WHERE tf.feed_url = ttrss_feedbrowser_cache.feed_url
+                               AND owner_uid = '$owner_uid') $search_qpart 
+                               ORDER BY subscribers DESC LIMIT $limit");
 
                        $feedctr = 0;
                        
index 611ea6c17c19697d78c0508e2ee97f037e2c8f5b..266703f6454e047e19f80567520761c3ac62775c 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -550,28 +550,6 @@ function getSelectedFeedCats() {
        return getSelectedTableRowIds("prefFeedCatList", "FCATR");
 }
 
-function getSelectedFeedsFromBrowser() {
-
-       var list = document.getElementById("browseFeedList");
-       if (!list) list = document.getElementById("browseBigFeedList");
-
-       var selected = new Array();
-       
-       for (i = 0; i < list.childNodes.length; i++) {
-               var child = list.childNodes[i];
-               if (child.id && child.id.match("FBROW-")) {
-                       var id = child.id.replace("FBROW-", "");
-                       
-                       var cb = document.getElementById("FBCHK-" + id);
-
-                       if (cb.checked) {
-                               selected.push(id);
-                       }
-               }
-       }
-
-       return selected;
-}
 
 function removeSelectedLabels() {
 
index ba7fbc64d1dd6c8865dcc6d0fdf4896d3d9d47fe..0bcf20cf2d25f0c1fc0792a060f2660d9b9fcf82 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1443,10 +1443,77 @@ function browseFeeds(limit) {
 }
 
 function updateFeedBrowser() {
-       alert("FIXME");
+       try {
+
+               var query = "backend.php?op=rpc&subop=feedBrowser";
+
+               var search = document.getElementById("feed_browser_search");
+               var limit = document.getElementById("feed_browser_limit");
+
+               if (limit) {
+                       query = query + "&limit=" + limit[limit.selectedIndex].value;
+               }
+
+               if (search) {
+                       query = query + "&search=" + param_escape(search.value);
+               }
+
+               notify_progress("Loading, please wait...", true);
+
+               new Ajax.Request(query, {
+                       onComplete: function(transport) { 
+                               notify('');
+
+                               var c = document.getElementById("browseFeedList");
+                               var r = transport.responseXML.getElementsByTagName("content")[0];
+                               var nr = transport.responseXML.getElementsByTagName("num-results")[0];
+                               var sb = document.getElementById("feed_browser_subscribe");
+
+                               if (c && r) {
+                                       c.innerHTML = r.firstChild.nodeValue;
+                               }
+       
+                               if (nr && sb) {
+                                       if (nr.getAttribute("value") > 0) {
+                                               sb.disabled = false;
+                                       } else {
+                                               sb.disabled = true;
+                                       }
+                               }
+
+                       } });
+
+
+       } catch (e) {
+               exception_error("updateFeedBrowser", e);
+       }
 }
 
+
 function feedBrowserSubscribe() {
-       alert("FIXME");
+       try {
+
+               var selected = getSelectedFeedsFromBrowser();
+
+               if (selected.length > 0) {
+                       closeInfoBox();
+
+                       notify_progress("Loading, please wait...", true);
+
+                       var query =  "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
+                               param_escape(selected.toString());
 
+                       new Ajax.Request(query, {
+                               onComplete: function(transport) { 
+                                       updateFeedList();
+                               } });
+
+               } else {
+                       alert(__("No feeds are selected."));
+               }
+
+       } catch (e) {
+               exception_error("feedBrowserSubscribe", e);
+       }
 }
+