From 7a822893ce9f83d69b5fc0d6d4544d0288a97c32 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 4 May 2008 07:46:32 +0100 Subject: [PATCH] online search in headline buffer (hotkey shift-I) --- functions.js | 59 ++++++++++++++++++++++++++++++++------------------- functions.php | 18 +++++++++++----- tt-rss.css | 6 ++++++ tt-rss.js | 1 + viewfeed.js | 36 +++++++++++++++++++++++++++++++ 5 files changed, 93 insertions(+), 27 deletions(-) diff --git a/functions.js b/functions.js index 9ef91c59..088b986e 100644 --- a/functions.js +++ b/functions.js @@ -353,6 +353,19 @@ function hotkey_handler(e) { } } + if (keycode == 73 && shift_key) { // shift + i + if (document.getElementById("subtoolbar_search")) { + if (Element.visible("subtoolbar_search")) { + Element.hide("subtoolbar_search"); + Element.show("subtoolbar_ftitle"); + setTimeout("Element.focus('subtoolbar_search_box')", 100); + } else { + Element.show("subtoolbar_search"); + Element.hide("subtoolbar_ftitle"); + } + } + } + if (typeof localHotkeyHandler != 'undefined') { try { return localHotkeyHandler(e); @@ -1056,38 +1069,40 @@ function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, } for (i = 0; i < content.rows.length; i++) { - if (!classcheck || content.rows[i].className.match(classcheck)) { + if (Element.visible(content.rows[i])) { + if (!classcheck || content.rows[i].className.match(classcheck)) { + + if (content.rows[i].id.match(prefix)) { + selectTableRow(content.rows[i], do_select); + + var row_id = content.rows[i].id.replace(prefix, ""); + var check = document.getElementById(check_prefix + row_id); + + if (check) { + check.checked = do_select; + } + } else if (reset_others) { + selectTableRow(content.rows[i], false); + + var row_id = content.rows[i].id.replace(prefix, ""); + var check = document.getElementById(check_prefix + row_id); + + if (check) { + check.checked = false; + } - if (content.rows[i].id.match(prefix)) { - selectTableRow(content.rows[i], do_select); - - var row_id = content.rows[i].id.replace(prefix, ""); - var check = document.getElementById(check_prefix + row_id); - - if (check) { - check.checked = do_select; } } else if (reset_others) { selectTableRow(content.rows[i], false); - + var row_id = content.rows[i].id.replace(prefix, ""); var check = document.getElementById(check_prefix + row_id); - + if (check) { check.checked = false; } - - } - } else if (reset_others) { - selectTableRow(content.rows[i], false); - - var row_id = content.rows[i].id.replace(prefix, ""); - var check = document.getElementById(check_prefix + row_id); - - if (check) { - check.checked = false; + } - } } } diff --git a/functions.php b/functions.php index 449bb4e5..71931646 100644 --- a/functions.php +++ b/functions.php @@ -3964,7 +3964,15 @@ print ""; - print ""; + print "Search: "; + + print ""; if ($feed_site_url) { if (!$bottom) { @@ -3984,8 +3992,6 @@ print " [$user_page_offset] "; } - print ""; - if (!$bottom && !$disable_feed) { print " "; } - + + print ""; + print ""; print ""; @@ -4981,7 +4989,7 @@ print ""; - print "" . + print "" . $line["title"]; if (get_pref($link, 'SHOW_CONTENT_PREVIEW')) { diff --git a/tt-rss.css b/tt-rss.css index e33b291a..e772b83b 100644 --- a/tt-rss.css +++ b/tt-rss.css @@ -743,6 +743,12 @@ table.headlinesSubToolbar { background-color : white; } +input#subtoolbar_search_box { + height : 10px; + font-size : 7pt; + vertical-align : middle; +} + table.headlinesSubToolbar td.headlineActions { font-size : 9pt; font-family : "Lucida Grande", Tahoma, Arial, sans-serif; diff --git a/tt-rss.js b/tt-rss.js index 25efe8f6..11ce57b7 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -891,3 +891,4 @@ function rescoreCurrentFeed() { } } + diff --git a/viewfeed.js b/viewfeed.js index 79dbe003..4a192a35 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -152,6 +152,8 @@ function headlines_callback2(transport, active_feed_id, is_cat, feed_cur_page) { markHeadline(ids[i]); } + subtoolbarSearch(); + } else { debug("no new headlines received"); } @@ -1677,4 +1679,38 @@ function cdmExpandArticle(a_id) { } +function subtoolbarSearch() { + + try { + + var q = document.getElementById("subtoolbar_search_box"); + + if (!q) return; + + q = q.value.toUpperCase(); + + var ids = false; + + if (document.getElementById("headlinesList")) { + ids = getVisibleHeadlineIds(); + } else { + ids = cdmGetVisibleArticles(); + } + for (var i = 0; i < ids.length; i++) { + var title = document.getElementById("RTITLE-" + ids[i]); + + if (title) { + if (!title.innerHTML.toUpperCase().match(q)) { + Element.hide(document.getElementById("RROW-" + ids[i])); + } else { + Element.show(document.getElementById("RROW-" + ids[i])); + } + } + } + + } catch (e) { + exception_error("subtoolbarSearch", e); + } + +} -- 2.39.5