search.js: kill get_search_string

(imported from commit 5979832ba697386a660ca9cdc6487fa79257511b)
This commit is contained in:
Steve Howell
2013-07-16 17:16:30 -04:00
parent c201354e6b
commit 87e025602c

View File

@@ -79,22 +79,6 @@ function describe(operators) {
}).join(', '); }).join(', ');
} }
function get_search_string(obj) {
switch (obj.action) {
case 'stream':
return 'stream:' + obj.query;
case 'private_message':
return 'pm-with:' + obj.query.email;
case 'sender':
return 'sender:' + obj.query.email;
case 'operators':
return obj.query;
}
}
function narrow_or_search_for_term(item) { function narrow_or_search_for_term(item) {
var search_query_box = $("#search_query"); var search_query_box = $("#search_query");
var obj = search_object[item]; var obj = search_object[item];
@@ -155,7 +139,7 @@ function get_stream_suggestions(query, max_num) {
var stream = obj.query; var stream = obj.query;
stream = typeahead_helper.highlight_query_in_phrase(query, stream); stream = typeahead_helper.highlight_query_in_phrase(query, stream);
obj.description = prefix + ' ' + stream; obj.description = prefix + ' ' + stream;
obj.search_string = get_search_string(obj); obj.search_string = 'stream:' + obj.query;
}); });
return objs; return objs;
@@ -181,19 +165,22 @@ function get_person_suggestions(all_people, query, action, max_num) {
var prefix; var prefix;
var person; var person;
var name; var name;
var operator;
if (action === 'private_message') { if (action === 'private_message') {
prefix = 'Narrow to private messages with'; prefix = 'Narrow to private messages with';
operator = 'pm-with';
} }
if (action === 'sender') { if (action === 'sender') {
prefix = 'Narrow to messages sent by'; prefix = 'Narrow to messages sent by';
operator = 'sender';
} }
person = obj.query; person = obj.query;
name = highlight_person(query, person); name = highlight_person(query, person);
obj.description = prefix + ' ' + name; obj.description = prefix + ' ' + name;
obj.search_string = get_search_string(obj); obj.search_string = operator + ':' + obj.query.email;
}); });
return objs; return objs;
@@ -208,7 +195,7 @@ exports.initialize = function () {
var operators = narrow.parse(query); var operators = narrow.parse(query);
if (operators.length !== 0) { if (operators.length !== 0) {
var obj = {action: 'operators', query: query}; var obj = {action: 'operators', query: query};
obj.search_string = get_search_string(obj); obj.search_string = query;
var description = describe(operators); var description = describe(operators);
obj.description = Handlebars.Utils.escapeExpression(description); obj.description = Handlebars.Utils.escapeExpression(description);
result = [obj]; result = [obj];