90 if (!name || !resultsPath) { alert(
"Missing parameters to SearchBox."); }
94 this.resultsPath = resultsPath;
96 this.keyTimeoutLength = 500;
97 this.closeSelectionTimeout = 300;
98 this.lastSearchValue =
"";
99 this.lastResultsPage =
"";
100 this.hideTimeout = 0;
101 this.searchIndex = 0;
102 this.searchActive =
false;
103 this.insideFrame = inFrame;
104 this.searchLabel = label;
108 this.DOMSearchField =
function()
109 {
return document.getElementById(
"MSearchField"); }
111 this.DOMSearchSelect =
function()
112 {
return document.getElementById(
"MSearchSelect"); }
114 this.DOMSearchSelectWindow =
function()
115 {
return document.getElementById(
"MSearchSelectWindow"); }
117 this.DOMPopupSearchResults =
function()
118 {
return document.getElementById(
"MSearchResults"); }
120 this.DOMPopupSearchResultsWindow =
function()
121 {
return document.getElementById(
"MSearchResultsWindow"); }
123 this.DOMSearchClose =
function()
124 {
return document.getElementById(
"MSearchClose"); }
126 this.DOMSearchBox =
function()
127 {
return document.getElementById(
"MSearchBox"); }
132 this.OnSearchFieldFocus =
function(isActive)
134 this.Activate(isActive);
137 this.OnSearchSelectShow =
function()
139 var searchSelectWindow = this.DOMSearchSelectWindow();
140 var searchField = this.DOMSearchSelect();
142 if (this.insideFrame)
144 var left =
getXPos(searchField);
145 var top =
getYPos(searchField);
146 left += searchField.offsetWidth + 6;
147 top += searchField.offsetHeight;
150 searchSelectWindow.style.display=
'block';
151 left -= searchSelectWindow.offsetWidth;
152 searchSelectWindow.style.left = left +
'px';
153 searchSelectWindow.style.top = top +
'px';
157 var left =
getXPos(searchField);
158 var top =
getYPos(searchField);
159 top += searchField.offsetHeight;
162 searchSelectWindow.style.display=
'block';
163 searchSelectWindow.style.left = left +
'px';
164 searchSelectWindow.style.top = top +
'px';
168 if (this.hideTimeout)
170 clearTimeout(this.hideTimeout);
176 this.OnSearchSelectHide =
function()
178 this.hideTimeout = setTimeout(this.name +
".CloseSelectionWindow()",
179 this.closeSelectionTimeout);
183 this.OnSearchFieldChange =
function(evt)
187 clearTimeout(this.keyTimeout);
191 var e = (evt) ? evt :
window.event;
192 if (e.keyCode==40 || e.keyCode==13)
196 this.OnSearchSelectShow();
197 var win=this.DOMSearchSelectWindow();
198 for (i=0;i<win.childNodes.length;i++)
200 var child = win.childNodes[i];
201 if (child.className==
'SelectItem')
209 else if (
window.frames.MSearchResults.searchResults)
211 var elem =
window.frames.MSearchResults.searchResults.NavNext(0);
212 if (elem) elem.focus();
215 else if (e.keyCode==27)
217 this.DOMSearchField().blur();
218 this.DOMPopupSearchResultsWindow().style.display =
'none';
219 this.DOMSearchClose().style.display =
'none';
220 this.lastSearchValue =
'';
221 this.Activate(
false);
226 var searchValue = this.DOMSearchField().value.replace(/ +/g,
"");
228 if (searchValue != this.lastSearchValue)
230 if (searchValue !=
"")
233 this.keyTimeout = setTimeout(this.name +
'.Search()',
234 this.keyTimeoutLength);
238 this.DOMPopupSearchResultsWindow().style.display =
'none';
239 this.DOMSearchClose().style.display =
'none';
240 this.lastSearchValue =
'';
245 this.SelectItemCount =
function(id)
248 var win=this.DOMSearchSelectWindow();
249 for (i=0;i<win.childNodes.length;i++)
251 var child = win.childNodes[i];
252 if (child.className==
'SelectItem')
260 this.SelectItemSet =
function(id)
263 var win=this.DOMSearchSelectWindow();
264 for (i=0;i<win.childNodes.length;i++)
266 var child = win.childNodes[i];
267 if (child.className==
'SelectItem')
269 var node = child.firstChild;
272 node.innerHTML=
'•';
276 node.innerHTML=
' ';
285 this.OnSelectItem =
function(id)
287 this.searchIndex = id;
288 this.SelectItemSet(
id);
289 var searchValue = this.DOMSearchField().value.replace(/ +/g,
"");
290 if (searchValue!=
"" && this.searchActive)
296 this.OnSearchSelectKey =
function(evt)
298 var e = (evt) ? evt :
window.event;
299 if (e.keyCode==40 &&
this.searchIndex<
this.SelectItemCount())
302 this.OnSelectItem(this.searchIndex);
304 else if (e.keyCode==38 &&
this.searchIndex>0)
307 this.OnSelectItem(this.searchIndex);
309 else if (e.keyCode==13 || e.keyCode==27)
311 this.OnSelectItem(this.searchIndex);
312 this.CloseSelectionWindow();
313 this.DOMSearchField().focus();
321 this.CloseResultsWindow =
function()
323 this.DOMPopupSearchResultsWindow().style.display =
'none';
324 this.DOMSearchClose().style.display =
'none';
325 this.Activate(
false);
328 this.CloseSelectionWindow =
function()
330 this.DOMSearchSelectWindow().style.display =
'none';
334 this.Search =
function()
339 var searchValue = this.DOMSearchField().value.replace(/^ +/,
"");
341 var code = searchValue.toLowerCase().charCodeAt(0);
342 var idxChar = searchValue.substr(0, 1).toLowerCase();
343 if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1)
345 idxChar = searchValue.substr(0, 2);
349 var resultsPageWithSearch;
355 var hexCode=idx.toString(16);
356 resultsPage = this.resultsPath +
'/' +
indexSectionNames[this.searchIndex] +
'_' + hexCode +
'.html';
357 resultsPageWithSearch = resultsPage+
'?'+escape(searchValue);
358 hasResultsPage =
true;
362 resultsPage = this.resultsPath +
'/nomatches.html';
363 resultsPageWithSearch = resultsPage;
364 hasResultsPage =
false;
367 window.frames.MSearchResults.location = resultsPageWithSearch;
368 var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
370 if (domPopupSearchResultsWindow.style.display!=
'block')
372 var domSearchBox = this.DOMSearchBox();
373 this.DOMSearchClose().style.display =
'inline';
374 if (this.insideFrame)
376 var domPopupSearchResults = this.DOMPopupSearchResults();
377 domPopupSearchResultsWindow.style.position =
'relative';
378 domPopupSearchResultsWindow.style.display =
'block';
379 var width = document.body.clientWidth - 8;
380 domPopupSearchResultsWindow.style.width = width +
'px';
381 domPopupSearchResults.style.width = width +
'px';
385 var domPopupSearchResults = this.DOMPopupSearchResults();
386 var left =
getXPos(domSearchBox) + 150;
387 var top =
getYPos(domSearchBox) + 20;
388 domPopupSearchResultsWindow.style.display =
'block';
389 left -= domPopupSearchResults.offsetWidth;
390 domPopupSearchResultsWindow.style.top = top +
'px';
391 domPopupSearchResultsWindow.style.left = left +
'px';
395 this.lastSearchValue = searchValue;
396 this.lastResultsPage = resultsPage;
403 this.Activate =
function(isActive)
406 this.DOMPopupSearchResultsWindow().style.display ==
'block'
409 this.DOMSearchBox().className =
'MSearchBoxActive';
411 var searchField = this.DOMSearchField();
413 if (searchField.value ==
this.searchLabel)
415 searchField.value =
'';
416 this.searchActive =
true;
421 this.DOMSearchBox().className =
'MSearchBoxInactive';
422 this.DOMSearchField().value = this.searchLabel;
423 this.searchActive =
false;
424 this.lastSearchValue =
''
425 this.lastResultsPage =
'';
var indexSectionsWithContent