Commit 9276574925d17de9c46648602d463ee5f7adf916

Authored by Georg Hopp
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,7 +98,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
98 switch (inField.getAttribute ('id')) 98 switch (inField.getAttribute ('id'))
99 { 99 {
100 case 'personSearch1_fname': 100 case 'personSearch1_fname':
101 - idx = this.fnameIdx; 101 + idx = this.fnameIdx;
102 if (idx != -1) 102 if (idx != -1)
103 { 103 {
104 dists = this.fnameDists[idx].split ('::'); 104 dists = this.fnameDists[idx].split ('::');
@@ -107,7 +107,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -107,7 +107,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
107 } 107 }
108 break; 108 break;
109 case 'personSearch1_sname': 109 case 'personSearch1_sname':
110 - idx = this.snameIdx; 110 + idx = this.snameIdx;
111 if (idx != -1) 111 if (idx != -1)
112 { 112 {
113 dists = this.snameDists[idx].split ('::'); 113 dists = this.snameDists[idx].split ('::');
@@ -142,18 +142,28 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -142,18 +142,28 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
142 if (dists.length > 0) 142 if (dists.length > 0)
143 // there are caculated distances for surnames 143 // there are caculated distances for surnames
144 { 144 {
145 - var i = 0;  
146 var bestMatch = dists[0].split ('::'); // infos for best match 145 var bestMatch = dists[0].split ('::'); // infos for best match
  146 + var len = bestMatch[1];
147 147
148 // reset matches select 148 // reset matches select
149 while ((child = bestFit.firstChild) != null) 149 while ((child = bestFit.firstChild) != null)
150 bestFit.removeChild (child); 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 // walk through all matches 163 // walk through all matches
154 { 164 {
155 // get infos for match 165 // get infos for match
156 - var sMatch = dists[match].split ('::'); 166 + var sMatch = dists[i].split ('::');
157 167
158 // create list entries 168 // create list entries
159 newLi = document.createElement ('li'); 169 newLi = document.createElement ('li');
@@ -164,11 +174,6 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -164,11 +174,6 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
164 liTxt = document.createTextNode (sMatch[2]); 174 liTxt = document.createTextNode (sMatch[2]);
165 newLi.appendChild (liTxt); 175 newLi.appendChild (liTxt);
166 bestFit.appendChild (newLi); 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 else 179 else
@@ -177,10 +182,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -177,10 +182,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
177 // reset matches select 182 // reset matches select
178 while ((child = bestFit.firstChild) != null) 183 while ((child = bestFit.firstChild) != null)
179 bestFit.removeChild (child); 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 this.altSurnames = function (_event) 191 this.altSurnames = function (_event)
@@ -189,12 +194,13 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -189,12 +194,13 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
189 var sNameAlt = document.getElementById (this.sNameAlt); 194 var sNameAlt = document.getElementById (this.sNameAlt);
190 195
191 this.snameDists = fittingStrings (surname.value, this.surnames, false); 196 this.snameDists = fittingStrings (surname.value, this.surnames, false);
  197 +
192 if (this.snameDists.length > 0) 198 if (this.snameDists.length > 0)
193 - this.snameMaxIdx = this.snameDists[0].split ('::')[1]; 199 + this.sNameBest = this.snameDists[0].split ('::');
194 else 200 else
195 - this.snameMaxIdx = -1; 201 + this.sNameBest = new Array (-1, -1, '');
196 202
197 - this.sNameBest = 203 + this.snameMaxIdx =
198 this.genAlternativesList (sNameAlt, this.snameDists, this.snameIdx); 204 this.genAlternativesList (sNameAlt, this.snameDists, this.snameIdx);
199 this.updField (surname, this.sNameBest, this.sNameAlt) 205 this.updField (surname, this.sNameBest, this.sNameAlt)
200 206
@@ -204,9 +210,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -204,9 +210,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
204 this.fnameDists = fittingStrings ( 210 this.fnameDists = fittingStrings (
205 firstname.value, this.firstnames[this.sNameBest[2]], false); 211 firstname.value, this.firstnames[this.sNameBest[2]], false);
206 if (this.fnameDists.length > 0) 212 if (this.fnameDists.length > 0)
207 - this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; 213 + this.fNameBest = this.fnameDists[0].split ('::');
208 else 214 else
209 - this.fnameMaxIdx = -1; 215 + this.fNameBest = new Array (-1, -1, '');
  216 +
210 217
211 if (this.fnameDists.length > 0) 218 if (this.fnameDists.length > 0)
212 this.fNameBest = this.fnameDists[0].split ('::'); 219 this.fNameBest = this.fnameDists[0].split ('::');
@@ -238,15 +245,16 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) @@ -238,15 +245,16 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person)
238 var surname = document.getElementById (this.surname); 245 var surname = document.getElementById (this.surname);
239 this.fnameDists = fittingStrings ( 246 this.fnameDists = fittingStrings (
240 firstname.value, this.firstnames[this.sNameBest[2]], false); 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 else 249 else
247 this.fnameDists = new Array (); 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 this.genAlternativesList (fNameAlt, this.fnameDists, this.fnameIdx); 258 this.genAlternativesList (fNameAlt, this.fnameDists, this.fnameIdx);
251 this.updField (firstname, this.fNameBest, this.fNameAlt) 259 this.updField (firstname, this.fNameBest, this.fNameAlt)
252 260
Please register or login to post a comment