Skip to content
Permalink
Browse files
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 75832158b21a70cb32f9925a04a0ec471709a66e
@@ -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);
}
}
}

0 comments on commit 7583215

Please sign in to comment.