From 9276574925d17de9c46648602d463ee5f7adf916 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Wed, 10 Oct 2007 15:23:44 +0000 Subject: [PATCH] =?UTF-8?q?Enter=20w=C3=A4hlt=20jetzt=20auch=20aus=20den?= =?UTF-8?q?=20Alternativen=20aus.=20(noch=20buggi)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/personAdmin/personSearch1.js | 52 +++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/js/personAdmin/personSearch1.js b/js/personAdmin/personSearch1.js index df47d25..01802fc 100644 --- a/js/personAdmin/personSearch1.js +++ b/js/personAdmin/personSearch1.js @@ -98,7 +98,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) switch (inField.getAttribute ('id')) { case 'personSearch1_fname': - idx = this.fnameIdx; + idx = this.fnameIdx; if (idx != -1) { dists = this.fnameDists[idx].split ('::'); @@ -107,7 +107,7 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) } break; case 'personSearch1_sname': - idx = this.snameIdx; + idx = this.snameIdx; if (idx != -1) { dists = this.snameDists[idx].split ('::'); @@ -142,18 +142,28 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) if (dists.length > 0) // there are caculated distances for surnames { - var i = 0; var bestMatch = dists[0].split ('::'); // infos for best match + var len = bestMatch[1]; // reset matches select while ((child = bestFit.firstChild) != null) bestFit.removeChild (child); - for (match in dists) + // len ist ein Array mit entweder snameMaxIdx oder fnameMaxIdx + // als einziges Element. Ich übergebe das als Array um ein call + // bei reference zu simulieren. + if (len < dists.length) + while (dists[len].split ('::')[1] < bestMatch[1] && + len < dists.lenth) + len++; + else + len = dists.length - 1; + + for (var i=0; i= bestMatch[1] && sMatch[1] > bestMatch[1]) - // dont show more than best match distance matches. - break; } } else @@ -177,10 +182,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) // reset matches select while ((child = bestFit.firstChild) != null) bestFit.removeChild (child); - return new Array (-1, -1, ''); + return -1; } - return bestMatch; + return len; } this.altSurnames = function (_event) @@ -189,12 +194,13 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) var sNameAlt = document.getElementById (this.sNameAlt); this.snameDists = fittingStrings (surname.value, this.surnames, false); + if (this.snameDists.length > 0) - this.snameMaxIdx = this.snameDists[0].split ('::')[1]; + this.sNameBest = this.snameDists[0].split ('::'); else - this.snameMaxIdx = -1; + this.sNameBest = new Array (-1, -1, ''); - this.sNameBest = + this.snameMaxIdx = this.genAlternativesList (sNameAlt, this.snameDists, this.snameIdx); this.updField (surname, this.sNameBest, this.sNameAlt) @@ -204,9 +210,10 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) this.fnameDists = fittingStrings ( firstname.value, this.firstnames[this.sNameBest[2]], false); if (this.fnameDists.length > 0) - this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; + this.fNameBest = this.fnameDists[0].split ('::'); else - this.fnameMaxIdx = -1; + this.fNameBest = new Array (-1, -1, ''); + if (this.fnameDists.length > 0) this.fNameBest = this.fnameDists[0].split ('::'); @@ -238,15 +245,16 @@ function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) var surname = document.getElementById (this.surname); this.fnameDists = fittingStrings ( firstname.value, this.firstnames[this.sNameBest[2]], false); - if (this.fnameDists.length > 0) - this.fnameMaxIdx = this.fnameDists[0].split ('::')[1]; - else - this.fnameMaxIdx = -1; } else this.fnameDists = new Array (); - this.fNameBest = + if (this.fnameDists.length > 0) + this.fNameBest = this.fnameDists[0].split ('::'); + else + this.fNameBest = new Array (-1, -1, ''); + + this.fnameMaxIdx = this.genAlternativesList (fNameAlt, this.fnameDists, this.fnameIdx); this.updField (firstname, this.fNameBest, this.fNameAlt)