From b9f4662af9456df070cfac239ffc74e7408f8176 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 27 Sep 2009 14:13:57 +0000 Subject: [PATCH] Very partial change, the only visible effect should be that "Pre-Query" is no longer part of the interface in any way. svn: r16136 --- .../main/private/search-context.html | 5 +- collects/scribblings/main/private/search.js | 98 ++++++++++--------- 2 files changed, 53 insertions(+), 50 deletions(-) diff --git a/collects/scribblings/main/private/search-context.html b/collects/scribblings/main/private/search-context.html index c74675a111..5f875c3233 100644 --- a/collects/scribblings/main/private/search-context.html +++ b/collects/scribblings/main/private/search-context.html @@ -22,9 +22,10 @@ if (location.search.length > 0) { var param = paramstrs[i].split(/=/); // an empty "hq=" can be used to clear the cookie if (param[0] == "hq") { - SetCookie("PLT_PreQuery", ((param.length==2) ? unescape(param[1]) : "")); + SetCookie("PLT_ContextQuery", + ((param.length==2) ? unescape(param[1]) : "")); } else if (param[0] == "label") { - SetCookie("PLT_PreQueryLabel", + SetCookie("PLT_ContextQueryLabel", ((param.length==2) ? unescape(param[1]) : "")); } else { newsearch = (newsearch == null) diff --git a/collects/scribblings/main/private/search.js b/collects/scribblings/main/private/search.js index fbd567ca9e..cb01f2cf39 100644 --- a/collects/scribblings/main/private/search.js +++ b/collects/scribblings/main/private/search.js @@ -1,14 +1,14 @@ // Globally visible bindings var key_handler, toggle_panel, hide_prefs, new_query, refine_query, - set_pre_query, set_context_query, set_show_manuals, set_show_manual_titles, + set_ctx_query, set_context_query, set_show_manuals, set_show_manual_titles, set_results_num, set_type_delay, set_highlight_color, status_line, - saved_status = false, pre_query_label_line; + saved_status = false, ctx_query_label_line; (function(){ // Configuration options (use || in case a cookie exists but is empty) -var pre_query = GetCookie("PLT_PreQuery",""); -var pre_query_label = GetCookie("PLT_PreQueryLabel",""); // no prefs UI +var ctx_query = GetCookie("PLT_ContextQuery",""); +var ctx_query_label = GetCookie("PLT_ContextQueryLabel",""); // no prefs UI var manual_settings = parseInt(GetCookie("PLT_ManualSettings",1)); var show_manuals = manual_settings % 10; var show_manual_titles = ((manual_settings - show_manuals) / 10) > 0; @@ -25,7 +25,7 @@ var prev_page_link1, prev_page_link2, next_page_link1, next_page_link2; // 2 index links // 3 help/pref toggle // 4 pref widgets -// 5 clear current pre-filter context +// 5 clear current context-query // -1 prev/next page (un-tab-able) function MakePref(label, input) { @@ -62,9 +62,9 @@ function MakeChevrons(num, middle) { +''; } -function MakePreQueryItem(qry, desc) { +function MakeContextQueryItem(qry, desc) { return '
  • ') - + MakePref('Pre-Query', + + MakePref('Context-Query', ' ' @@ -182,20 +182,20 @@ function InitializeSearch() { +'' +'
    ' +'' - + MakePref('Pre-Query', + + MakePref('Context-Query', '') +'
    ' - +'Clicking the following links will set your pre-query context to a' + +'Clicking the following links will set your context-query to a' +' few common choices:' +'
      ' - +MakePreQueryItem("M:", "Bindings") - +MakePreQueryItem("T:reference", "Reference manual") - +MakePreQueryItem("M:scheme", "{{scheme}} bindings") - +MakePreQueryItem("M:scheme/base", "{{scheme/base}} bindings") + +MakeContextQueryItem("M:", "Bindings") + +MakeContextQueryItem("T:reference", "Reference manual") + +MakeContextQueryItem("M:scheme", "{{scheme}} bindings") + +MakeContextQueryItem("M:scheme/base", "{{scheme/base}} bindings") +'
    ' +'
    ' +MakeChevrons(1, @@ -208,12 +208,12 @@ function InitializeSearch() { +'' +'
    ' +MakeChevrons(2, - ' ') + ' ') +''; // get the widgets we use query = document.getElementById("search_box"); status_line = document.getElementById("search_status"); - pre_query_label_line = document.getElementById("pre_query_label"); + ctx_query_label_line = document.getElementById("ctx_query_label"); prev_page_link1 = document.getElementById("prev_page_link1"); prev_page_link2 = document.getElementById("prev_page_link2"); next_page_link1 = document.getElementById("next_page_link1"); @@ -237,7 +237,7 @@ function InitializeSearch() { } } } - PreFilter(); + ContextFilter(); DoSearch(); query.focus(); query.select(); @@ -457,13 +457,13 @@ function Search(data, term, is_pre, K) { function GetContextHTML() { // useful only when a context is set - return (((pre_query_label != "") && pre_query_label) - ? SanitizeHTML(pre_query_label) - : ('“' + SanitizeHTML(pre_query) + '”')); + return (((ctx_query_label != "") && ctx_query_label) + ? SanitizeHTML(ctx_query_label) + : ('“' + SanitizeHTML(ctx_query) + '”')); } function GetContextClearerHTML(text) { return ('
    ' @@ -472,24 +472,24 @@ function GetContextClearerHTML(text) { } var search_data; // pre-filtered searchable index data -function PreFilter() { - pre_query = NormalizeSpaces(pre_query); - search_data = Search(plt_search_data, pre_query, true, false)[1]; - if (pre_query == "") { - pre_query_label_line.innerHTML = +function ContextFilter() { + ctx_query = NormalizeSpaces(ctx_query); + search_data = Search(plt_search_data, ctx_query, true, false)[1]; + if (ctx_query == "") { + ctx_query_label_line.innerHTML = '' +'[set context]'; } else { - pre_query_label_line.innerHTML = + ctx_query_label_line.innerHTML = 'Context: ' + GetContextHTML() + ' ' + GetContextClearerHTML('[clear') + '/' @@ -613,14 +613,14 @@ function UpdateResults() { if (search_results.length == 0) { if (last_search_term == "") status_line.innerHTML = ""; else status_line.innerHTML = 'No matches found' - + ((pre_query != "") + + ((ctx_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' : '') + + ((ctx_query != "") ? ', or clear the search context' : '') + ')
    '; } else if (search_results.length <= results_num) status_line.innerHTML = "Showing all matches" + exact; @@ -698,8 +698,8 @@ function NewQuery(node,label) { DoSearch(); return false; } else if ((m = href.search(/[?]hq=[^?&;]*$/)) >= 0) { // `hq' can - SetPreQuery(decodeURIComponent(href.substring(m+4)), - decodeURIComponent(label)); + SetContextQuery(decodeURIComponent(href.substring(m+4)), + decodeURIComponent(label)); return false; } else { return true; @@ -732,7 +732,7 @@ function TogglePanel(name) { } panel_shown = ((panel_shown != name) && name); if (panel_shown == "prefs") { - document.getElementById("pre_query_pref").value = pre_query; + document.getElementById("ctx_query_pref").value = ctx_query; document.getElementById("show_manuals_pref").selectedIndex = show_manuals; document.getElementById("show_manual_titles_pref").checked = show_manual_titles; @@ -740,12 +740,14 @@ function TogglePanel(name) { document.getElementById("type_delay_pref").value = type_delay; document.getElementById("highlight_color_pref").value = highlight_color; } else if (panel_shown == "contexts") { - document.getElementById("context_query_pref").value = pre_query; + document.getElementById("context_query_pref").value = ctx_query; } if (panel_shown) { document.getElementById(panel_shown+"_panel").style.display = "block"; document.getElementById("close_panel").style.display = "block"; - document.getElementById(panel_shown+"_panel").scrollIntoView(); + // This is annoying -- would be nicer to have a way to make sure + // that it's in view without scrolling if not necessary. + // document.getElementById(panel_shown+"_panel").scrollIntoView(); } } toggle_panel = TogglePanel; @@ -767,23 +769,23 @@ function SetShowManuals(inp) { } set_show_manuals = SetShowManuals; -function SetPreQuery(inp,label) { +function SetContextQuery(inp,label) { // can be called with the input object, or with a string if (typeof inp != "string") inp = inp.value; - if (inp != pre_query) { - pre_query = inp; - SetCookie("PLT_PreQuery", pre_query); + if (inp != ctx_query) { + ctx_query = inp; + SetCookie("PLT_ContextQuery", ctx_query); label = label || ""; - pre_query_label = label; - SetCookie("PLT_PreQueryLabel",label); - PreFilter(); - document.getElementById("pre_query_pref").value = pre_query; - document.getElementById("context_query_pref").value = pre_query; + ctx_query_label = label; + SetCookie("PLT_ContextQueryLabel",label); + ContextFilter(); + document.getElementById("ctx_query_pref").value = ctx_query; + document.getElementById("context_query_pref").value = ctx_query; DoSearch(); } } -set_pre_query = SetPreQuery; -set_context_query = SetPreQuery; // a different widget, same effect +set_ctx_query = SetContextQuery; +set_context_query = SetContextQuery; // a different widget, same effect function SetShowManuals(inp) { if (inp.selectedIndex != show_manuals) {