Wayne,
I’m not sure I understand the process. Could you be more explicit using my example code noted? Obviously, the JSON I included is the data currently within my custom_.js file that I want to be a separate file. The build index code will be (and currently is) within my custom_.js file.
Thank you,
//
var data = {"a":[
{"i":"BWI","t":"39.17","g":"-76.66","n":"Baltimore","f":"d"},
{"i":"HEF","t":"38.72","g":"-77.51","n":"Manassas","f":"d"},
{"i":"IAD","t":"38.94","g":"-77.45","n":"Dulles","f":"d"},
{"i":"LCA","t":"34.87","g":"33.62","n":"Cyprus","f":"i"},
{"i":"YKZ","t":"43.86","g":"-79.37","n":"Toronto","f":"i"},
]};
// searchPropertyName represents the name of the property the search will be performed on
// make sure the ALL data is also sorted by this column, the algorithm relies on this for performance
var searchPropertyName = "i";
var dataIndex = null;
function rebuildIndex(){
dataIndex = [];
var i = 0;
var indexLetter;
while(i < data.a.length){
var currentLetter = data.a[i][searchPropertyName][0].toUpperCase();
if(!indexLetter || indexLetter != currentLetter){
indexLetter = currentLetter;
dataIndex[currentLetter.charCodeAt(0) - 65] = i;
}
i=i+1;
}
// alert(dataIndex.join()); // test index
}