Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion src/js/idx-omnibar.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,29 @@ var idxOmnibar = function(jsonData){
}
return displayName;
};

let includedStateAbreviations = new Set();

//helper function for grabbing the name of each item in JSON creating new array
var createArrays = function(array, newArray, type, fieldName){

// Add state abbreviations to the set for later reference
array.forEach((item) => {
if (item.stateAbrv) {
console.log(item.stateAbrv);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this console log is needed. Everything else looks like it works fine! Good stuff

includedStateAbreviations.add(item.stateAbrv);
}
});

//if zip, do not append state abbreviations
if(type === 'zip'){
array.forEach(function(item){
//filter out blank and Other CCZ from autocomplete dropdown
if(item.name !== '' && item.name !== 'Other' && item.name !== 'Other State'){
newArray.push(item.name);
}


});
//if county, append County and State
} else if(type ==='county') {
Expand Down Expand Up @@ -479,7 +493,11 @@ var idxOmnibar = function(jsonData){
}
for(var i=0; i < list.length; i++){
//filter out blank and county from input and check for appended state
if (inputFiltered.split(' county')[0] === list[i].name.toLowerCase() && whatState(input.value.split(', ')[1], list[i].stateAbrv, stateException) && isCounty(inputFiltered.split(' county')[1], listType) && input.value) {
if (inputFiltered.split(' county')[0] === list[i].name.toLowerCase()
&& (
whatState(input.value.split(', ')[1], list[i].stateAbrv, stateException)
|| includedStateAbreviations.has(input.value.split(', ')[1].toUpperCase()))
&& isCounty(inputFiltered.split(' county')[1], listType) && input.value) {
switch(listType){
case 'cities':
foundResult = true;
Expand Down