Commit 9276574925d17de9c46648602d463ee5f7adf916
1 parent
40722a76
Enter wählt jetzt auch aus den Alternativen aus. (noch buggi)
Showing
1 changed file
with
30 additions
and
22 deletions
... | ... | @@ -98,7 +98,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
98 | 98 | switch (inField.getAttribute ('id')) |
99 | 99 | { |
100 | 100 | case 'personSearch1_fname': |
101 | - idx = this.fnameIdx; | |
101 | + idx = this.fnameIdx; | |
102 | 102 | if (idx != -1) |
103 | 103 | { |
104 | 104 | dists = this.fnameDists[idx].split ('::'); |
... | ... | @@ -107,7 +107,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
107 | 107 | } |
108 | 108 | break; |
109 | 109 | case 'personSearch1_sname': |
110 | - idx = this.snameIdx; | |
110 | + idx = this.snameIdx; | |
111 | 111 | if (idx != -1) |
112 | 112 | { |
113 | 113 | dists = this.snameDists[idx].split ('::'); |
... | ... | @@ -142,18 +142,28 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
142 | 142 | if (dists.length > 0) |
143 | 143 | // there are caculated distances for surnames |
144 | 144 | { |
145 | - var i = 0; | |
146 | 145 | var bestMatch = dists[0].split ('::'); // infos for best match |
146 | + var len = bestMatch[1]; | |
147 | 147 | |
148 | 148 | // reset matches select |
149 | 149 | while ((child = bestFit.firstChild) != null) |
150 | 150 | bestFit.removeChild (child); |
151 | 151 | |
152 | - for (match in dists) | |
152 | + // len ist ein Array mit entweder snameMaxIdx oder fnameMaxIdx | |
153 | + // als einziges Element. Ich übergebe das als Array um ein call | |
154 | + // bei reference zu simulieren. | |
155 | + if (len < dists.length) | |
156 | + while (dists[len].split ('::')[1] < bestMatch[1] && | |
157 | + len < dists.lenth) | |
158 | + len++; | |
159 | + else | |
160 | + len = dists.length - 1; | |
161 | + | |
162 | + for (var i=0; i<len; i++) | |
153 | 163 | // walk through all matches |
154 | 164 | { |
155 | 165 | // get infos for match |
156 | - var sMatch = dists[match].split ('::'); | |
166 | + var sMatch = dists[i].split ('::'); | |
157 | 167 | |
158 | 168 | // create list entries |
159 | 169 | newLi = document.createElement ('li'); |
... | ... | @@ -164,11 +174,6 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
164 | 174 | liTxt = document.createTextNode (sMatch[2]); |
165 | 175 | newLi.appendChild (liTxt); |
166 | 176 | bestFit.appendChild (newLi); |
167 | - i=i+1; | |
168 | - | |
169 | - if (i >= bestMatch[1] && sMatch[1] > bestMatch[1]) | |
170 | - // dont show more than best match distance matches. | |
171 | - break; | |
172 | 177 | } |
173 | 178 | } |
174 | 179 | else |
... | ... | @@ -177,10 +182,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
177 | 182 | // reset matches select |
178 | 183 | while ((child = bestFit.firstChild) != null) |
179 | 184 | bestFit.removeChild (child); |
180 | - return new Array (-1, -1, ''); | |
185 | + return -1; | |
181 | 186 | } |
182 | 187 | |
183 | - return bestMatch; | |
188 | + return len; | |
184 | 189 | } |
185 | 190 | |
186 | 191 | this.altSurnames = function (_event) |
... | ... | @@ -189,12 +194,13 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
189 | 194 | var sNameAlt = document.getElementById (this.sNameAlt); |
190 | 195 | |
191 | 196 | this.snameDists = fittingStrings (surname.value, this.surnames, false); |
197 | + | |
192 | 198 | if (this.snameDists.length > 0) |
193 | - this.snameMaxIdx = this.snameDists[0].split ('::')[1]; | |
199 | + this.sNameBest = this.snameDists[0].split ('::'); | |
194 | 200 | else |
195 | - this.snameMaxIdx = -1; | |
201 | + this.sNameBest = new Array (-1, -1, ''); | |
196 | 202 | |
197 | - this.sNameBest = | |
203 | + this.snameMaxIdx = | |
198 | 204 | this.genAlternativesList (sNameAlt, this.snameDists, this.snameIdx); |
199 | 205 | this.updField (surname, this.sNameBest, this.sNameAlt) |
200 | 206 | |
... | ... | @@ -204,9 +210,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
204 | 210 | this.fnameDists = fittingStrings ( |
205 | 211 | firstname.value, this.firstnames[this.sNameBest[2]], false); |
206 | 212 | if (this.fnameDists.length > 0) |
207 | - this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; | |
213 | + this.fNameBest = this.fnameDists[0].split ('::'); | |
208 | 214 | else |
209 | - this.fnameMaxIdx = -1; | |
215 | + this.fNameBest = new Array (-1, -1, ''); | |
216 | + | |
210 | 217 | |
211 | 218 | if (this.fnameDists.length > 0) |
212 | 219 | this.fNameBest = this.fnameDists[0].split ('::'); |
... | ... | @@ -238,15 +245,16 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) |
238 | 245 | var surname = document.getElementById (this.surname); |
239 | 246 | this.fnameDists = fittingStrings ( |
240 | 247 | firstname.value, this.firstnames[this.sNameBest[2]], false); |
241 | - if (this.fnameDists.length > 0) | |
242 | - this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; | |
243 | - else | |
244 | - this.fnameMaxIdx = -1; | |
245 | 248 | } |
246 | 249 | else |
247 | 250 | this.fnameDists = new Array (); |
248 | 251 | |
249 | - this.fNameBest = | |
252 | + if (this.fnameDists.length > 0) | |
253 | + this.fNameBest = this.fnameDists[0].split ('::'); | |
254 | + else | |
255 | + this.fNameBest = new Array (-1, -1, ''); | |
256 | + | |
257 | + this.fnameMaxIdx = | |
250 | 258 | this.genAlternativesList (fNameAlt, this.fnameDists, this.fnameIdx); |
251 | 259 | this.updField (firstname, this.fNameBest, this.fNameAlt) |
252 | 260 | ... | ... |
Please
register
or
login
to post a comment