docs/api-2.1/search/search.js

Tue, 26 Nov 2024 21:53:06 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 26 Nov 2024 21:53:06 +0100
changeset 991
ec49db06dae0
parent 390
d345541018fa
permissions
-rw-r--r--

cxBufferFree() now calls cxBufferDestroy()

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

mercurial