use popup feedbrowser for main UI (2)
This commit is contained in:
parent
b56465dd56
commit
c2913898f1
24
functions.js
24
functions.js
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -503,6 +503,23 @@
|
|||
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>";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -64,33 +64,41 @@
|
|||
|
||||
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'
|
||||
|
@ -1433,10 +1441,20 @@
|
|||
|
||||
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");
|
||||
AND owner_uid = '$owner_uid') $search_qpart
|
||||
ORDER BY subscribers DESC LIMIT $limit");
|
||||
|
||||
$feedctr = 0;
|
||||
|
||||
|
|
22
prefs.js
22
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() {
|
||||
|
||||
|
|
71
tt-rss.js
71
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue