search dialog improvements, main toolbar overhaul

This commit is contained in:
Andrew Dolgov 2006-05-21 05:28:51 +01:00
parent ea0e4caf80
commit 86b682ce2f
7 changed files with 223 additions and 124 deletions

View file

@ -146,7 +146,9 @@
$script_dt_add = get_script_dt_add();
print "<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
print "
<script type=\"text/javascript\" src=\"prototype.js\"></script>
<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
<script type=\"text/javascript\" src=\"feedlist.js?$script_dt_add\"></script>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<!--[if gte IE 5.5000]>
@ -552,7 +554,9 @@
$script_dt_add = get_script_dt_add();
print "<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
print "
<script type=\"text/javascript\" src=\"prototype.js\"></script>
<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
</head><body $rtl_tag>";
@ -673,15 +677,12 @@
if ($op == "viewfeed") {
$feed = db_escape_string($_GET["feed"]);
$skip = db_escape_string($_GET["skip"]);
$subop = db_escape_string($_GET["subop"]);
$view_mode = db_escape_string($_GET["view"]);
$view_mode = db_escape_string($_GET["view_mode"]);
$limit = db_escape_string($_GET["limit"]);
$cat_view = db_escape_string($_GET["cat"]);
$next_unread_feed = db_escape_string($_GET["nuf"]);
if (!$skip) $skip = 0;
if ($subop == "undefined") $subop = "";
print "<html><head>
@ -741,6 +742,7 @@
$script_dt_add = get_script_dt_add();
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
<script type=\"text/javascript\" src=\"prototype.js\"></script>
<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
<script type=\"text/javascript\" src=\"viewfeed.js?$script_dt_add\"></script>
<!--[if gte IE 5.5000]>
@ -755,19 +757,33 @@
window.onload = init;
</script>";
$search = db_escape_string($_GET["search"]);
$search_mode = db_escape_string($_GET["smode"]);
// print_r($_GET);
$search = db_escape_string($_GET["query"]);
$search_mode = db_escape_string($_GET["search_mode"]);
$match_on = db_escape_string($_GET["match_on"]);
if (!$match_on) {
$match_on = "both";
}
if ($search) {
$search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%')
OR ttrss_entries.content LIKE '%$search%') AND";
if ($match_on == "both") {
$search_query_part = "(upper(ttrss_entries.title) LIKE upper('%$search%')
OR upper(ttrss_entries.content) LIKE '%$search%') AND";
} else if ($match_on == "title") {
$search_query_part = "upper(ttrss_entries.title) LIKE upper('%$search%')
AND";
} else if ($match_on == "content") {
$search_query_part = "upper(ttrss_entries.content) LIKE upper('%$search%') AND";
}
} else {
$search_query_part = "";
}
$view_query_part = "";
if ($view_mode == "Adaptive") {
if ($view_mode == "adaptive") {
if ($search) {
$view_query_part = " ";
} else if ($feed != -1) {
@ -778,29 +794,29 @@
}
}
if ($view_mode == "Starred") {
if ($view_mode == "marked") {
$view_query_part = " marked = true AND ";
}
if ($view_mode == "Unread") {
if ($view_mode == "unread") {
$view_query_part = " unread = true AND ";
}
if ($limit && $limit != "All") {
if ($limit > 0) {
$limit_query_part = "LIMIT " . $limit;
}
$vfeed_query_part = "";
// override query strategy and enable feed display when searching globally
if ($search && $search_mode == "All feeds") {
if ($search && $search_mode == "all_feeds") {
$query_strategy_part = "ttrss_entries.id > 0";
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
} else if (preg_match("/^-?[0-9][0-9]*$/", $feed) == false) {
$query_strategy_part = "ttrss_entries.id > 0";
$vfeed_query_part = "(SELECT title FROM ttrss_feeds WHERE
id = feed_id) as feed_title,";
} else if ($feed >= 0 && $search && $search_mode == "This category") {
} else if ($feed >= 0 && $search && $search_mode == "this_cat") {
$vfeed_query_part = "ttrss_feeds.title AS feed_title,";
@ -878,7 +894,7 @@
$feed_title = "";
if ($search && $search_mode == "All feeds") {
if ($search && $search_mode == "all_feeds") {
$feed_title = "Global search results ($search)";
} else if ($search && preg_match('/^-?[0-9][0-9]*$/', $feed) == false) {
$feed_title = "Feed search results ($search, $feed)";
@ -1360,7 +1376,7 @@
}
if ($subop == "editfeed") {
$feed_id = db_escape_string($_GET["id"]);
$feed_id = db_escape_string($_REQUEST["id"]);
$result = db_query($link,
"SELECT * FROM ttrss_feeds WHERE id = '$feed_id' AND
@ -2581,6 +2597,7 @@
print "<html><head>
<title>Tiny Tiny RSS : Help</title>
<link rel=\"stylesheet\" href=\"tt-rss.css\" type=\"text/css\">
<script type=\"text/javascript\" src=\"prototype.js\"></script>
<script type=\"text/javascript\" src=\"functions.js?$script_dt_add\"></script>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">
</head><body>";
@ -2655,39 +2672,63 @@
print "<div id=\"infoBoxTitle\">Search</div>";
print "<div class=\"infoBoxContents\">";
print "<form id='search_form'>";
$active_feed_id = db_escape_string($_GET["param"]);
print "<table width='100%'><tr><td>Search:</td><td>";
print "<input id=\"searchbox\" class=\"extSearch\"
onblur=\"javascript:enableHotkeys()\"
onfocus=\"javascript:disableHotkeys()\"
print "<input name=\"query\" class=\"iedit\"
onkeypress=\"return filterCR(event)\"
onkeyup=\"toggleSubmitNotEmpty(this, 'search_submit_btn')\"
onchange=\"javascript:search()\">
</td></tr><tr><td>Where:</td><td>
<select id=\"searchmodebox\">
<option selected>All feeds</option>";
value=\"\">
</td></tr>";
print "<tr><td>Where:</td><td>";
print "<select name=\"search_mode\">
<option value=\"all_feeds\">All feeds</option>";
$feed_title = getFeedTitle($link, $active_feed_id);
$feed_cat_title = getFeedCatTitle($link, $active_feed_id);
if ($active_feed_id) {
print "<option>This feed</option>";
print "<option selected value=\"this_feed\">This feed ($feed_title)</option>";
} else {
print "<option disabled>This feed</option>";
}
if (get_pref($link, 'ENABLE_FEED_CATS')) {
print "<option>This category</option>";
if (get_pref($link, 'ENABLE_FEED_CATS') && $active_feed_id && $active_feed_id > 0) {
print "<option value=\"this_cat\">This category ($feed_cat_title)</option>";
} else {
print "<option disabled>This category</option>";
}
print "</select></td></tr>
print "</select></td></tr>";
<tr><td colspan='2' align='right'>
print "<tr><td>Match on:</td><td>";
$search_fields = array(
"title" => "Title",
"content" => "Content",
"both" => "Title or content");
print_select_hash("match_on", 3, $search_fields);
print "</td></tr></table>";
print "</form>";
print "<div align=\"right\">
<input type=\"submit\"
class=\"button\" onclick=\"javascript:search()\"
id=\"search_submit_btn\" disabled=\"true\"
value=\"Search\">
<input class=\"button\"
type=\"submit\" onclick=\"javascript:closeInfoBox()\"
value=\"Cancel\"></td></tr></table>";
type=\"submit\" onclick=\"javascript:searchCancel()\"
value=\"Cancel\"></div>";
print "</div>";
}
@ -2717,7 +2758,8 @@
print "<table width='100%'>";
print "<tr><td>Match:</td>
<td><input onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
<td><input onkeypress=\"return filterCR(event)\"
onkeyup=\"toggleSubmitNotEmpty(this, 'infobox_submit')\"
name=\"reg_exp\" size=\"30\">&nbsp;";
print_select_hash("match_id", 1, $filter_types);

View file

@ -35,12 +35,13 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
enableHotkeys();
var searchbox = doc.getElementById("searchbox");
/* var searchbox = doc.getElementById("searchbox");
var search_query = "";
var search_mode = "";
if (searchbox) {
search_query = searchbox.value;
} else {
search_query = "";
}
var searchmodebox = doc.getElementById("searchmodebox");
@ -49,12 +50,8 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
if (searchmodebox) {
search_mode = searchmodebox[searchmodebox.selectedIndex].text;
} else {
search_mode = "";
}
setCookie("ttrss_vf_smode", search_mode);
var viewbox = doc.getElementById("viewbox");
var view_mode;
@ -63,9 +60,9 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
view_mode = viewbox[viewbox.selectedIndex].text;
} else {
view_mode = "All Posts";
}
}
setCookie("ttrss_vf_vmode", view_mode, getCookie("ttrss_cltime"));
setCookie("ttrss_vf_vmode", view_mode, getCookie("ttrss_cltime"));
var limitbox = doc.getElementById("limitbox");
@ -78,8 +75,19 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
limit = "All";
}
// document.getElementById("ACTFEEDID").innerHTML = feed;
// document.getElementById("ACTFEEDID").innerHTML = feed; */
var toolbar_query = parent.Form.serialize("main_toolbar_form");
var query = "backend.php?op=viewfeed&feed=" + feed + "&" +
toolbar_query + "&subop=" + param_escape(subop);
if (parent.document.getElementById("search_form")) {
var search_query = parent.Form.serialize("search_form");
query = query + "&" + search_query;
parent.closeInfoBox(true);
}
if (getActiveFeedId() != feed) {
cat_view_mode = is_cat;
}
@ -92,10 +100,10 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
setActiveFeedId(feed);
var query = "backend.php?op=viewfeed&feed=" + param_escape(feed) +
/* var query = "backend.php?op=viewfeed&feed=" + param_escape(feed) +
"&skip=" + param_escape(skip) + "&subop=" + param_escape(subop) +
"&view=" + param_escape(view_mode) + "&limit=" + limit +
"&smode=" + param_escape(search_mode);
"&smode=" + param_escape(search_mode); */
if (subop == "MarkAllRead") {
@ -122,18 +130,16 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
}
}
if (search_query != "") {
query = query + "&search=" + param_escape(search_query);
// if (search_query != "") {
// query = query + "&search=" + param_escape(search_query);
// searchbox.value = "";
}
// }
if (cat_view_mode) {
query = query + "&cat=1";
}
var headlines_frame = parent.frames["headlines-frame"];
// alert(headlines_frame)
if (navigator.userAgent.match("Opera")) {
var date = new Date();
@ -152,14 +158,9 @@ function viewfeed(feed, skip, subop, doc, is_cat, subop_param) {
feedr.className = feedr.className + "Selected";
}
disableContainerChildren("headlinesToolbar", false, doc);
/* var btnMarkAsRead = doc.getElementById("btnMarkFeedAsRead");
if (btnMarkAsRead && !isNumeric(feed)) {
btnMarkAsRead.disabled = true;
btnMarkAsRead.className = "disabledButton";
} */
parent.disableContainerChildren("headlinesToolbar", false);
parent.Form.enable("main_toolbar_form");
// notify("");
} catch (e) {

View file

@ -920,7 +920,7 @@ function leading_zero(p) {
return s;
}
function closeInfoBox() {
function closeInfoBox(cleanup) {
var box = document.getElementById('infoBox');
var shadow = document.getElementById('infoBoxShadow');
@ -930,6 +930,8 @@ function closeInfoBox() {
box.style.display = "none";
}
if (cleanup) box.innerHTML = "&nbsp;";
enableHotkeys();
}
@ -1032,3 +1034,18 @@ function qafAdd() {
xmlhttp.send(null);
}
function filterCR(e)
{
var key;
if(window.event)
key = window.event.keyCode; //IE
else
key = e.which; //firefox
if(key == 13)
return false;
else
return true;
}

View file

@ -1639,4 +1639,49 @@
function checkbox_to_sql_bool($val) {
return ($val == "on") ? "true" : "false";
}
function getFeedCatTitle($link, $id) {
if ($id == -1) {
return "Special";
} else if ($id < -10) {
return "Labels";
} else if ($id > 0) {
$result = db_query($link, "SELECT ttrss_feed_categories.title
FROM ttrss_feeds, ttrss_feed_categories WHERE ttrss_feeds.id = '$id' AND
cat_id = ttrss_feed_categories.id");
if (db_num_rows($result) == 1) {
return db_fetch_result($result, 0, "title");
} else {
return "Unknown category ($id)";
}
} else {
return "getFeedCatTitle($id) failed";
}
}
function getFeedTitle($link, $id) {
if ($id == -1) {
return "Starred articles";
} else if ($id < -10) {
$label_id = -10 - $id;
$result = db_query($link, "SELECT description FROM ttrss_labels WHERE id = '$label_id'");
if (db_num_rows($result) == 1) {
return db_fetch_result($result, 0, "description");
} else {
return "Unknown label ($label_id)";
}
} else if ($id > 0) {
$result = db_query($link, "SELECT title FROM ttrss_feeds WHERE id = '$id'");
if (db_num_rows($result) == 1) {
return db_fetch_result($result, 0, "title");
} else {
return "Unknown feed ($id)";
}
} else {
return "getFeedTitle($id) failed";
}
}
?>

View file

@ -1107,3 +1107,7 @@ form {
margin : 0px;
padding : 0px;
}
#main_toolbar_form {
display : inline;
}

View file

@ -274,6 +274,10 @@ function resetSearch() {
}
}
function searchCancel() {
closeInfoBox(true);
}
function search() {
closeInfoBox();
viewCurrentFeed(0, "");
@ -375,6 +379,8 @@ function init() {
disableContainerChildren("headlinesToolbar", true);
Form.disable("main_toolbar_form");
if (!genericSanityCheck())
return;
@ -414,11 +420,11 @@ function init_second_stage() {
updateFeedList(false, false);
document.onkeydown = hotkey_handler;
var viewbox = document.getElementById("viewbox");
/* var viewbox = document.getElementById("viewbox");
var limitbox = document.getElementById("limitbox");
dropboxSelect(viewbox, getCookie("ttrss_vf_vmode"));
dropboxSelect(limitbox, getCookie("ttrss_vf_limit"));
dropboxSelect(limitbox, getCookie("ttrss_vf_limit")); */
daemon_enabled = getCookie("ttrss_vf_daemon");
@ -449,7 +455,7 @@ function init_second_stage() {
function quickMenuChange() {
var chooser = document.getElementById("quickMenuChooser");
var opid = chooser[chooser.selectedIndex].id;
var opid = chooser[chooser.selectedIndex].value;
chooser.selectedIndex = 0;
quickMenuGo(opid);

View file

@ -150,101 +150,85 @@ window.onload = init;
<tr><td class="headlinesToolbar" id="headlinesToolbar">
<? if (get_pref($link, 'ENABLE_SEARCH_TOOLBAR')) { ?>
<!-- <? if (get_pref($link, 'ENABLE_SEARCH_TOOLBAR')) { ?>
<input id="searchbox"
onblur="javascript:enableHotkeys();" onfocus="javascript:disableHotkeys();">
<select id="searchmodebox">
<option>This feed</option>
<option value="all_feeds">All feeds</option>
<option value="this_feed" selected>This feed</option>
<? if (get_pref($link, 'ENABLE_FEED_CATS')) { ?>
<option>This category</option>
<option value="this_cat">This category</option>
<? } ?>
<option>All feeds</option>
</select>
<input type="submit"
class="button" onclick="javascript:search()" value="Search">
&nbsp;
&nbsp;
<? } ?>
<? } ?> -->
View:
<select id="viewbox" onchange="javascript:viewCurrentFeed(0, '')">
<option selected>Adaptive</option>
<option>All Articles</option>
<option>Starred</option>
<option>Unread</option>
<form id="main_toolbar_form">
View:
<select name="view_mode" onchange="viewCurrentFeed(0, '')">
<option selected value="adaptive">Adaptive</option>
<option value="all_articles">All Articles</option>
<option value="marked">Starred</option>
<option value="unread">Unread</option>
</select>
&nbsp;Limit:
<select id="limitbox" onchange="javascript:viewCurrentFeed(0, '')">
<?
$limits = array(15 => 15, 30 => 30, 60 => 60);
$limits = array(15 => 15, 30 => 30, 60 => 60, 0 => "All");
$def_art_limit = get_pref($link, 'DEFAULT_ARTICLE_LIMIT');
$def_art_limit = get_pref($link, 'DEFAULT_ARTICLE_LIMIT');
if ($def_art_limit >= 0 && !array_key_exists($def_art_limit, $limits)) {
$limits[$def_art_limit] = $def_art_limit;
}
if ($def_art_limit >= 0 && !array_key_exists($def_art_limit, $limits)) {
$limits[$def_art_limit] = $def_art_limit;
}
asort($limits);
array_push($limits, 0);
asort($limits);
if (!$def_art_limit) {
$def_art_limit = 30;
}
if (!$def_art_limit) {
$def_art_limit = 30;
}
foreach ($limits as $key) {
print "<option";
if ($key == $def_art_limit) { print " selected"; }
print ">";
if ($limits[$key] == 0) { print "All"; } else { print $limits[$key]; }
print "</option>";
} ?>
</select>
print_select_hash("limit", $def_art_limit, $limits,
'onchange="viewCurrentFeed(0, \'\')"');
?>
</form>
<!-- &nbsp;Selection:
<!-- &nbsp;<input class="button" type="submit"
onclick="quickMenuGo('qmcSearch')" value="Search (tmp)"> -->
<select id="headopbox">
<option id="hopToggleRead">Toggle (un)read</option>
</select>
&nbsp;<input class="button" type="submit"
onclick="viewCurrentFeed(0, 'ForceUpdate')" value="Update">
<input class="button" type="submit" onclick="headopGo()" value="Go"> -->
&nbsp;Feed: <input class="button" type="submit"
onclick="javascript:viewCurrentFeed(0, 'ForceUpdate')" value="Update">
<input class="button" type="submit" id="btnMarkFeedAsRead"
onclick="javascript:viewCurrentFeed(0, 'MarkAllRead')" value="Mark as read">
<input class="button" type="submit"
onclick="viewCurrentFeed(0, 'MarkAllRead')" value="Mark as read">
</td>
<td align="right">
<select id="quickMenuChooser" onchange="quickMenuChange()">
<option id="qmcDefault" selected>Actions...</option>
<option id="qmcPrefs">Preferences</option>
<option id="qmcSearch">Search</option>
<option value="qmcDefault" selected>Actions...</option>
<option value="qmcPrefs">Preferences</option>
<option value="qmcSearch">Search</option>
<option disabled>--------</option>
<option style="color : #5050aa" disabled>Feed actions:</option>
<option id="qmcAddFeed">&nbsp;&nbsp;Subscribe to feed</option>
<option id="qmcRemoveFeed">&nbsp;&nbsp;Unsubscribe</option>
<option value="qmcAddFeed">&nbsp;&nbsp;Subscribe to feed</option>
<option value="qmcRemoveFeed">&nbsp;&nbsp;Unsubscribe</option>
<!-- <option>Edit this feed</option> -->
<option disabled>--------</option>
<option style="color : #5050aa" disabled>All feeds:</option>
<? if (!ENABLE_UPDATE_DAEMON) { ?>
<option id="qmcUpdateFeeds">&nbsp;&nbsp;Update</option>
<option value="qmcUpdateFeeds">&nbsp;&nbsp;Update</option>
<? } ?>
<option id="qmcCatchupAll">&nbsp;&nbsp;Mark as read</option>
<option id="qmcShowOnlyUnread">&nbsp;&nbsp;Show only unread</option>
<option value="qmcCatchupAll">&nbsp;&nbsp;Mark as read</option>
<option value="qmcShowOnlyUnread">&nbsp;&nbsp;Show only unread</option>
<option disabled>--------</option>
<option style="color : #5050aa" disabled>Other actions:</option>
<option id="qmcAddFilter">&nbsp;&nbsp;Create filter</option>
<option value="qmcAddFilter">&nbsp;&nbsp;Create filter</option>
</select>
</td>
</tr>