Very partial change, the only visible effect should be that "Pre-Query"
is no longer part of the interface in any way. svn: r16136
This commit is contained in:
parent
c3602ff740
commit
b9f4662af9
|
@ -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)
|
||||
|
|
|
@ -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) {
|
|||
+'</div>';
|
||||
}
|
||||
|
||||
function MakePreQueryItem(qry, desc) {
|
||||
function MakeContextQueryItem(qry, desc) {
|
||||
return '<li><a href="?hq='+encodeURIComponent(qry)+'" tabIndex="4"'
|
||||
+' title="set this as your pre-filter context"'
|
||||
+' title="set this as your context-query"'
|
||||
+' style="text-decoration: none;"'
|
||||
+' onclick="return new_query(this,\''
|
||||
+encodeURIComponent(desc)
|
||||
|
@ -169,9 +169,9 @@ function InitializeSearch() {
|
|||
"The color to use for highlighting exact"
|
||||
+" matches (a known color name or #RGB)")
|
||||
+'>')
|
||||
+ MakePref('Pre-Query',
|
||||
+ MakePref('Context-Query',
|
||||
'<input type="text" '
|
||||
+PrefInputArgs("pre_query",
|
||||
+PrefInputArgs("ctx_query",
|
||||
"A “context” query that is implicitly added"
|
||||
+" to all searches")
|
||||
+'> '
|
||||
|
@ -182,20 +182,20 @@ function InitializeSearch() {
|
|||
+'</div>'
|
||||
+'<div id="contexts_panel" '+panelstyle+'>'
|
||||
+'<table align="center" style="margin: 0em 2em;">'
|
||||
+ MakePref('Pre-Query',
|
||||
+ MakePref('Context-Query',
|
||||
'<input type="text" '
|
||||
+PrefInputArgs("context_query",
|
||||
"A “context” query that is implicitly added"
|
||||
+" to all searches")
|
||||
+'>')
|
||||
+'</table>'
|
||||
+'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:'
|
||||
+'<ul style="padding: 0em; margin: 0.5em 1.5em;">'
|
||||
+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")
|
||||
+'</ul>'
|
||||
+'</div>'
|
||||
+MakeChevrons(1,
|
||||
|
@ -208,12 +208,12 @@ function InitializeSearch() {
|
|||
+'</div>'
|
||||
+'<br />'
|
||||
+MakeChevrons(2,
|
||||
'<span id="pre_query_label" style="color: #444;"> </span>')
|
||||
'<span id="ctx_query_label" style="color: #444;"> </span>')
|
||||
+'</div>';
|
||||
// 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 ('<a href="?hq=" tabIndex="5"'
|
||||
+' title="Clear pre-filter context"'
|
||||
+' title="Clear context-query"'
|
||||
+' style="text-decoration: none; color: #444;'
|
||||
+' font-size: 82%; font-weight: bold;"'
|
||||
+' onclick="return new_query(this,\'\');">'
|
||||
|
@ -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 =
|
||||
'<a href="#" tabIndex="5"'
|
||||
+' title="Edit pre-filter context"'
|
||||
+' title="Edit context-query"'
|
||||
+' style="text-decoration: none; color: #444;'
|
||||
+' font-size: 82%; font-weight: bold;"'
|
||||
+' onclick="toggle_panel(\'contexts\'); return false;">'
|
||||
+'[set context]</a>';
|
||||
} else {
|
||||
pre_query_label_line.innerHTML =
|
||||
ctx_query_label_line.innerHTML =
|
||||
'Context: ' + GetContextHTML()
|
||||
+ ' '
|
||||
+ GetContextClearerHTML('[clear')
|
||||
+ '/<a href="#" tabIndex="5"'
|
||||
+' title="Edit pre-filter context"'
|
||||
+' title="Edit context-query"'
|
||||
+' style="text-decoration: none; color: #444;'
|
||||
+' font-size: 82%; font-weight: bold;"'
|
||||
+' onclick="toggle_panel(\'contexts\'); return false;">'
|
||||
|
@ -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('<small>[clear]</small>'))
|
||||
: '')
|
||||
+ '<br><div style="color: black; font-size: 82%;">'
|
||||
+ '(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' : '')
|
||||
+ ')</div>';
|
||||
} else if (search_results.length <= results_num)
|
||||
status_line.innerHTML = "Showing all matches" + exact;
|
||||
|
@ -698,7 +698,7 @@ function NewQuery(node,label) {
|
|||
DoSearch();
|
||||
return false;
|
||||
} else if ((m = href.search(/[?]hq=[^?&;]*$/)) >= 0) { // `hq' can
|
||||
SetPreQuery(decodeURIComponent(href.substring(m+4)),
|
||||
SetContextQuery(decodeURIComponent(href.substring(m+4)),
|
||||
decodeURIComponent(label));
|
||||
return false;
|
||||
} else {
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user