diff --git a/collects/scribblings/main/private/search.js b/collects/scribblings/main/private/search.js index 98c24fe91a..90426855f6 100644 --- a/collects/scribblings/main/private/search.js +++ b/collects/scribblings/main/private/search.js @@ -455,6 +455,22 @@ function Search(data, term, is_pre, K) { else { progress(0); t = setTimeout(DoChunk,15); return killer; } } +function GetContextHTML() { + // useful only when a context is set + return (((pre_query_label != "") && pre_query_label) + ? SanitizeHTML(pre_query_label) + : ('“' + SanitizeHTML(pre_query) + '”')); +} +function GetContextClearerHTML(text) { + return ('' + + text + + ''); +} + var search_data; // pre-filtered searchable index data function PreFilter() { pre_query = NormalizeSpaces(pre_query); @@ -469,23 +485,15 @@ function PreFilter() { +'[set context]'; } else { pre_query_label_line.innerHTML = - 'Context: ' - + (((pre_query_label != "") && pre_query_label) - ? SanitizeHTML(pre_query_label) - : ('“' + SanitizeHTML(pre_query) + '”')) - + ' ' - +'[clear' - +'/' - +'' - +'modify]'; + 'Context: ' + GetContextHTML() + + ' ' + + GetContextClearerHTML('[clear') + + '/' + +'modify]'; } last_search_term = null; last_search_term_raw = null; @@ -604,8 +612,12 @@ function UpdateResults() { + ' exact)'; if (search_results.length == 0) { if (last_search_term == "") status_line.innerHTML = ""; - else status_line.innerHTML = 'No matches found ' - + '
' + else status_line.innerHTML = 'No matches found' + + ((pre_query != "") + ? (' in '+GetContextHTML() + +' '+GetContextClearerHTML('[clear]')) + : '') + + '
' + '(Make sure your spelling is correct' + (last_search_term.search(/ /)>=0 ? ', or try fewer keywords' : '') + ((pre_query != "") ? ', or clear the search context' : '')