Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
JENKINS-50776: Default selected item doesn't always honor exactly Def…
…ault Value
  • Loading branch information
BeChris authored and klimas7 committed Apr 15, 2018
1 parent abfaf0f commit 7583215
Showing 1 changed file with 11 additions and 12 deletions.
Expand Up @@ -74,25 +74,24 @@ var GitParameter = GitParameter || (function($) {
var defaultValue = _self.getDefaultValue();
console.log("Search default value : " + defaultValue);

var foundExactMatch = false;
var approximateMatchIndex = -1;

for (var i = 0; i < optionsLength; i++ ) {
if (filteredElement.options[i].value == defaultValue) {
filteredElement.options[i].selected = true;
var option = filteredElement.options[i];
if (option.value == defaultValue) {
option.selected = true;
console.log("Found an exact match");
foundExactMatch = true;
approximateMatchIndex = -1;
break;
}
if (approximateMatchIndex == -1 && option.value.indexOf(defaultValue) > -1) {
approximateMatchIndex = i;
}
}

if (!foundExactMatch) {
for (var i = 0; i < optionsLength; i++ ) {
if (filteredElement.options[i].value.indexOf(defaultValue) > -1) {
filteredElement.options[i].selected = true;
console.log("Found an approximate match : " + filteredElement.options[i].value);
break;
}
}
if (approximateMatchIndex != -1) {
filteredElement.options[approximateMatchIndex].selected = true;
console.log("Found an approximate match : " + filteredElement.options[approximateMatchIndex].value);
}
}
}
Expand Down

0 comments on commit 7583215

Please sign in to comment.