Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
doc/html/search/search.js@13:2b51f5267c92, 2014-08-13 (annotated)
- Committer:
- dan_ackme
- Date:
- Wed Aug 13 03:14:30 2014 -0700
- Revision:
- 13:2b51f5267c92
- Parent:
- 11:ea484e1b7fc4
- Child:
- 29:b6af04b77a56
doc updates
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
dan_ackme | 11:ea484e1b7fc4 | 1 | // Search script generated by doxygen |
dan_ackme | 11:ea484e1b7fc4 | 2 | // Copyright (C) 2009 by Dimitri van Heesch. |
dan_ackme | 11:ea484e1b7fc4 | 3 | |
dan_ackme | 11:ea484e1b7fc4 | 4 | // The code in this file is loosly based on main.js, part of Natural Docs, |
dan_ackme | 11:ea484e1b7fc4 | 5 | // which is Copyright (C) 2003-2008 Greg Valure |
dan_ackme | 11:ea484e1b7fc4 | 6 | // Natural Docs is licensed under the GPL. |
dan_ackme | 11:ea484e1b7fc4 | 7 | |
dan_ackme | 11:ea484e1b7fc4 | 8 | var indexSectionsWithContent = |
dan_ackme | 11:ea484e1b7fc4 | 9 | { |
dan_ackme | 13:2b51f5267c92 | 10 | 0: "acdefghijlmnopqrstuvw", |
dan_ackme | 13:2b51f5267c92 | 11 | 1: "cfhlmnqrsw", |
dan_ackme | 11:ea484e1b7fc4 | 12 | 2: "w", |
dan_ackme | 11:ea484e1b7fc4 | 13 | 3: "cdfghijlmnoprstuw", |
dan_ackme | 11:ea484e1b7fc4 | 14 | 4: "clotv", |
dan_ackme | 11:ea484e1b7fc4 | 15 | 5: "imps", |
dan_ackme | 11:ea484e1b7fc4 | 16 | 6: "fhnsw", |
dan_ackme | 11:ea484e1b7fc4 | 17 | 7: "fnsw", |
dan_ackme | 13:2b51f5267c92 | 18 | 8: "cefhmnstuw", |
dan_ackme | 13:2b51f5267c92 | 19 | 9: "l" |
dan_ackme | 11:ea484e1b7fc4 | 20 | }; |
dan_ackme | 11:ea484e1b7fc4 | 21 | |
dan_ackme | 11:ea484e1b7fc4 | 22 | var indexSectionNames = |
dan_ackme | 11:ea484e1b7fc4 | 23 | { |
dan_ackme | 11:ea484e1b7fc4 | 24 | 0: "all", |
dan_ackme | 11:ea484e1b7fc4 | 25 | 1: "classes", |
dan_ackme | 11:ea484e1b7fc4 | 26 | 2: "namespaces", |
dan_ackme | 11:ea484e1b7fc4 | 27 | 3: "functions", |
dan_ackme | 11:ea484e1b7fc4 | 28 | 4: "variables", |
dan_ackme | 11:ea484e1b7fc4 | 29 | 5: "typedefs", |
dan_ackme | 11:ea484e1b7fc4 | 30 | 6: "enums", |
dan_ackme | 11:ea484e1b7fc4 | 31 | 7: "enumvalues", |
dan_ackme | 11:ea484e1b7fc4 | 32 | 8: "groups", |
dan_ackme | 11:ea484e1b7fc4 | 33 | 9: "pages" |
dan_ackme | 11:ea484e1b7fc4 | 34 | }; |
dan_ackme | 11:ea484e1b7fc4 | 35 | |
dan_ackme | 11:ea484e1b7fc4 | 36 | function convertToId(search) |
dan_ackme | 11:ea484e1b7fc4 | 37 | { |
dan_ackme | 11:ea484e1b7fc4 | 38 | var result = ''; |
dan_ackme | 11:ea484e1b7fc4 | 39 | for (i=0;i<search.length;i++) |
dan_ackme | 11:ea484e1b7fc4 | 40 | { |
dan_ackme | 11:ea484e1b7fc4 | 41 | var c = search.charAt(i); |
dan_ackme | 11:ea484e1b7fc4 | 42 | var cn = c.charCodeAt(0); |
dan_ackme | 11:ea484e1b7fc4 | 43 | if (c.match(/[a-z0-9\u0080-\uFFFF]/)) |
dan_ackme | 11:ea484e1b7fc4 | 44 | { |
dan_ackme | 11:ea484e1b7fc4 | 45 | result+=c; |
dan_ackme | 11:ea484e1b7fc4 | 46 | } |
dan_ackme | 11:ea484e1b7fc4 | 47 | else if (cn<16) |
dan_ackme | 11:ea484e1b7fc4 | 48 | { |
dan_ackme | 11:ea484e1b7fc4 | 49 | result+="_0"+cn.toString(16); |
dan_ackme | 11:ea484e1b7fc4 | 50 | } |
dan_ackme | 11:ea484e1b7fc4 | 51 | else |
dan_ackme | 11:ea484e1b7fc4 | 52 | { |
dan_ackme | 11:ea484e1b7fc4 | 53 | result+="_"+cn.toString(16); |
dan_ackme | 11:ea484e1b7fc4 | 54 | } |
dan_ackme | 11:ea484e1b7fc4 | 55 | } |
dan_ackme | 11:ea484e1b7fc4 | 56 | return result; |
dan_ackme | 11:ea484e1b7fc4 | 57 | } |
dan_ackme | 11:ea484e1b7fc4 | 58 | |
dan_ackme | 11:ea484e1b7fc4 | 59 | function getXPos(item) |
dan_ackme | 11:ea484e1b7fc4 | 60 | { |
dan_ackme | 11:ea484e1b7fc4 | 61 | var x = 0; |
dan_ackme | 11:ea484e1b7fc4 | 62 | if (item.offsetWidth) |
dan_ackme | 11:ea484e1b7fc4 | 63 | { |
dan_ackme | 11:ea484e1b7fc4 | 64 | while (item && item!=document.body) |
dan_ackme | 11:ea484e1b7fc4 | 65 | { |
dan_ackme | 11:ea484e1b7fc4 | 66 | x += item.offsetLeft; |
dan_ackme | 11:ea484e1b7fc4 | 67 | item = item.offsetParent; |
dan_ackme | 11:ea484e1b7fc4 | 68 | } |
dan_ackme | 11:ea484e1b7fc4 | 69 | } |
dan_ackme | 11:ea484e1b7fc4 | 70 | return x; |
dan_ackme | 11:ea484e1b7fc4 | 71 | } |
dan_ackme | 11:ea484e1b7fc4 | 72 | |
dan_ackme | 11:ea484e1b7fc4 | 73 | function getYPos(item) |
dan_ackme | 11:ea484e1b7fc4 | 74 | { |
dan_ackme | 11:ea484e1b7fc4 | 75 | var y = 0; |
dan_ackme | 11:ea484e1b7fc4 | 76 | if (item.offsetWidth) |
dan_ackme | 11:ea484e1b7fc4 | 77 | { |
dan_ackme | 11:ea484e1b7fc4 | 78 | while (item && item!=document.body) |
dan_ackme | 11:ea484e1b7fc4 | 79 | { |
dan_ackme | 11:ea484e1b7fc4 | 80 | y += item.offsetTop; |
dan_ackme | 11:ea484e1b7fc4 | 81 | item = item.offsetParent; |
dan_ackme | 11:ea484e1b7fc4 | 82 | } |
dan_ackme | 11:ea484e1b7fc4 | 83 | } |
dan_ackme | 11:ea484e1b7fc4 | 84 | return y; |
dan_ackme | 11:ea484e1b7fc4 | 85 | } |
dan_ackme | 11:ea484e1b7fc4 | 86 | |
dan_ackme | 11:ea484e1b7fc4 | 87 | /* A class handling everything associated with the search panel. |
dan_ackme | 11:ea484e1b7fc4 | 88 | |
dan_ackme | 11:ea484e1b7fc4 | 89 | Parameters: |
dan_ackme | 11:ea484e1b7fc4 | 90 | name - The name of the global variable that will be |
dan_ackme | 11:ea484e1b7fc4 | 91 | storing this instance. Is needed to be able to set timeouts. |
dan_ackme | 11:ea484e1b7fc4 | 92 | resultPath - path to use for external files |
dan_ackme | 11:ea484e1b7fc4 | 93 | */ |
dan_ackme | 11:ea484e1b7fc4 | 94 | function SearchBox(name, resultsPath, inFrame, label) |
dan_ackme | 11:ea484e1b7fc4 | 95 | { |
dan_ackme | 11:ea484e1b7fc4 | 96 | if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); } |
dan_ackme | 11:ea484e1b7fc4 | 97 | |
dan_ackme | 11:ea484e1b7fc4 | 98 | // ---------- Instance variables |
dan_ackme | 11:ea484e1b7fc4 | 99 | this.name = name; |
dan_ackme | 11:ea484e1b7fc4 | 100 | this.resultsPath = resultsPath; |
dan_ackme | 11:ea484e1b7fc4 | 101 | this.keyTimeout = 0; |
dan_ackme | 11:ea484e1b7fc4 | 102 | this.keyTimeoutLength = 500; |
dan_ackme | 11:ea484e1b7fc4 | 103 | this.closeSelectionTimeout = 300; |
dan_ackme | 11:ea484e1b7fc4 | 104 | this.lastSearchValue = ""; |
dan_ackme | 11:ea484e1b7fc4 | 105 | this.lastResultsPage = ""; |
dan_ackme | 11:ea484e1b7fc4 | 106 | this.hideTimeout = 0; |
dan_ackme | 11:ea484e1b7fc4 | 107 | this.searchIndex = 0; |
dan_ackme | 11:ea484e1b7fc4 | 108 | this.searchActive = false; |
dan_ackme | 11:ea484e1b7fc4 | 109 | this.insideFrame = inFrame; |
dan_ackme | 11:ea484e1b7fc4 | 110 | this.searchLabel = label; |
dan_ackme | 11:ea484e1b7fc4 | 111 | |
dan_ackme | 11:ea484e1b7fc4 | 112 | // ----------- DOM Elements |
dan_ackme | 11:ea484e1b7fc4 | 113 | |
dan_ackme | 11:ea484e1b7fc4 | 114 | this.DOMSearchField = function() |
dan_ackme | 11:ea484e1b7fc4 | 115 | { return document.getElementById("MSearchField"); } |
dan_ackme | 11:ea484e1b7fc4 | 116 | |
dan_ackme | 11:ea484e1b7fc4 | 117 | this.DOMSearchSelect = function() |
dan_ackme | 11:ea484e1b7fc4 | 118 | { return document.getElementById("MSearchSelect"); } |
dan_ackme | 11:ea484e1b7fc4 | 119 | |
dan_ackme | 11:ea484e1b7fc4 | 120 | this.DOMSearchSelectWindow = function() |
dan_ackme | 11:ea484e1b7fc4 | 121 | { return document.getElementById("MSearchSelectWindow"); } |
dan_ackme | 11:ea484e1b7fc4 | 122 | |
dan_ackme | 11:ea484e1b7fc4 | 123 | this.DOMPopupSearchResults = function() |
dan_ackme | 11:ea484e1b7fc4 | 124 | { return document.getElementById("MSearchResults"); } |
dan_ackme | 11:ea484e1b7fc4 | 125 | |
dan_ackme | 11:ea484e1b7fc4 | 126 | this.DOMPopupSearchResultsWindow = function() |
dan_ackme | 11:ea484e1b7fc4 | 127 | { return document.getElementById("MSearchResultsWindow"); } |
dan_ackme | 11:ea484e1b7fc4 | 128 | |
dan_ackme | 11:ea484e1b7fc4 | 129 | this.DOMSearchClose = function() |
dan_ackme | 11:ea484e1b7fc4 | 130 | { return document.getElementById("MSearchClose"); } |
dan_ackme | 11:ea484e1b7fc4 | 131 | |
dan_ackme | 11:ea484e1b7fc4 | 132 | this.DOMSearchBox = function() |
dan_ackme | 11:ea484e1b7fc4 | 133 | { return document.getElementById("MSearchBox"); } |
dan_ackme | 11:ea484e1b7fc4 | 134 | |
dan_ackme | 11:ea484e1b7fc4 | 135 | // ------------ Event Handlers |
dan_ackme | 11:ea484e1b7fc4 | 136 | |
dan_ackme | 11:ea484e1b7fc4 | 137 | // Called when focus is added or removed from the search field. |
dan_ackme | 11:ea484e1b7fc4 | 138 | this.OnSearchFieldFocus = function(isActive) |
dan_ackme | 11:ea484e1b7fc4 | 139 | { |
dan_ackme | 11:ea484e1b7fc4 | 140 | this.Activate(isActive); |
dan_ackme | 11:ea484e1b7fc4 | 141 | } |
dan_ackme | 11:ea484e1b7fc4 | 142 | |
dan_ackme | 11:ea484e1b7fc4 | 143 | this.OnSearchSelectShow = function() |
dan_ackme | 11:ea484e1b7fc4 | 144 | { |
dan_ackme | 11:ea484e1b7fc4 | 145 | var searchSelectWindow = this.DOMSearchSelectWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 146 | var searchField = this.DOMSearchSelect(); |
dan_ackme | 11:ea484e1b7fc4 | 147 | |
dan_ackme | 11:ea484e1b7fc4 | 148 | if (this.insideFrame) |
dan_ackme | 11:ea484e1b7fc4 | 149 | { |
dan_ackme | 11:ea484e1b7fc4 | 150 | var left = getXPos(searchField); |
dan_ackme | 11:ea484e1b7fc4 | 151 | var top = getYPos(searchField); |
dan_ackme | 11:ea484e1b7fc4 | 152 | left += searchField.offsetWidth + 6; |
dan_ackme | 11:ea484e1b7fc4 | 153 | top += searchField.offsetHeight; |
dan_ackme | 11:ea484e1b7fc4 | 154 | |
dan_ackme | 11:ea484e1b7fc4 | 155 | // show search selection popup |
dan_ackme | 11:ea484e1b7fc4 | 156 | searchSelectWindow.style.display='block'; |
dan_ackme | 11:ea484e1b7fc4 | 157 | left -= searchSelectWindow.offsetWidth; |
dan_ackme | 11:ea484e1b7fc4 | 158 | searchSelectWindow.style.left = left + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 159 | searchSelectWindow.style.top = top + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 160 | } |
dan_ackme | 11:ea484e1b7fc4 | 161 | else |
dan_ackme | 11:ea484e1b7fc4 | 162 | { |
dan_ackme | 11:ea484e1b7fc4 | 163 | var left = getXPos(searchField); |
dan_ackme | 11:ea484e1b7fc4 | 164 | var top = getYPos(searchField); |
dan_ackme | 11:ea484e1b7fc4 | 165 | top += searchField.offsetHeight; |
dan_ackme | 11:ea484e1b7fc4 | 166 | |
dan_ackme | 11:ea484e1b7fc4 | 167 | // show search selection popup |
dan_ackme | 11:ea484e1b7fc4 | 168 | searchSelectWindow.style.display='block'; |
dan_ackme | 11:ea484e1b7fc4 | 169 | searchSelectWindow.style.left = left + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 170 | searchSelectWindow.style.top = top + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 171 | } |
dan_ackme | 11:ea484e1b7fc4 | 172 | |
dan_ackme | 11:ea484e1b7fc4 | 173 | // stop selection hide timer |
dan_ackme | 11:ea484e1b7fc4 | 174 | if (this.hideTimeout) |
dan_ackme | 11:ea484e1b7fc4 | 175 | { |
dan_ackme | 11:ea484e1b7fc4 | 176 | clearTimeout(this.hideTimeout); |
dan_ackme | 11:ea484e1b7fc4 | 177 | this.hideTimeout=0; |
dan_ackme | 11:ea484e1b7fc4 | 178 | } |
dan_ackme | 11:ea484e1b7fc4 | 179 | return false; // to avoid "image drag" default event |
dan_ackme | 11:ea484e1b7fc4 | 180 | } |
dan_ackme | 11:ea484e1b7fc4 | 181 | |
dan_ackme | 11:ea484e1b7fc4 | 182 | this.OnSearchSelectHide = function() |
dan_ackme | 11:ea484e1b7fc4 | 183 | { |
dan_ackme | 11:ea484e1b7fc4 | 184 | this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()", |
dan_ackme | 11:ea484e1b7fc4 | 185 | this.closeSelectionTimeout); |
dan_ackme | 11:ea484e1b7fc4 | 186 | } |
dan_ackme | 11:ea484e1b7fc4 | 187 | |
dan_ackme | 11:ea484e1b7fc4 | 188 | // Called when the content of the search field is changed. |
dan_ackme | 11:ea484e1b7fc4 | 189 | this.OnSearchFieldChange = function(evt) |
dan_ackme | 11:ea484e1b7fc4 | 190 | { |
dan_ackme | 11:ea484e1b7fc4 | 191 | if (this.keyTimeout) // kill running timer |
dan_ackme | 11:ea484e1b7fc4 | 192 | { |
dan_ackme | 11:ea484e1b7fc4 | 193 | clearTimeout(this.keyTimeout); |
dan_ackme | 11:ea484e1b7fc4 | 194 | this.keyTimeout = 0; |
dan_ackme | 11:ea484e1b7fc4 | 195 | } |
dan_ackme | 11:ea484e1b7fc4 | 196 | |
dan_ackme | 11:ea484e1b7fc4 | 197 | var e = (evt) ? evt : window.event; // for IE |
dan_ackme | 11:ea484e1b7fc4 | 198 | if (e.keyCode==40 || e.keyCode==13) |
dan_ackme | 11:ea484e1b7fc4 | 199 | { |
dan_ackme | 11:ea484e1b7fc4 | 200 | if (e.shiftKey==1) |
dan_ackme | 11:ea484e1b7fc4 | 201 | { |
dan_ackme | 11:ea484e1b7fc4 | 202 | this.OnSearchSelectShow(); |
dan_ackme | 11:ea484e1b7fc4 | 203 | var win=this.DOMSearchSelectWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 204 | for (i=0;i<win.childNodes.length;i++) |
dan_ackme | 11:ea484e1b7fc4 | 205 | { |
dan_ackme | 11:ea484e1b7fc4 | 206 | var child = win.childNodes[i]; // get span within a |
dan_ackme | 11:ea484e1b7fc4 | 207 | if (child.className=='SelectItem') |
dan_ackme | 11:ea484e1b7fc4 | 208 | { |
dan_ackme | 11:ea484e1b7fc4 | 209 | child.focus(); |
dan_ackme | 11:ea484e1b7fc4 | 210 | return; |
dan_ackme | 11:ea484e1b7fc4 | 211 | } |
dan_ackme | 11:ea484e1b7fc4 | 212 | } |
dan_ackme | 11:ea484e1b7fc4 | 213 | return; |
dan_ackme | 11:ea484e1b7fc4 | 214 | } |
dan_ackme | 11:ea484e1b7fc4 | 215 | else if (window.frames.MSearchResults.searchResults) |
dan_ackme | 11:ea484e1b7fc4 | 216 | { |
dan_ackme | 11:ea484e1b7fc4 | 217 | var elem = window.frames.MSearchResults.searchResults.NavNext(0); |
dan_ackme | 11:ea484e1b7fc4 | 218 | if (elem) elem.focus(); |
dan_ackme | 11:ea484e1b7fc4 | 219 | } |
dan_ackme | 11:ea484e1b7fc4 | 220 | } |
dan_ackme | 11:ea484e1b7fc4 | 221 | else if (e.keyCode==27) // Escape out of the search field |
dan_ackme | 11:ea484e1b7fc4 | 222 | { |
dan_ackme | 11:ea484e1b7fc4 | 223 | this.DOMSearchField().blur(); |
dan_ackme | 11:ea484e1b7fc4 | 224 | this.DOMPopupSearchResultsWindow().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 225 | this.DOMSearchClose().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 226 | this.lastSearchValue = ''; |
dan_ackme | 11:ea484e1b7fc4 | 227 | this.Activate(false); |
dan_ackme | 11:ea484e1b7fc4 | 228 | return; |
dan_ackme | 11:ea484e1b7fc4 | 229 | } |
dan_ackme | 11:ea484e1b7fc4 | 230 | |
dan_ackme | 11:ea484e1b7fc4 | 231 | // strip whitespaces |
dan_ackme | 11:ea484e1b7fc4 | 232 | var searchValue = this.DOMSearchField().value.replace(/ +/g, ""); |
dan_ackme | 11:ea484e1b7fc4 | 233 | |
dan_ackme | 11:ea484e1b7fc4 | 234 | if (searchValue != this.lastSearchValue) // search value has changed |
dan_ackme | 11:ea484e1b7fc4 | 235 | { |
dan_ackme | 11:ea484e1b7fc4 | 236 | if (searchValue != "") // non-empty search |
dan_ackme | 11:ea484e1b7fc4 | 237 | { |
dan_ackme | 11:ea484e1b7fc4 | 238 | // set timer for search update |
dan_ackme | 11:ea484e1b7fc4 | 239 | this.keyTimeout = setTimeout(this.name + '.Search()', |
dan_ackme | 11:ea484e1b7fc4 | 240 | this.keyTimeoutLength); |
dan_ackme | 11:ea484e1b7fc4 | 241 | } |
dan_ackme | 11:ea484e1b7fc4 | 242 | else // empty search field |
dan_ackme | 11:ea484e1b7fc4 | 243 | { |
dan_ackme | 11:ea484e1b7fc4 | 244 | this.DOMPopupSearchResultsWindow().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 245 | this.DOMSearchClose().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 246 | this.lastSearchValue = ''; |
dan_ackme | 11:ea484e1b7fc4 | 247 | } |
dan_ackme | 11:ea484e1b7fc4 | 248 | } |
dan_ackme | 11:ea484e1b7fc4 | 249 | } |
dan_ackme | 11:ea484e1b7fc4 | 250 | |
dan_ackme | 11:ea484e1b7fc4 | 251 | this.SelectItemCount = function(id) |
dan_ackme | 11:ea484e1b7fc4 | 252 | { |
dan_ackme | 11:ea484e1b7fc4 | 253 | var count=0; |
dan_ackme | 11:ea484e1b7fc4 | 254 | var win=this.DOMSearchSelectWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 255 | for (i=0;i<win.childNodes.length;i++) |
dan_ackme | 11:ea484e1b7fc4 | 256 | { |
dan_ackme | 11:ea484e1b7fc4 | 257 | var child = win.childNodes[i]; // get span within a |
dan_ackme | 11:ea484e1b7fc4 | 258 | if (child.className=='SelectItem') |
dan_ackme | 11:ea484e1b7fc4 | 259 | { |
dan_ackme | 11:ea484e1b7fc4 | 260 | count++; |
dan_ackme | 11:ea484e1b7fc4 | 261 | } |
dan_ackme | 11:ea484e1b7fc4 | 262 | } |
dan_ackme | 11:ea484e1b7fc4 | 263 | return count; |
dan_ackme | 11:ea484e1b7fc4 | 264 | } |
dan_ackme | 11:ea484e1b7fc4 | 265 | |
dan_ackme | 11:ea484e1b7fc4 | 266 | this.SelectItemSet = function(id) |
dan_ackme | 11:ea484e1b7fc4 | 267 | { |
dan_ackme | 11:ea484e1b7fc4 | 268 | var i,j=0; |
dan_ackme | 11:ea484e1b7fc4 | 269 | var win=this.DOMSearchSelectWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 270 | for (i=0;i<win.childNodes.length;i++) |
dan_ackme | 11:ea484e1b7fc4 | 271 | { |
dan_ackme | 11:ea484e1b7fc4 | 272 | var child = win.childNodes[i]; // get span within a |
dan_ackme | 11:ea484e1b7fc4 | 273 | if (child.className=='SelectItem') |
dan_ackme | 11:ea484e1b7fc4 | 274 | { |
dan_ackme | 11:ea484e1b7fc4 | 275 | var node = child.firstChild; |
dan_ackme | 11:ea484e1b7fc4 | 276 | if (j==id) |
dan_ackme | 11:ea484e1b7fc4 | 277 | { |
dan_ackme | 11:ea484e1b7fc4 | 278 | node.innerHTML='•'; |
dan_ackme | 11:ea484e1b7fc4 | 279 | } |
dan_ackme | 11:ea484e1b7fc4 | 280 | else |
dan_ackme | 11:ea484e1b7fc4 | 281 | { |
dan_ackme | 11:ea484e1b7fc4 | 282 | node.innerHTML=' '; |
dan_ackme | 11:ea484e1b7fc4 | 283 | } |
dan_ackme | 11:ea484e1b7fc4 | 284 | j++; |
dan_ackme | 11:ea484e1b7fc4 | 285 | } |
dan_ackme | 11:ea484e1b7fc4 | 286 | } |
dan_ackme | 11:ea484e1b7fc4 | 287 | } |
dan_ackme | 11:ea484e1b7fc4 | 288 | |
dan_ackme | 11:ea484e1b7fc4 | 289 | // Called when an search filter selection is made. |
dan_ackme | 11:ea484e1b7fc4 | 290 | // set item with index id as the active item |
dan_ackme | 11:ea484e1b7fc4 | 291 | this.OnSelectItem = function(id) |
dan_ackme | 11:ea484e1b7fc4 | 292 | { |
dan_ackme | 11:ea484e1b7fc4 | 293 | this.searchIndex = id; |
dan_ackme | 11:ea484e1b7fc4 | 294 | this.SelectItemSet(id); |
dan_ackme | 11:ea484e1b7fc4 | 295 | var searchValue = this.DOMSearchField().value.replace(/ +/g, ""); |
dan_ackme | 11:ea484e1b7fc4 | 296 | if (searchValue!="" && this.searchActive) // something was found -> do a search |
dan_ackme | 11:ea484e1b7fc4 | 297 | { |
dan_ackme | 11:ea484e1b7fc4 | 298 | this.Search(); |
dan_ackme | 11:ea484e1b7fc4 | 299 | } |
dan_ackme | 11:ea484e1b7fc4 | 300 | } |
dan_ackme | 11:ea484e1b7fc4 | 301 | |
dan_ackme | 11:ea484e1b7fc4 | 302 | this.OnSearchSelectKey = function(evt) |
dan_ackme | 11:ea484e1b7fc4 | 303 | { |
dan_ackme | 11:ea484e1b7fc4 | 304 | var e = (evt) ? evt : window.event; // for IE |
dan_ackme | 11:ea484e1b7fc4 | 305 | if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down |
dan_ackme | 11:ea484e1b7fc4 | 306 | { |
dan_ackme | 11:ea484e1b7fc4 | 307 | this.searchIndex++; |
dan_ackme | 11:ea484e1b7fc4 | 308 | this.OnSelectItem(this.searchIndex); |
dan_ackme | 11:ea484e1b7fc4 | 309 | } |
dan_ackme | 11:ea484e1b7fc4 | 310 | else if (e.keyCode==38 && this.searchIndex>0) // Up |
dan_ackme | 11:ea484e1b7fc4 | 311 | { |
dan_ackme | 11:ea484e1b7fc4 | 312 | this.searchIndex--; |
dan_ackme | 11:ea484e1b7fc4 | 313 | this.OnSelectItem(this.searchIndex); |
dan_ackme | 11:ea484e1b7fc4 | 314 | } |
dan_ackme | 11:ea484e1b7fc4 | 315 | else if (e.keyCode==13 || e.keyCode==27) |
dan_ackme | 11:ea484e1b7fc4 | 316 | { |
dan_ackme | 11:ea484e1b7fc4 | 317 | this.OnSelectItem(this.searchIndex); |
dan_ackme | 11:ea484e1b7fc4 | 318 | this.CloseSelectionWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 319 | this.DOMSearchField().focus(); |
dan_ackme | 11:ea484e1b7fc4 | 320 | } |
dan_ackme | 11:ea484e1b7fc4 | 321 | return false; |
dan_ackme | 11:ea484e1b7fc4 | 322 | } |
dan_ackme | 11:ea484e1b7fc4 | 323 | |
dan_ackme | 11:ea484e1b7fc4 | 324 | // --------- Actions |
dan_ackme | 11:ea484e1b7fc4 | 325 | |
dan_ackme | 11:ea484e1b7fc4 | 326 | // Closes the results window. |
dan_ackme | 11:ea484e1b7fc4 | 327 | this.CloseResultsWindow = function() |
dan_ackme | 11:ea484e1b7fc4 | 328 | { |
dan_ackme | 11:ea484e1b7fc4 | 329 | this.DOMPopupSearchResultsWindow().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 330 | this.DOMSearchClose().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 331 | this.Activate(false); |
dan_ackme | 11:ea484e1b7fc4 | 332 | } |
dan_ackme | 11:ea484e1b7fc4 | 333 | |
dan_ackme | 11:ea484e1b7fc4 | 334 | this.CloseSelectionWindow = function() |
dan_ackme | 11:ea484e1b7fc4 | 335 | { |
dan_ackme | 11:ea484e1b7fc4 | 336 | this.DOMSearchSelectWindow().style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 337 | } |
dan_ackme | 11:ea484e1b7fc4 | 338 | |
dan_ackme | 11:ea484e1b7fc4 | 339 | // Performs a search. |
dan_ackme | 11:ea484e1b7fc4 | 340 | this.Search = function() |
dan_ackme | 11:ea484e1b7fc4 | 341 | { |
dan_ackme | 11:ea484e1b7fc4 | 342 | this.keyTimeout = 0; |
dan_ackme | 11:ea484e1b7fc4 | 343 | |
dan_ackme | 11:ea484e1b7fc4 | 344 | // strip leading whitespace |
dan_ackme | 11:ea484e1b7fc4 | 345 | var searchValue = this.DOMSearchField().value.replace(/^ +/, ""); |
dan_ackme | 11:ea484e1b7fc4 | 346 | |
dan_ackme | 11:ea484e1b7fc4 | 347 | var code = searchValue.toLowerCase().charCodeAt(0); |
dan_ackme | 11:ea484e1b7fc4 | 348 | var idxChar = searchValue.substr(0, 1).toLowerCase(); |
dan_ackme | 11:ea484e1b7fc4 | 349 | if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair |
dan_ackme | 11:ea484e1b7fc4 | 350 | { |
dan_ackme | 11:ea484e1b7fc4 | 351 | idxChar = searchValue.substr(0, 2); |
dan_ackme | 11:ea484e1b7fc4 | 352 | } |
dan_ackme | 11:ea484e1b7fc4 | 353 | |
dan_ackme | 11:ea484e1b7fc4 | 354 | var resultsPage; |
dan_ackme | 11:ea484e1b7fc4 | 355 | var resultsPageWithSearch; |
dan_ackme | 11:ea484e1b7fc4 | 356 | var hasResultsPage; |
dan_ackme | 11:ea484e1b7fc4 | 357 | |
dan_ackme | 11:ea484e1b7fc4 | 358 | var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar); |
dan_ackme | 11:ea484e1b7fc4 | 359 | if (idx!=-1) |
dan_ackme | 11:ea484e1b7fc4 | 360 | { |
dan_ackme | 11:ea484e1b7fc4 | 361 | var hexCode=idx.toString(16); |
dan_ackme | 11:ea484e1b7fc4 | 362 | resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html'; |
dan_ackme | 11:ea484e1b7fc4 | 363 | resultsPageWithSearch = resultsPage+'?'+escape(searchValue); |
dan_ackme | 11:ea484e1b7fc4 | 364 | hasResultsPage = true; |
dan_ackme | 11:ea484e1b7fc4 | 365 | } |
dan_ackme | 11:ea484e1b7fc4 | 366 | else // nothing available for this search term |
dan_ackme | 11:ea484e1b7fc4 | 367 | { |
dan_ackme | 11:ea484e1b7fc4 | 368 | resultsPage = this.resultsPath + '/nomatches.html'; |
dan_ackme | 11:ea484e1b7fc4 | 369 | resultsPageWithSearch = resultsPage; |
dan_ackme | 11:ea484e1b7fc4 | 370 | hasResultsPage = false; |
dan_ackme | 11:ea484e1b7fc4 | 371 | } |
dan_ackme | 11:ea484e1b7fc4 | 372 | |
dan_ackme | 11:ea484e1b7fc4 | 373 | window.frames.MSearchResults.location = resultsPageWithSearch; |
dan_ackme | 11:ea484e1b7fc4 | 374 | var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 375 | |
dan_ackme | 11:ea484e1b7fc4 | 376 | if (domPopupSearchResultsWindow.style.display!='block') |
dan_ackme | 11:ea484e1b7fc4 | 377 | { |
dan_ackme | 11:ea484e1b7fc4 | 378 | var domSearchBox = this.DOMSearchBox(); |
dan_ackme | 11:ea484e1b7fc4 | 379 | this.DOMSearchClose().style.display = 'inline'; |
dan_ackme | 11:ea484e1b7fc4 | 380 | if (this.insideFrame) |
dan_ackme | 11:ea484e1b7fc4 | 381 | { |
dan_ackme | 11:ea484e1b7fc4 | 382 | var domPopupSearchResults = this.DOMPopupSearchResults(); |
dan_ackme | 11:ea484e1b7fc4 | 383 | domPopupSearchResultsWindow.style.position = 'relative'; |
dan_ackme | 11:ea484e1b7fc4 | 384 | domPopupSearchResultsWindow.style.display = 'block'; |
dan_ackme | 11:ea484e1b7fc4 | 385 | var width = document.body.clientWidth - 8; // the -8 is for IE :-( |
dan_ackme | 11:ea484e1b7fc4 | 386 | domPopupSearchResultsWindow.style.width = width + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 387 | domPopupSearchResults.style.width = width + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 388 | } |
dan_ackme | 11:ea484e1b7fc4 | 389 | else |
dan_ackme | 11:ea484e1b7fc4 | 390 | { |
dan_ackme | 11:ea484e1b7fc4 | 391 | var domPopupSearchResults = this.DOMPopupSearchResults(); |
dan_ackme | 11:ea484e1b7fc4 | 392 | var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth; |
dan_ackme | 11:ea484e1b7fc4 | 393 | var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1; |
dan_ackme | 11:ea484e1b7fc4 | 394 | domPopupSearchResultsWindow.style.display = 'block'; |
dan_ackme | 11:ea484e1b7fc4 | 395 | left -= domPopupSearchResults.offsetWidth; |
dan_ackme | 11:ea484e1b7fc4 | 396 | domPopupSearchResultsWindow.style.top = top + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 397 | domPopupSearchResultsWindow.style.left = left + 'px'; |
dan_ackme | 11:ea484e1b7fc4 | 398 | } |
dan_ackme | 11:ea484e1b7fc4 | 399 | } |
dan_ackme | 11:ea484e1b7fc4 | 400 | |
dan_ackme | 11:ea484e1b7fc4 | 401 | this.lastSearchValue = searchValue; |
dan_ackme | 11:ea484e1b7fc4 | 402 | this.lastResultsPage = resultsPage; |
dan_ackme | 11:ea484e1b7fc4 | 403 | } |
dan_ackme | 11:ea484e1b7fc4 | 404 | |
dan_ackme | 11:ea484e1b7fc4 | 405 | // -------- Activation Functions |
dan_ackme | 11:ea484e1b7fc4 | 406 | |
dan_ackme | 11:ea484e1b7fc4 | 407 | // Activates or deactivates the search panel, resetting things to |
dan_ackme | 11:ea484e1b7fc4 | 408 | // their default values if necessary. |
dan_ackme | 11:ea484e1b7fc4 | 409 | this.Activate = function(isActive) |
dan_ackme | 11:ea484e1b7fc4 | 410 | { |
dan_ackme | 11:ea484e1b7fc4 | 411 | if (isActive || // open it |
dan_ackme | 11:ea484e1b7fc4 | 412 | this.DOMPopupSearchResultsWindow().style.display == 'block' |
dan_ackme | 11:ea484e1b7fc4 | 413 | ) |
dan_ackme | 11:ea484e1b7fc4 | 414 | { |
dan_ackme | 11:ea484e1b7fc4 | 415 | this.DOMSearchBox().className = 'MSearchBoxActive'; |
dan_ackme | 11:ea484e1b7fc4 | 416 | |
dan_ackme | 11:ea484e1b7fc4 | 417 | var searchField = this.DOMSearchField(); |
dan_ackme | 11:ea484e1b7fc4 | 418 | |
dan_ackme | 11:ea484e1b7fc4 | 419 | if (searchField.value == this.searchLabel) // clear "Search" term upon entry |
dan_ackme | 11:ea484e1b7fc4 | 420 | { |
dan_ackme | 11:ea484e1b7fc4 | 421 | searchField.value = ''; |
dan_ackme | 11:ea484e1b7fc4 | 422 | this.searchActive = true; |
dan_ackme | 11:ea484e1b7fc4 | 423 | } |
dan_ackme | 11:ea484e1b7fc4 | 424 | } |
dan_ackme | 11:ea484e1b7fc4 | 425 | else if (!isActive) // directly remove the panel |
dan_ackme | 11:ea484e1b7fc4 | 426 | { |
dan_ackme | 11:ea484e1b7fc4 | 427 | this.DOMSearchBox().className = 'MSearchBoxInactive'; |
dan_ackme | 11:ea484e1b7fc4 | 428 | this.DOMSearchField().value = this.searchLabel; |
dan_ackme | 11:ea484e1b7fc4 | 429 | this.searchActive = false; |
dan_ackme | 11:ea484e1b7fc4 | 430 | this.lastSearchValue = '' |
dan_ackme | 11:ea484e1b7fc4 | 431 | this.lastResultsPage = ''; |
dan_ackme | 11:ea484e1b7fc4 | 432 | } |
dan_ackme | 11:ea484e1b7fc4 | 433 | } |
dan_ackme | 11:ea484e1b7fc4 | 434 | } |
dan_ackme | 11:ea484e1b7fc4 | 435 | |
dan_ackme | 11:ea484e1b7fc4 | 436 | // ----------------------------------------------------------------------- |
dan_ackme | 11:ea484e1b7fc4 | 437 | |
dan_ackme | 11:ea484e1b7fc4 | 438 | // The class that handles everything on the search results page. |
dan_ackme | 11:ea484e1b7fc4 | 439 | function SearchResults(name) |
dan_ackme | 11:ea484e1b7fc4 | 440 | { |
dan_ackme | 11:ea484e1b7fc4 | 441 | // The number of matches from the last run of <Search()>. |
dan_ackme | 11:ea484e1b7fc4 | 442 | this.lastMatchCount = 0; |
dan_ackme | 11:ea484e1b7fc4 | 443 | this.lastKey = 0; |
dan_ackme | 11:ea484e1b7fc4 | 444 | this.repeatOn = false; |
dan_ackme | 11:ea484e1b7fc4 | 445 | |
dan_ackme | 11:ea484e1b7fc4 | 446 | // Toggles the visibility of the passed element ID. |
dan_ackme | 11:ea484e1b7fc4 | 447 | this.FindChildElement = function(id) |
dan_ackme | 11:ea484e1b7fc4 | 448 | { |
dan_ackme | 11:ea484e1b7fc4 | 449 | var parentElement = document.getElementById(id); |
dan_ackme | 11:ea484e1b7fc4 | 450 | var element = parentElement.firstChild; |
dan_ackme | 11:ea484e1b7fc4 | 451 | |
dan_ackme | 11:ea484e1b7fc4 | 452 | while (element && element!=parentElement) |
dan_ackme | 11:ea484e1b7fc4 | 453 | { |
dan_ackme | 11:ea484e1b7fc4 | 454 | if (element.nodeName == 'DIV' && element.className == 'SRChildren') |
dan_ackme | 11:ea484e1b7fc4 | 455 | { |
dan_ackme | 11:ea484e1b7fc4 | 456 | return element; |
dan_ackme | 11:ea484e1b7fc4 | 457 | } |
dan_ackme | 11:ea484e1b7fc4 | 458 | |
dan_ackme | 11:ea484e1b7fc4 | 459 | if (element.nodeName == 'DIV' && element.hasChildNodes()) |
dan_ackme | 11:ea484e1b7fc4 | 460 | { |
dan_ackme | 11:ea484e1b7fc4 | 461 | element = element.firstChild; |
dan_ackme | 11:ea484e1b7fc4 | 462 | } |
dan_ackme | 11:ea484e1b7fc4 | 463 | else if (element.nextSibling) |
dan_ackme | 11:ea484e1b7fc4 | 464 | { |
dan_ackme | 11:ea484e1b7fc4 | 465 | element = element.nextSibling; |
dan_ackme | 11:ea484e1b7fc4 | 466 | } |
dan_ackme | 11:ea484e1b7fc4 | 467 | else |
dan_ackme | 11:ea484e1b7fc4 | 468 | { |
dan_ackme | 11:ea484e1b7fc4 | 469 | do |
dan_ackme | 11:ea484e1b7fc4 | 470 | { |
dan_ackme | 11:ea484e1b7fc4 | 471 | element = element.parentNode; |
dan_ackme | 11:ea484e1b7fc4 | 472 | } |
dan_ackme | 11:ea484e1b7fc4 | 473 | while (element && element!=parentElement && !element.nextSibling); |
dan_ackme | 11:ea484e1b7fc4 | 474 | |
dan_ackme | 11:ea484e1b7fc4 | 475 | if (element && element!=parentElement) |
dan_ackme | 11:ea484e1b7fc4 | 476 | { |
dan_ackme | 11:ea484e1b7fc4 | 477 | element = element.nextSibling; |
dan_ackme | 11:ea484e1b7fc4 | 478 | } |
dan_ackme | 11:ea484e1b7fc4 | 479 | } |
dan_ackme | 11:ea484e1b7fc4 | 480 | } |
dan_ackme | 11:ea484e1b7fc4 | 481 | } |
dan_ackme | 11:ea484e1b7fc4 | 482 | |
dan_ackme | 11:ea484e1b7fc4 | 483 | this.Toggle = function(id) |
dan_ackme | 11:ea484e1b7fc4 | 484 | { |
dan_ackme | 11:ea484e1b7fc4 | 485 | var element = this.FindChildElement(id); |
dan_ackme | 11:ea484e1b7fc4 | 486 | if (element) |
dan_ackme | 11:ea484e1b7fc4 | 487 | { |
dan_ackme | 11:ea484e1b7fc4 | 488 | if (element.style.display == 'block') |
dan_ackme | 11:ea484e1b7fc4 | 489 | { |
dan_ackme | 11:ea484e1b7fc4 | 490 | element.style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 491 | } |
dan_ackme | 11:ea484e1b7fc4 | 492 | else |
dan_ackme | 11:ea484e1b7fc4 | 493 | { |
dan_ackme | 11:ea484e1b7fc4 | 494 | element.style.display = 'block'; |
dan_ackme | 11:ea484e1b7fc4 | 495 | } |
dan_ackme | 11:ea484e1b7fc4 | 496 | } |
dan_ackme | 11:ea484e1b7fc4 | 497 | } |
dan_ackme | 11:ea484e1b7fc4 | 498 | |
dan_ackme | 11:ea484e1b7fc4 | 499 | // Searches for the passed string. If there is no parameter, |
dan_ackme | 11:ea484e1b7fc4 | 500 | // it takes it from the URL query. |
dan_ackme | 11:ea484e1b7fc4 | 501 | // |
dan_ackme | 11:ea484e1b7fc4 | 502 | // Always returns true, since other documents may try to call it |
dan_ackme | 11:ea484e1b7fc4 | 503 | // and that may or may not be possible. |
dan_ackme | 11:ea484e1b7fc4 | 504 | this.Search = function(search) |
dan_ackme | 11:ea484e1b7fc4 | 505 | { |
dan_ackme | 11:ea484e1b7fc4 | 506 | if (!search) // get search word from URL |
dan_ackme | 11:ea484e1b7fc4 | 507 | { |
dan_ackme | 11:ea484e1b7fc4 | 508 | search = window.location.search; |
dan_ackme | 11:ea484e1b7fc4 | 509 | search = search.substring(1); // Remove the leading '?' |
dan_ackme | 11:ea484e1b7fc4 | 510 | search = unescape(search); |
dan_ackme | 11:ea484e1b7fc4 | 511 | } |
dan_ackme | 11:ea484e1b7fc4 | 512 | |
dan_ackme | 11:ea484e1b7fc4 | 513 | search = search.replace(/^ +/, ""); // strip leading spaces |
dan_ackme | 11:ea484e1b7fc4 | 514 | search = search.replace(/ +$/, ""); // strip trailing spaces |
dan_ackme | 11:ea484e1b7fc4 | 515 | search = search.toLowerCase(); |
dan_ackme | 11:ea484e1b7fc4 | 516 | search = convertToId(search); |
dan_ackme | 11:ea484e1b7fc4 | 517 | |
dan_ackme | 11:ea484e1b7fc4 | 518 | var resultRows = document.getElementsByTagName("div"); |
dan_ackme | 11:ea484e1b7fc4 | 519 | var matches = 0; |
dan_ackme | 11:ea484e1b7fc4 | 520 | |
dan_ackme | 11:ea484e1b7fc4 | 521 | var i = 0; |
dan_ackme | 11:ea484e1b7fc4 | 522 | while (i < resultRows.length) |
dan_ackme | 11:ea484e1b7fc4 | 523 | { |
dan_ackme | 11:ea484e1b7fc4 | 524 | var row = resultRows.item(i); |
dan_ackme | 11:ea484e1b7fc4 | 525 | if (row.className == "SRResult") |
dan_ackme | 11:ea484e1b7fc4 | 526 | { |
dan_ackme | 11:ea484e1b7fc4 | 527 | var rowMatchName = row.id.toLowerCase(); |
dan_ackme | 11:ea484e1b7fc4 | 528 | rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_' |
dan_ackme | 11:ea484e1b7fc4 | 529 | |
dan_ackme | 11:ea484e1b7fc4 | 530 | if (search.length<=rowMatchName.length && |
dan_ackme | 11:ea484e1b7fc4 | 531 | rowMatchName.substr(0, search.length)==search) |
dan_ackme | 11:ea484e1b7fc4 | 532 | { |
dan_ackme | 11:ea484e1b7fc4 | 533 | row.style.display = 'block'; |
dan_ackme | 11:ea484e1b7fc4 | 534 | matches++; |
dan_ackme | 11:ea484e1b7fc4 | 535 | } |
dan_ackme | 11:ea484e1b7fc4 | 536 | else |
dan_ackme | 11:ea484e1b7fc4 | 537 | { |
dan_ackme | 11:ea484e1b7fc4 | 538 | row.style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 539 | } |
dan_ackme | 11:ea484e1b7fc4 | 540 | } |
dan_ackme | 11:ea484e1b7fc4 | 541 | i++; |
dan_ackme | 11:ea484e1b7fc4 | 542 | } |
dan_ackme | 11:ea484e1b7fc4 | 543 | document.getElementById("Searching").style.display='none'; |
dan_ackme | 11:ea484e1b7fc4 | 544 | if (matches == 0) // no results |
dan_ackme | 11:ea484e1b7fc4 | 545 | { |
dan_ackme | 11:ea484e1b7fc4 | 546 | document.getElementById("NoMatches").style.display='block'; |
dan_ackme | 11:ea484e1b7fc4 | 547 | } |
dan_ackme | 11:ea484e1b7fc4 | 548 | else // at least one result |
dan_ackme | 11:ea484e1b7fc4 | 549 | { |
dan_ackme | 11:ea484e1b7fc4 | 550 | document.getElementById("NoMatches").style.display='none'; |
dan_ackme | 11:ea484e1b7fc4 | 551 | } |
dan_ackme | 11:ea484e1b7fc4 | 552 | this.lastMatchCount = matches; |
dan_ackme | 11:ea484e1b7fc4 | 553 | return true; |
dan_ackme | 11:ea484e1b7fc4 | 554 | } |
dan_ackme | 11:ea484e1b7fc4 | 555 | |
dan_ackme | 11:ea484e1b7fc4 | 556 | // return the first item with index index or higher that is visible |
dan_ackme | 11:ea484e1b7fc4 | 557 | this.NavNext = function(index) |
dan_ackme | 11:ea484e1b7fc4 | 558 | { |
dan_ackme | 11:ea484e1b7fc4 | 559 | var focusItem; |
dan_ackme | 11:ea484e1b7fc4 | 560 | while (1) |
dan_ackme | 11:ea484e1b7fc4 | 561 | { |
dan_ackme | 11:ea484e1b7fc4 | 562 | var focusName = 'Item'+index; |
dan_ackme | 11:ea484e1b7fc4 | 563 | focusItem = document.getElementById(focusName); |
dan_ackme | 11:ea484e1b7fc4 | 564 | if (focusItem && focusItem.parentNode.parentNode.style.display=='block') |
dan_ackme | 11:ea484e1b7fc4 | 565 | { |
dan_ackme | 11:ea484e1b7fc4 | 566 | break; |
dan_ackme | 11:ea484e1b7fc4 | 567 | } |
dan_ackme | 11:ea484e1b7fc4 | 568 | else if (!focusItem) // last element |
dan_ackme | 11:ea484e1b7fc4 | 569 | { |
dan_ackme | 11:ea484e1b7fc4 | 570 | break; |
dan_ackme | 11:ea484e1b7fc4 | 571 | } |
dan_ackme | 11:ea484e1b7fc4 | 572 | focusItem=null; |
dan_ackme | 11:ea484e1b7fc4 | 573 | index++; |
dan_ackme | 11:ea484e1b7fc4 | 574 | } |
dan_ackme | 11:ea484e1b7fc4 | 575 | return focusItem; |
dan_ackme | 11:ea484e1b7fc4 | 576 | } |
dan_ackme | 11:ea484e1b7fc4 | 577 | |
dan_ackme | 11:ea484e1b7fc4 | 578 | this.NavPrev = function(index) |
dan_ackme | 11:ea484e1b7fc4 | 579 | { |
dan_ackme | 11:ea484e1b7fc4 | 580 | var focusItem; |
dan_ackme | 11:ea484e1b7fc4 | 581 | while (1) |
dan_ackme | 11:ea484e1b7fc4 | 582 | { |
dan_ackme | 11:ea484e1b7fc4 | 583 | var focusName = 'Item'+index; |
dan_ackme | 11:ea484e1b7fc4 | 584 | focusItem = document.getElementById(focusName); |
dan_ackme | 11:ea484e1b7fc4 | 585 | if (focusItem && focusItem.parentNode.parentNode.style.display=='block') |
dan_ackme | 11:ea484e1b7fc4 | 586 | { |
dan_ackme | 11:ea484e1b7fc4 | 587 | break; |
dan_ackme | 11:ea484e1b7fc4 | 588 | } |
dan_ackme | 11:ea484e1b7fc4 | 589 | else if (!focusItem) // last element |
dan_ackme | 11:ea484e1b7fc4 | 590 | { |
dan_ackme | 11:ea484e1b7fc4 | 591 | break; |
dan_ackme | 11:ea484e1b7fc4 | 592 | } |
dan_ackme | 11:ea484e1b7fc4 | 593 | focusItem=null; |
dan_ackme | 11:ea484e1b7fc4 | 594 | index--; |
dan_ackme | 11:ea484e1b7fc4 | 595 | } |
dan_ackme | 11:ea484e1b7fc4 | 596 | return focusItem; |
dan_ackme | 11:ea484e1b7fc4 | 597 | } |
dan_ackme | 11:ea484e1b7fc4 | 598 | |
dan_ackme | 11:ea484e1b7fc4 | 599 | this.ProcessKeys = function(e) |
dan_ackme | 11:ea484e1b7fc4 | 600 | { |
dan_ackme | 11:ea484e1b7fc4 | 601 | if (e.type == "keydown") |
dan_ackme | 11:ea484e1b7fc4 | 602 | { |
dan_ackme | 11:ea484e1b7fc4 | 603 | this.repeatOn = false; |
dan_ackme | 11:ea484e1b7fc4 | 604 | this.lastKey = e.keyCode; |
dan_ackme | 11:ea484e1b7fc4 | 605 | } |
dan_ackme | 11:ea484e1b7fc4 | 606 | else if (e.type == "keypress") |
dan_ackme | 11:ea484e1b7fc4 | 607 | { |
dan_ackme | 11:ea484e1b7fc4 | 608 | if (!this.repeatOn) |
dan_ackme | 11:ea484e1b7fc4 | 609 | { |
dan_ackme | 11:ea484e1b7fc4 | 610 | if (this.lastKey) this.repeatOn = true; |
dan_ackme | 11:ea484e1b7fc4 | 611 | return false; // ignore first keypress after keydown |
dan_ackme | 11:ea484e1b7fc4 | 612 | } |
dan_ackme | 11:ea484e1b7fc4 | 613 | } |
dan_ackme | 11:ea484e1b7fc4 | 614 | else if (e.type == "keyup") |
dan_ackme | 11:ea484e1b7fc4 | 615 | { |
dan_ackme | 11:ea484e1b7fc4 | 616 | this.lastKey = 0; |
dan_ackme | 11:ea484e1b7fc4 | 617 | this.repeatOn = false; |
dan_ackme | 11:ea484e1b7fc4 | 618 | } |
dan_ackme | 11:ea484e1b7fc4 | 619 | return this.lastKey!=0; |
dan_ackme | 11:ea484e1b7fc4 | 620 | } |
dan_ackme | 11:ea484e1b7fc4 | 621 | |
dan_ackme | 11:ea484e1b7fc4 | 622 | this.Nav = function(evt,itemIndex) |
dan_ackme | 11:ea484e1b7fc4 | 623 | { |
dan_ackme | 11:ea484e1b7fc4 | 624 | var e = (evt) ? evt : window.event; // for IE |
dan_ackme | 11:ea484e1b7fc4 | 625 | if (e.keyCode==13) return true; |
dan_ackme | 11:ea484e1b7fc4 | 626 | if (!this.ProcessKeys(e)) return false; |
dan_ackme | 11:ea484e1b7fc4 | 627 | |
dan_ackme | 11:ea484e1b7fc4 | 628 | if (this.lastKey==38) // Up |
dan_ackme | 11:ea484e1b7fc4 | 629 | { |
dan_ackme | 11:ea484e1b7fc4 | 630 | var newIndex = itemIndex-1; |
dan_ackme | 11:ea484e1b7fc4 | 631 | var focusItem = this.NavPrev(newIndex); |
dan_ackme | 11:ea484e1b7fc4 | 632 | if (focusItem) |
dan_ackme | 11:ea484e1b7fc4 | 633 | { |
dan_ackme | 11:ea484e1b7fc4 | 634 | var child = this.FindChildElement(focusItem.parentNode.parentNode.id); |
dan_ackme | 11:ea484e1b7fc4 | 635 | if (child && child.style.display == 'block') // children visible |
dan_ackme | 11:ea484e1b7fc4 | 636 | { |
dan_ackme | 11:ea484e1b7fc4 | 637 | var n=0; |
dan_ackme | 11:ea484e1b7fc4 | 638 | var tmpElem; |
dan_ackme | 11:ea484e1b7fc4 | 639 | while (1) // search for last child |
dan_ackme | 11:ea484e1b7fc4 | 640 | { |
dan_ackme | 11:ea484e1b7fc4 | 641 | tmpElem = document.getElementById('Item'+newIndex+'_c'+n); |
dan_ackme | 11:ea484e1b7fc4 | 642 | if (tmpElem) |
dan_ackme | 11:ea484e1b7fc4 | 643 | { |
dan_ackme | 11:ea484e1b7fc4 | 644 | focusItem = tmpElem; |
dan_ackme | 11:ea484e1b7fc4 | 645 | } |
dan_ackme | 11:ea484e1b7fc4 | 646 | else // found it! |
dan_ackme | 11:ea484e1b7fc4 | 647 | { |
dan_ackme | 11:ea484e1b7fc4 | 648 | break; |
dan_ackme | 11:ea484e1b7fc4 | 649 | } |
dan_ackme | 11:ea484e1b7fc4 | 650 | n++; |
dan_ackme | 11:ea484e1b7fc4 | 651 | } |
dan_ackme | 11:ea484e1b7fc4 | 652 | } |
dan_ackme | 11:ea484e1b7fc4 | 653 | } |
dan_ackme | 11:ea484e1b7fc4 | 654 | if (focusItem) |
dan_ackme | 11:ea484e1b7fc4 | 655 | { |
dan_ackme | 11:ea484e1b7fc4 | 656 | focusItem.focus(); |
dan_ackme | 11:ea484e1b7fc4 | 657 | } |
dan_ackme | 11:ea484e1b7fc4 | 658 | else // return focus to search field |
dan_ackme | 11:ea484e1b7fc4 | 659 | { |
dan_ackme | 11:ea484e1b7fc4 | 660 | parent.document.getElementById("MSearchField").focus(); |
dan_ackme | 11:ea484e1b7fc4 | 661 | } |
dan_ackme | 11:ea484e1b7fc4 | 662 | } |
dan_ackme | 11:ea484e1b7fc4 | 663 | else if (this.lastKey==40) // Down |
dan_ackme | 11:ea484e1b7fc4 | 664 | { |
dan_ackme | 11:ea484e1b7fc4 | 665 | var newIndex = itemIndex+1; |
dan_ackme | 11:ea484e1b7fc4 | 666 | var focusItem; |
dan_ackme | 11:ea484e1b7fc4 | 667 | var item = document.getElementById('Item'+itemIndex); |
dan_ackme | 11:ea484e1b7fc4 | 668 | var elem = this.FindChildElement(item.parentNode.parentNode.id); |
dan_ackme | 11:ea484e1b7fc4 | 669 | if (elem && elem.style.display == 'block') // children visible |
dan_ackme | 11:ea484e1b7fc4 | 670 | { |
dan_ackme | 11:ea484e1b7fc4 | 671 | focusItem = document.getElementById('Item'+itemIndex+'_c0'); |
dan_ackme | 11:ea484e1b7fc4 | 672 | } |
dan_ackme | 11:ea484e1b7fc4 | 673 | if (!focusItem) focusItem = this.NavNext(newIndex); |
dan_ackme | 11:ea484e1b7fc4 | 674 | if (focusItem) focusItem.focus(); |
dan_ackme | 11:ea484e1b7fc4 | 675 | } |
dan_ackme | 11:ea484e1b7fc4 | 676 | else if (this.lastKey==39) // Right |
dan_ackme | 11:ea484e1b7fc4 | 677 | { |
dan_ackme | 11:ea484e1b7fc4 | 678 | var item = document.getElementById('Item'+itemIndex); |
dan_ackme | 11:ea484e1b7fc4 | 679 | var elem = this.FindChildElement(item.parentNode.parentNode.id); |
dan_ackme | 11:ea484e1b7fc4 | 680 | if (elem) elem.style.display = 'block'; |
dan_ackme | 11:ea484e1b7fc4 | 681 | } |
dan_ackme | 11:ea484e1b7fc4 | 682 | else if (this.lastKey==37) // Left |
dan_ackme | 11:ea484e1b7fc4 | 683 | { |
dan_ackme | 11:ea484e1b7fc4 | 684 | var item = document.getElementById('Item'+itemIndex); |
dan_ackme | 11:ea484e1b7fc4 | 685 | var elem = this.FindChildElement(item.parentNode.parentNode.id); |
dan_ackme | 11:ea484e1b7fc4 | 686 | if (elem) elem.style.display = 'none'; |
dan_ackme | 11:ea484e1b7fc4 | 687 | } |
dan_ackme | 11:ea484e1b7fc4 | 688 | else if (this.lastKey==27) // Escape |
dan_ackme | 11:ea484e1b7fc4 | 689 | { |
dan_ackme | 11:ea484e1b7fc4 | 690 | parent.searchBox.CloseResultsWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 691 | parent.document.getElementById("MSearchField").focus(); |
dan_ackme | 11:ea484e1b7fc4 | 692 | } |
dan_ackme | 11:ea484e1b7fc4 | 693 | else if (this.lastKey==13) // Enter |
dan_ackme | 11:ea484e1b7fc4 | 694 | { |
dan_ackme | 11:ea484e1b7fc4 | 695 | return true; |
dan_ackme | 11:ea484e1b7fc4 | 696 | } |
dan_ackme | 11:ea484e1b7fc4 | 697 | return false; |
dan_ackme | 11:ea484e1b7fc4 | 698 | } |
dan_ackme | 11:ea484e1b7fc4 | 699 | |
dan_ackme | 11:ea484e1b7fc4 | 700 | this.NavChild = function(evt,itemIndex,childIndex) |
dan_ackme | 11:ea484e1b7fc4 | 701 | { |
dan_ackme | 11:ea484e1b7fc4 | 702 | var e = (evt) ? evt : window.event; // for IE |
dan_ackme | 11:ea484e1b7fc4 | 703 | if (e.keyCode==13) return true; |
dan_ackme | 11:ea484e1b7fc4 | 704 | if (!this.ProcessKeys(e)) return false; |
dan_ackme | 11:ea484e1b7fc4 | 705 | |
dan_ackme | 11:ea484e1b7fc4 | 706 | if (this.lastKey==38) // Up |
dan_ackme | 11:ea484e1b7fc4 | 707 | { |
dan_ackme | 11:ea484e1b7fc4 | 708 | if (childIndex>0) |
dan_ackme | 11:ea484e1b7fc4 | 709 | { |
dan_ackme | 11:ea484e1b7fc4 | 710 | var newIndex = childIndex-1; |
dan_ackme | 11:ea484e1b7fc4 | 711 | document.getElementById('Item'+itemIndex+'_c'+newIndex).focus(); |
dan_ackme | 11:ea484e1b7fc4 | 712 | } |
dan_ackme | 11:ea484e1b7fc4 | 713 | else // already at first child, jump to parent |
dan_ackme | 11:ea484e1b7fc4 | 714 | { |
dan_ackme | 11:ea484e1b7fc4 | 715 | document.getElementById('Item'+itemIndex).focus(); |
dan_ackme | 11:ea484e1b7fc4 | 716 | } |
dan_ackme | 11:ea484e1b7fc4 | 717 | } |
dan_ackme | 11:ea484e1b7fc4 | 718 | else if (this.lastKey==40) // Down |
dan_ackme | 11:ea484e1b7fc4 | 719 | { |
dan_ackme | 11:ea484e1b7fc4 | 720 | var newIndex = childIndex+1; |
dan_ackme | 11:ea484e1b7fc4 | 721 | var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex); |
dan_ackme | 11:ea484e1b7fc4 | 722 | if (!elem) // last child, jump to parent next parent |
dan_ackme | 11:ea484e1b7fc4 | 723 | { |
dan_ackme | 11:ea484e1b7fc4 | 724 | elem = this.NavNext(itemIndex+1); |
dan_ackme | 11:ea484e1b7fc4 | 725 | } |
dan_ackme | 11:ea484e1b7fc4 | 726 | if (elem) |
dan_ackme | 11:ea484e1b7fc4 | 727 | { |
dan_ackme | 11:ea484e1b7fc4 | 728 | elem.focus(); |
dan_ackme | 11:ea484e1b7fc4 | 729 | } |
dan_ackme | 11:ea484e1b7fc4 | 730 | } |
dan_ackme | 11:ea484e1b7fc4 | 731 | else if (this.lastKey==27) // Escape |
dan_ackme | 11:ea484e1b7fc4 | 732 | { |
dan_ackme | 11:ea484e1b7fc4 | 733 | parent.searchBox.CloseResultsWindow(); |
dan_ackme | 11:ea484e1b7fc4 | 734 | parent.document.getElementById("MSearchField").focus(); |
dan_ackme | 11:ea484e1b7fc4 | 735 | } |
dan_ackme | 11:ea484e1b7fc4 | 736 | else if (this.lastKey==13) // Enter |
dan_ackme | 11:ea484e1b7fc4 | 737 | { |
dan_ackme | 11:ea484e1b7fc4 | 738 | return true; |
dan_ackme | 11:ea484e1b7fc4 | 739 | } |
dan_ackme | 11:ea484e1b7fc4 | 740 | return false; |
dan_ackme | 11:ea484e1b7fc4 | 741 | } |
dan_ackme | 11:ea484e1b7fc4 | 742 | } |
dan_ackme | 11:ea484e1b7fc4 | 743 | |
dan_ackme | 11:ea484e1b7fc4 | 744 | function setKeyActions(elem,action) |
dan_ackme | 11:ea484e1b7fc4 | 745 | { |
dan_ackme | 11:ea484e1b7fc4 | 746 | elem.setAttribute('onkeydown',action); |
dan_ackme | 11:ea484e1b7fc4 | 747 | elem.setAttribute('onkeypress',action); |
dan_ackme | 11:ea484e1b7fc4 | 748 | elem.setAttribute('onkeyup',action); |
dan_ackme | 11:ea484e1b7fc4 | 749 | } |
dan_ackme | 11:ea484e1b7fc4 | 750 | |
dan_ackme | 11:ea484e1b7fc4 | 751 | function setClassAttr(elem,attr) |
dan_ackme | 11:ea484e1b7fc4 | 752 | { |
dan_ackme | 11:ea484e1b7fc4 | 753 | elem.setAttribute('class',attr); |
dan_ackme | 11:ea484e1b7fc4 | 754 | elem.setAttribute('className',attr); |
dan_ackme | 11:ea484e1b7fc4 | 755 | } |
dan_ackme | 11:ea484e1b7fc4 | 756 | |
dan_ackme | 11:ea484e1b7fc4 | 757 | function createResults() |
dan_ackme | 11:ea484e1b7fc4 | 758 | { |
dan_ackme | 11:ea484e1b7fc4 | 759 | var results = document.getElementById("SRResults"); |
dan_ackme | 11:ea484e1b7fc4 | 760 | for (var e=0; e<searchData.length; e++) |
dan_ackme | 11:ea484e1b7fc4 | 761 | { |
dan_ackme | 11:ea484e1b7fc4 | 762 | var id = searchData[e][0]; |
dan_ackme | 11:ea484e1b7fc4 | 763 | var srResult = document.createElement('div'); |
dan_ackme | 11:ea484e1b7fc4 | 764 | srResult.setAttribute('id','SR_'+id); |
dan_ackme | 11:ea484e1b7fc4 | 765 | setClassAttr(srResult,'SRResult'); |
dan_ackme | 11:ea484e1b7fc4 | 766 | var srEntry = document.createElement('div'); |
dan_ackme | 11:ea484e1b7fc4 | 767 | setClassAttr(srEntry,'SREntry'); |
dan_ackme | 11:ea484e1b7fc4 | 768 | var srLink = document.createElement('a'); |
dan_ackme | 11:ea484e1b7fc4 | 769 | srLink.setAttribute('id','Item'+e); |
dan_ackme | 11:ea484e1b7fc4 | 770 | setKeyActions(srLink,'return searchResults.Nav(event,'+e+')'); |
dan_ackme | 11:ea484e1b7fc4 | 771 | setClassAttr(srLink,'SRSymbol'); |
dan_ackme | 11:ea484e1b7fc4 | 772 | srLink.innerHTML = searchData[e][1][0]; |
dan_ackme | 11:ea484e1b7fc4 | 773 | srEntry.appendChild(srLink); |
dan_ackme | 11:ea484e1b7fc4 | 774 | if (searchData[e][1].length==2) // single result |
dan_ackme | 11:ea484e1b7fc4 | 775 | { |
dan_ackme | 11:ea484e1b7fc4 | 776 | srLink.setAttribute('href',searchData[e][1][1][0]); |
dan_ackme | 11:ea484e1b7fc4 | 777 | if (searchData[e][1][1][1]) |
dan_ackme | 11:ea484e1b7fc4 | 778 | { |
dan_ackme | 11:ea484e1b7fc4 | 779 | srLink.setAttribute('target','_parent'); |
dan_ackme | 11:ea484e1b7fc4 | 780 | } |
dan_ackme | 11:ea484e1b7fc4 | 781 | var srScope = document.createElement('span'); |
dan_ackme | 11:ea484e1b7fc4 | 782 | setClassAttr(srScope,'SRScope'); |
dan_ackme | 11:ea484e1b7fc4 | 783 | srScope.innerHTML = searchData[e][1][1][2]; |
dan_ackme | 11:ea484e1b7fc4 | 784 | srEntry.appendChild(srScope); |
dan_ackme | 11:ea484e1b7fc4 | 785 | } |
dan_ackme | 11:ea484e1b7fc4 | 786 | else // multiple results |
dan_ackme | 11:ea484e1b7fc4 | 787 | { |
dan_ackme | 11:ea484e1b7fc4 | 788 | srLink.setAttribute('href','javascript:searchResults.Toggle("SR_'+id+'")'); |
dan_ackme | 11:ea484e1b7fc4 | 789 | var srChildren = document.createElement('div'); |
dan_ackme | 11:ea484e1b7fc4 | 790 | setClassAttr(srChildren,'SRChildren'); |
dan_ackme | 11:ea484e1b7fc4 | 791 | for (var c=0; c<searchData[e][1].length-1; c++) |
dan_ackme | 11:ea484e1b7fc4 | 792 | { |
dan_ackme | 11:ea484e1b7fc4 | 793 | var srChild = document.createElement('a'); |
dan_ackme | 11:ea484e1b7fc4 | 794 | srChild.setAttribute('id','Item'+e+'_c'+c); |
dan_ackme | 11:ea484e1b7fc4 | 795 | setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')'); |
dan_ackme | 11:ea484e1b7fc4 | 796 | setClassAttr(srChild,'SRScope'); |
dan_ackme | 11:ea484e1b7fc4 | 797 | srChild.setAttribute('href',searchData[e][1][c+1][0]); |
dan_ackme | 11:ea484e1b7fc4 | 798 | if (searchData[e][1][c+1][1]) |
dan_ackme | 11:ea484e1b7fc4 | 799 | { |
dan_ackme | 11:ea484e1b7fc4 | 800 | srChild.setAttribute('target','_parent'); |
dan_ackme | 11:ea484e1b7fc4 | 801 | } |
dan_ackme | 11:ea484e1b7fc4 | 802 | srChild.innerHTML = searchData[e][1][c+1][2]; |
dan_ackme | 11:ea484e1b7fc4 | 803 | srChildren.appendChild(srChild); |
dan_ackme | 11:ea484e1b7fc4 | 804 | } |
dan_ackme | 11:ea484e1b7fc4 | 805 | srEntry.appendChild(srChildren); |
dan_ackme | 11:ea484e1b7fc4 | 806 | } |
dan_ackme | 11:ea484e1b7fc4 | 807 | srResult.appendChild(srEntry); |
dan_ackme | 11:ea484e1b7fc4 | 808 | results.appendChild(srResult); |
dan_ackme | 11:ea484e1b7fc4 | 809 | } |
dan_ackme | 11:ea484e1b7fc4 | 810 | } |
dan_ackme | 11:ea484e1b7fc4 | 811 |