comparison doc/html/search/search.js @ 117:ca2d83d29814 tip master

Merge branch 'release/1.0.5'
author Adam Stark <adamstark.uk@gmail.com>
date Fri, 18 Aug 2023 20:07:33 +0200
parents d6d9df2db3e1
children
comparison
equal deleted inserted replaced
96:c58f01834337 117:ca2d83d29814
1 // Search script generated by doxygen 1 /*
2 // Copyright (C) 2009 by Dimitri van Heesch. 2 @licstart The following is the entire license notice for the JavaScript code in this file.
3 3
4 // The code in this file is loosly based on main.js, part of Natural Docs, 4 The MIT License (MIT)
5 // which is Copyright (C) 2003-2008 Greg Valure 5
6 // Natural Docs is licensed under the GPL. 6 Copyright (C) 1997-2020 by Dimitri van Heesch
7 7
8 var indexSectionsWithContent = 8 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9 { 9 and associated documentation files (the "Software"), to deal in the Software without restriction,
10 0: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011101101000001100101010000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 10 including without limitation the rights to use, copy, modify, merge, publish, distribute,
11 1: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 11 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12 2: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 12 furnished to do so, subject to the following conditions:
13 3: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000011101101000001100101000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 13
14 4: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 14 The above copyright notice and this permission notice shall be included in all copies or
15 5: "0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" 15 substantial portions of the Software.
16 }; 16
17 17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18 var indexSectionNames = 18 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 { 19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 0: "all", 20 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 1: "classes", 21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 2: "files", 22
23 3: "functions", 23 @licend The above is the entire license notice for the JavaScript code in this file
24 4: "enums", 24 */
25 5: "pages"
26 };
27
28 function convertToId(search) 25 function convertToId(search)
29 { 26 {
30 var result = ''; 27 var result = '';
31 for (i=0;i<search.length;i++) 28 for (i=0;i<search.length;i++)
32 { 29 {
33 var c = search.charAt(i); 30 var c = search.charAt(i);
34 var cn = c.charCodeAt(0); 31 var cn = c.charCodeAt(0);
35 if (c.match(/[a-z0-9]/)) 32 if (c.match(/[a-z0-9\u0080-\uFFFF]/))
36 { 33 {
37 result+=c; 34 result+=c;
38 } 35 }
39 else if (cn<16) 36 else if (cn<16)
40 { 37 {
41 result+="_0"+cn.toString(16); 38 result+="_0"+cn.toString(16);
42 } 39 }
43 else 40 else
44 { 41 {
45 result+="_"+cn.toString(16); 42 result+="_"+cn.toString(16);
46 } 43 }
47 } 44 }
48 return result; 45 return result;
74 } 71 }
75 } 72 }
76 return y; 73 return y;
77 } 74 }
78 75
76 var searchResults = new SearchResults("searchResults");
77
79 /* A class handling everything associated with the search panel. 78 /* A class handling everything associated with the search panel.
80 79
81 Parameters: 80 Parameters:
82 name - The name of the global variable that will be 81 name - The name of the global variable that will be
83 storing this instance. Is needed to be able to set timeouts. 82 storing this instance. Is needed to be able to set timeouts.
84 resultPath - path to use for external files 83 resultPath - path to use for external files
85 */ 84 */
86 function SearchBox(name, resultsPath, inFrame, label) 85 function SearchBox(name, resultsPath, extension)
87 { 86 {
88 if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); } 87 if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); }
89 88 if (!extension || extension == "") { extension = ".html"; }
89
90 // ---------- Instance variables 90 // ---------- Instance variables
91 this.name = name; 91 this.name = name;
92 this.resultsPath = resultsPath; 92 this.resultsPath = resultsPath;
93 this.keyTimeout = 0; 93 this.keyTimeout = 0;
94 this.keyTimeoutLength = 500; 94 this.keyTimeoutLength = 500;
96 this.lastSearchValue = ""; 96 this.lastSearchValue = "";
97 this.lastResultsPage = ""; 97 this.lastResultsPage = "";
98 this.hideTimeout = 0; 98 this.hideTimeout = 0;
99 this.searchIndex = 0; 99 this.searchIndex = 0;
100 this.searchActive = false; 100 this.searchActive = false;
101 this.insideFrame = inFrame; 101 this.extension = extension;
102 this.searchLabel = label;
103 102
104 // ----------- DOM Elements 103 // ----------- DOM Elements
105 104
106 this.DOMSearchField = function() 105 this.DOMSearchField = function()
107 { return document.getElementById("MSearchField"); } 106 { return document.getElementById("MSearchField"); }
135 this.OnSearchSelectShow = function() 134 this.OnSearchSelectShow = function()
136 { 135 {
137 var searchSelectWindow = this.DOMSearchSelectWindow(); 136 var searchSelectWindow = this.DOMSearchSelectWindow();
138 var searchField = this.DOMSearchSelect(); 137 var searchField = this.DOMSearchSelect();
139 138
140 if (this.insideFrame) 139 var left = getXPos(searchField);
141 { 140 var top = getYPos(searchField);
142 var left = getXPos(searchField); 141 top += searchField.offsetHeight;
143 var top = getYPos(searchField); 142
144 left += searchField.offsetWidth + 6; 143 // show search selection popup
145 top += searchField.offsetHeight; 144 searchSelectWindow.style.display='block';
146 145 searchSelectWindow.style.left = left + 'px';
147 // show search selection popup 146 searchSelectWindow.style.top = top + 'px';
148 searchSelectWindow.style.display='block';
149 left -= searchSelectWindow.offsetWidth;
150 searchSelectWindow.style.left = left + 'px';
151 searchSelectWindow.style.top = top + 'px';
152 }
153 else
154 {
155 var left = getXPos(searchField);
156 var top = getYPos(searchField);
157 top += searchField.offsetHeight;
158
159 // show search selection popup
160 searchSelectWindow.style.display='block';
161 searchSelectWindow.style.left = left + 'px';
162 searchSelectWindow.style.top = top + 'px';
163 }
164 147
165 // stop selection hide timer 148 // stop selection hide timer
166 if (this.hideTimeout) 149 if (this.hideTimeout)
167 { 150 {
168 clearTimeout(this.hideTimeout); 151 clearTimeout(this.hideTimeout);
169 this.hideTimeout=0; 152 this.hideTimeout=0;
170 } 153 }
171 return false; // to avoid "image drag" default event 154 return false; // to avoid "image drag" default event
172 } 155 }
173 156
174 this.OnSearchSelectHide = function() 157 this.OnSearchSelectHide = function()
175 { 158 {
176 this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()", 159 this.hideTimeout = setTimeout(this.CloseSelectionWindow.bind(this),
177 this.closeSelectionTimeout); 160 this.closeSelectionTimeout);
178 } 161 }
179 162
180 // Called when the content of the search field is changed. 163 // Called when the content of the search field is changed.
181 this.OnSearchFieldChange = function(evt) 164 this.OnSearchFieldChange = function(evt)
190 if (e.keyCode==40 || e.keyCode==13) 173 if (e.keyCode==40 || e.keyCode==13)
191 { 174 {
192 if (e.shiftKey==1) 175 if (e.shiftKey==1)
193 { 176 {
194 this.OnSearchSelectShow(); 177 this.OnSearchSelectShow();
195 var win=this.DOMSearchSelectWindow(); 178 var win=this.DOMSearchSelectWindow();
196 for (i=0;i<win.childNodes.length;i++) 179 for (i=0;i<win.childNodes.length;i++)
197 { 180 {
198 var child = win.childNodes[i]; // get span within a 181 var child = win.childNodes[i]; // get span within a
199 if (child.className=='SelectItem') 182 if (child.className=='SelectItem')
200 { 183 {
202 return; 185 return;
203 } 186 }
204 } 187 }
205 return; 188 return;
206 } 189 }
207 else if (window.frames.MSearchResults.searchResults) 190 else
208 { 191 {
209 var elem = window.frames.MSearchResults.searchResults.NavNext(0); 192 var elem = searchResults.NavNext(0);
210 if (elem) elem.focus(); 193 if (elem) elem.focus();
211 } 194 }
212 } 195 }
213 else if (e.keyCode==27) // Escape out of the search field 196 else if (e.keyCode==27) // Escape out of the search field
214 { 197 {
226 if (searchValue != this.lastSearchValue) // search value has changed 209 if (searchValue != this.lastSearchValue) // search value has changed
227 { 210 {
228 if (searchValue != "") // non-empty search 211 if (searchValue != "") // non-empty search
229 { 212 {
230 // set timer for search update 213 // set timer for search update
231 this.keyTimeout = setTimeout(this.name + '.Search()', 214 this.keyTimeout = setTimeout(this.Search.bind(this),
232 this.keyTimeoutLength); 215 this.keyTimeoutLength);
233 } 216 }
234 else // empty search field 217 else // empty search field
235 { 218 {
236 this.DOMPopupSearchResultsWindow().style.display = 'none'; 219 this.DOMPopupSearchResultsWindow().style.display = 'none';
241 } 224 }
242 225
243 this.SelectItemCount = function(id) 226 this.SelectItemCount = function(id)
244 { 227 {
245 var count=0; 228 var count=0;
246 var win=this.DOMSearchSelectWindow(); 229 var win=this.DOMSearchSelectWindow();
247 for (i=0;i<win.childNodes.length;i++) 230 for (i=0;i<win.childNodes.length;i++)
248 { 231 {
249 var child = win.childNodes[i]; // get span within a 232 var child = win.childNodes[i]; // get span within a
250 if (child.className=='SelectItem') 233 if (child.className=='SelectItem')
251 { 234 {
256 } 239 }
257 240
258 this.SelectItemSet = function(id) 241 this.SelectItemSet = function(id)
259 { 242 {
260 var i,j=0; 243 var i,j=0;
261 var win=this.DOMSearchSelectWindow(); 244 var win=this.DOMSearchSelectWindow();
262 for (i=0;i<win.childNodes.length;i++) 245 for (i=0;i<win.childNodes.length;i++)
263 { 246 {
264 var child = win.childNodes[i]; // get span within a 247 var child = win.childNodes[i]; // get span within a
265 if (child.className=='SelectItem') 248 if (child.className=='SelectItem')
266 { 249 {
335 318
336 // strip leading whitespace 319 // strip leading whitespace
337 var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); 320 var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
338 321
339 var code = searchValue.toLowerCase().charCodeAt(0); 322 var code = searchValue.toLowerCase().charCodeAt(0);
340 var hexCode; 323 var idxChar = searchValue.substr(0, 1).toLowerCase();
341 if (code<16) 324 if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
342 { 325 {
343 hexCode="0"+code.toString(16); 326 idxChar = searchValue.substr(0, 2);
344 } 327 }
345 else 328
346 { 329 var jsFile;
347 hexCode=code.toString(16); 330
348 } 331 var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
349 332 if (idx!=-1)
350 var resultsPage; 333 {
351 var resultsPageWithSearch; 334 var hexCode=idx.toString(16);
352 var hasResultsPage; 335 jsFile = this.resultsPath + indexSectionNames[this.searchIndex] + '_' + hexCode + '.js';
353 336 }
354 if (indexSectionsWithContent[this.searchIndex].charAt(code) == '1') 337
355 { 338 var loadJS = function(url, impl, loc){
356 resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; 339 var scriptTag = document.createElement('script');
357 resultsPageWithSearch = resultsPage+'?'+escape(searchValue); 340 scriptTag.src = url;
358 hasResultsPage = true; 341 scriptTag.onload = impl;
359 } 342 scriptTag.onreadystatechange = impl;
360 else // nothing available for this search term 343 loc.appendChild(scriptTag);
361 { 344 }
362 resultsPage = this.resultsPath + '/nomatches.html'; 345
363 resultsPageWithSearch = resultsPage;
364 hasResultsPage = false;
365 }
366
367 window.frames.MSearchResults.location = resultsPageWithSearch;
368 var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); 346 var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
369 347 var domSearchBox = this.DOMSearchBox();
370 if (domPopupSearchResultsWindow.style.display!='block') 348 var domPopupSearchResults = this.DOMPopupSearchResults();
371 { 349 var domSearchClose = this.DOMSearchClose();
372 var domSearchBox = this.DOMSearchBox(); 350 var resultsPath = this.resultsPath;
373 this.DOMSearchClose().style.display = 'inline'; 351
374 if (this.insideFrame) 352 var handleResults = function() {
375 { 353 document.getElementById("Loading").style.display="none";
376 var domPopupSearchResults = this.DOMPopupSearchResults(); 354 if (typeof searchData !== 'undefined') {
377 domPopupSearchResultsWindow.style.position = 'relative'; 355 createResults(resultsPath);
378 domPopupSearchResultsWindow.style.display = 'block'; 356 document.getElementById("NoMatches").style.display="none";
379 var width = document.body.clientWidth - 8; // the -8 is for IE :-( 357 }
380 domPopupSearchResultsWindow.style.width = width + 'px'; 358
381 domPopupSearchResults.style.width = width + 'px'; 359 if (idx!=-1) {
382 } 360 searchResults.Search(searchValue);
383 else 361 } else { // no file with search results => force empty search results
384 { 362 searchResults.Search('====');
385 var domPopupSearchResults = this.DOMPopupSearchResults(); 363 }
386 var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; 364
387 var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; 365 if (domPopupSearchResultsWindow.style.display!='block')
388 domPopupSearchResultsWindow.style.display = 'block'; 366 {
389 left -= domPopupSearchResults.offsetWidth; 367 domSearchClose.style.display = 'inline-block';
390 domPopupSearchResultsWindow.style.top = top + 'px'; 368 var left = getXPos(domSearchBox) + 150;
391 domPopupSearchResultsWindow.style.left = left + 'px'; 369 var top = getYPos(domSearchBox) + 20;
392 } 370 domPopupSearchResultsWindow.style.display = 'block';
371 left -= domPopupSearchResults.offsetWidth;
372 var maxWidth = document.body.clientWidth;
373 var maxHeight = document.body.clientHeight;
374 var width = 300;
375 if (left<10) left=10;
376 if (width+left+8>maxWidth) width=maxWidth-left-8;
377 var height = 400;
378 if (height+top+8>maxHeight) height=maxHeight-top-8;
379 domPopupSearchResultsWindow.style.top = top + 'px';
380 domPopupSearchResultsWindow.style.left = left + 'px';
381 domPopupSearchResultsWindow.style.width = width + 'px';
382 domPopupSearchResultsWindow.style.height = height + 'px';
383 }
384 }
385
386 if (jsFile) {
387 loadJS(jsFile, handleResults, this.DOMPopupSearchResultsWindow());
388 } else {
389 handleResults();
393 } 390 }
394 391
395 this.lastSearchValue = searchValue; 392 this.lastSearchValue = searchValue;
396 this.lastResultsPage = resultsPage;
397 } 393 }
398 394
399 // -------- Activation Functions 395 // -------- Activation Functions
400 396
401 // Activates or deactivates the search panel, resetting things to 397 // Activates or deactivates the search panel, resetting things to
402 // their default values if necessary. 398 // their default values if necessary.
403 this.Activate = function(isActive) 399 this.Activate = function(isActive)
404 { 400 {
405 if (isActive || // open it 401 if (isActive || // open it
406 this.DOMPopupSearchResultsWindow().style.display == 'block' 402 this.DOMPopupSearchResultsWindow().style.display == 'block'
407 ) 403 )
408 { 404 {
409 this.DOMSearchBox().className = 'MSearchBoxActive'; 405 this.DOMSearchBox().className = 'MSearchBoxActive';
410 406 this.searchActive = true;
411 var searchField = this.DOMSearchField();
412
413 if (searchField.value == this.searchLabel) // clear "Search" term upon entry
414 {
415 searchField.value = '';
416 this.searchActive = true;
417 }
418 } 407 }
419 else if (!isActive) // directly remove the panel 408 else if (!isActive) // directly remove the panel
420 { 409 {
421 this.DOMSearchBox().className = 'MSearchBoxInactive'; 410 this.DOMSearchBox().className = 'MSearchBoxInactive';
422 this.DOMSearchField().value = this.searchLabel;
423 this.searchActive = false; 411 this.searchActive = false;
424 this.lastSearchValue = '' 412 this.lastSearchValue = ''
425 this.lastResultsPage = ''; 413 this.lastResultsPage = '';
414 this.DOMSearchField().value = '';
426 } 415 }
427 } 416 }
428 } 417 }
429 418
430 // ----------------------------------------------------------------------- 419 // -----------------------------------------------------------------------
443 var parentElement = document.getElementById(id); 432 var parentElement = document.getElementById(id);
444 var element = parentElement.firstChild; 433 var element = parentElement.firstChild;
445 434
446 while (element && element!=parentElement) 435 while (element && element!=parentElement)
447 { 436 {
448 if (element.nodeName == 'DIV' && element.className == 'SRChildren') 437 if (element.nodeName.toLowerCase() == 'div' && element.className == 'SRChildren')
449 { 438 {
450 return element; 439 return element;
451 } 440 }
452 441
453 if (element.nodeName == 'DIV' && element.hasChildNodes()) 442 if (element.nodeName.toLowerCase() == 'div' && element.hasChildNodes())
454 { 443 {
455 element = element.firstChild; 444 element = element.firstChild;
456 } 445 }
457 else if (element.nextSibling) 446 else if (element.nextSibling)
458 { 447 {
459 element = element.nextSibling; 448 element = element.nextSibling;
460 } 449 }
461 else 450 else
462 { 451 {
463 do 452 do
464 { 453 {
465 element = element.parentNode; 454 element = element.parentNode;
466 } 455 }
467 while (element && element!=parentElement && !element.nextSibling); 456 while (element && element!=parentElement && !element.nextSibling);
468 457
469 if (element && element!=parentElement) 458 if (element && element!=parentElement)
470 { 459 {
471 element = element.nextSibling; 460 element = element.nextSibling;
472 } 461 }
473 } 462 }
474 } 463 }
475 } 464 }
476 465
519 if (row.className == "SRResult") 508 if (row.className == "SRResult")
520 { 509 {
521 var rowMatchName = row.id.toLowerCase(); 510 var rowMatchName = row.id.toLowerCase();
522 rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' 511 rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
523 512
524 if (search.length<=rowMatchName.length && 513 if (search.length<=rowMatchName.length &&
525 rowMatchName.substr(0, search.length)==search) 514 rowMatchName.substr(0, search.length)==search)
526 { 515 {
527 row.style.display = 'block'; 516 row.style.display = 'block';
528 matches++; 517 matches++;
529 } 518 }
590 return focusItem; 579 return focusItem;
591 } 580 }
592 581
593 this.ProcessKeys = function(e) 582 this.ProcessKeys = function(e)
594 { 583 {
595 if (e.type == "keydown") 584 if (e.type == "keydown")
596 { 585 {
597 this.repeatOn = false; 586 this.repeatOn = false;
598 this.lastKey = e.keyCode; 587 this.lastKey = e.keyCode;
599 } 588 }
600 else if (e.type == "keypress") 589 else if (e.type == "keypress")
611 this.repeatOn = false; 600 this.repeatOn = false;
612 } 601 }
613 return this.lastKey!=0; 602 return this.lastKey!=0;
614 } 603 }
615 604
616 this.Nav = function(evt,itemIndex) 605 this.Nav = function(evt,itemIndex)
617 { 606 {
618 var e = (evt) ? evt : window.event; // for IE 607 var e = (evt) ? evt : window.event; // for IE
619 if (e.keyCode==13) return true; 608 if (e.keyCode==13) return true;
620 if (!this.ProcessKeys(e)) return false; 609 if (!this.ProcessKeys(e)) return false;
621 610
625 var focusItem = this.NavPrev(newIndex); 614 var focusItem = this.NavPrev(newIndex);
626 if (focusItem) 615 if (focusItem)
627 { 616 {
628 var child = this.FindChildElement(focusItem.parentNode.parentNode.id); 617 var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
629 if (child && child.style.display == 'block') // children visible 618 if (child && child.style.display == 'block') // children visible
630 { 619 {
631 var n=0; 620 var n=0;
632 var tmpElem; 621 var tmpElem;
633 while (1) // search for last child 622 while (1) // search for last child
634 { 623 {
635 tmpElem = document.getElementById('Item'+newIndex+'_c'+n); 624 tmpElem = document.getElementById('Item'+newIndex+'_c'+n);
649 { 638 {
650 focusItem.focus(); 639 focusItem.focus();
651 } 640 }
652 else // return focus to search field 641 else // return focus to search field
653 { 642 {
654 parent.document.getElementById("MSearchField").focus(); 643 document.getElementById("MSearchField").focus();
655 } 644 }
656 } 645 }
657 else if (this.lastKey==40) // Down 646 else if (this.lastKey==40) // Down
658 { 647 {
659 var newIndex = itemIndex+1; 648 var newIndex = itemIndex+1;
679 var elem = this.FindChildElement(item.parentNode.parentNode.id); 668 var elem = this.FindChildElement(item.parentNode.parentNode.id);
680 if (elem) elem.style.display = 'none'; 669 if (elem) elem.style.display = 'none';
681 } 670 }
682 else if (this.lastKey==27) // Escape 671 else if (this.lastKey==27) // Escape
683 { 672 {
684 parent.searchBox.CloseResultsWindow(); 673 searchBox.CloseResultsWindow();
685 parent.document.getElementById("MSearchField").focus(); 674 document.getElementById("MSearchField").focus();
686 } 675 }
687 else if (this.lastKey==13) // Enter 676 else if (this.lastKey==13) // Enter
688 { 677 {
689 return true; 678 return true;
690 } 679 }
718 elem = this.NavNext(itemIndex+1); 707 elem = this.NavNext(itemIndex+1);
719 } 708 }
720 if (elem) 709 if (elem)
721 { 710 {
722 elem.focus(); 711 elem.focus();
723 } 712 }
724 } 713 }
725 else if (this.lastKey==27) // Escape 714 else if (this.lastKey==27) // Escape
726 { 715 {
727 parent.searchBox.CloseResultsWindow(); 716 searchBox.CloseResultsWindow();
728 parent.document.getElementById("MSearchField").focus(); 717 document.getElementById("MSearchField").focus();
729 } 718 }
730 else if (this.lastKey==13) // Enter 719 else if (this.lastKey==13) // Enter
731 { 720 {
732 return true; 721 return true;
733 } 722 }
746 { 735 {
747 elem.setAttribute('class',attr); 736 elem.setAttribute('class',attr);
748 elem.setAttribute('className',attr); 737 elem.setAttribute('className',attr);
749 } 738 }
750 739
751 function createResults() 740 function createResults(resultsPath)
752 { 741 {
753 var results = document.getElementById("SRResults"); 742 var results = document.getElementById("SRResults");
743 results.innerHTML = '';
754 for (var e=0; e<searchData.length; e++) 744 for (var e=0; e<searchData.length; e++)
755 { 745 {
756 var id = searchData[e][0]; 746 var id = searchData[e][0];
757 var srResult = document.createElement('div'); 747 var srResult = document.createElement('div');
758 srResult.setAttribute('id','SR_'+id); 748 srResult.setAttribute('id','SR_'+id);
765 setClassAttr(srLink,'SRSymbol'); 755 setClassAttr(srLink,'SRSymbol');
766 srLink.innerHTML = searchData[e][1][0]; 756 srLink.innerHTML = searchData[e][1][0];
767 srEntry.appendChild(srLink); 757 srEntry.appendChild(srLink);
768 if (searchData[e][1].length==2) // single result 758 if (searchData[e][1].length==2) // single result
769 { 759 {
770 srLink.setAttribute('href',searchData[e][1][1][0]); 760 srLink.setAttribute('href',resultsPath+searchData[e][1][1][0]);
761 srLink.setAttribute('onclick','searchBox.CloseResultsWindow()');
771 if (searchData[e][1][1][1]) 762 if (searchData[e][1][1][1])
772 { 763 {
773 srLink.setAttribute('target','_parent'); 764 srLink.setAttribute('target','_parent');
765 }
766 else
767 {
768 srLink.setAttribute('target','_blank');
774 } 769 }
775 var srScope = document.createElement('span'); 770 var srScope = document.createElement('span');
776 setClassAttr(srScope,'SRScope'); 771 setClassAttr(srScope,'SRScope');
777 srScope.innerHTML = searchData[e][1][1][2]; 772 srScope.innerHTML = searchData[e][1][1][2];
778 srEntry.appendChild(srScope); 773 srEntry.appendChild(srScope);
786 { 781 {
787 var srChild = document.createElement('a'); 782 var srChild = document.createElement('a');
788 srChild.setAttribute('id','Item'+e+'_c'+c); 783 srChild.setAttribute('id','Item'+e+'_c'+c);
789 setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')'); 784 setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
790 setClassAttr(srChild,'SRScope'); 785 setClassAttr(srChild,'SRScope');
791 srChild.setAttribute('href',searchData[e][1][c+1][0]); 786 srChild.setAttribute('href',resultsPath+searchData[e][1][c+1][0]);
787 srChild.setAttribute('onclick','searchBox.CloseResultsWindow()');
792 if (searchData[e][1][c+1][1]) 788 if (searchData[e][1][c+1][1])
793 { 789 {
794 srChild.setAttribute('target','_parent'); 790 srChild.setAttribute('target','_parent');
791 }
792 else
793 {
794 srChild.setAttribute('target','_blank');
795 } 795 }
796 srChild.innerHTML = searchData[e][1][c+1][2]; 796 srChild.innerHTML = searchData[e][1][c+1][2];
797 srChildren.appendChild(srChild); 797 srChildren.appendChild(srChild);
798 } 798 }
799 srEntry.appendChild(srChildren); 799 srEntry.appendChild(srChildren);
801 srResult.appendChild(srEntry); 801 srResult.appendChild(srEntry);
802 results.appendChild(srResult); 802 results.appendChild(srResult);
803 } 803 }
804 } 804 }
805 805
806 function init_search()
807 {
808 var results = document.getElementById("MSearchSelectWindow");
809 for (var key in indexSectionLabels)
810 {
811 var link = document.createElement('a');
812 link.setAttribute('class','SelectItem');
813 link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
814 link.href='javascript:void(0)';
815 link.innerHTML='<span class="SelectionMark">&#160;</span>'+indexSectionLabels[key];
816 results.appendChild(link);
817 }
818 searchBox.OnSelectItem(0);
819 }
820 /* @license-end */