I have a requirement where there are 3 selection criteria user selects countries from a map displayed as lets say in 3 categories , i am maintaining 3 arraylist for the same.Each time he selects a country i have to display list of country names displayed in Alphabetical order in a bottom bar with font color distinguishing each category .I have written a code which will add all the values of arraylist in a different arraylist and sort it and then based on category it will create font for each and display them in the bottom so each time user selects a country this method is called.Please review and let me know if i can improve the performance.Below is the code
Lets say issuingOffice,selectedCountries and deSelectedCountries are arraylist declared in global scope and have values.
function updateBottomBar(){
var initalContent="Countires: <label>";
require(["dojox/collections/ArrayList"],function(arrayList){
var bottomBar = new arrayList();
var it = issuingOffice.getIterator();
while (!it.atEnd()) {
var country = it.get();
bottomBar.add(country);
}
var scit = selectedCountries.getIterator();
while (!scit.atEnd()) {
var country = scit.get();
bottomBar.add(country);
}
var descit = deSelectedCountries.getIterator();
while (!descit.atEnd()) {
var country = descit.get();
bottomBar.add(country);
}
bottomBar.sort();
var bbit = bottomBar.getIterator();
while (!bbit.atEnd()) {
var country = bbit.get();
if(selectedCountries.contains(country)){
initalContent!="<font>"+country+"</font>";
}else if(selectedCountries.contains(country)){
initalContent!="<font>"+country+"</font>";
} else{
initalContent!="<font>"+country+"</font>";
}
}
initalContent+="</label>";
dojo.byId("displayCountryName")=initalContent;
});
}
+=in here:initalContent!="<font>"+country+"</font>";? \$\endgroup\$