I'm not too used to working with arrays in javascript, so was wondering if there is a good way to condense this down.
Any pointers much appreciated!
you can see it in action @ http://www.productionlocations.com/locations
if($('.filters').length) {
if(url === 'http://www.productionlocations.com/locations' || url === 'http://www.productionlocations.com/locations/') {
searchval[0] = 'Find a location…';
searchval[1] = 'Try searching by zip code, like 90012…';
searchval[2] = 'Know your location ID? Find it like so: #xxxx';
searchval[3] = 'Search locations by type, like apartment, office, or retail...';
searchval[4] = 'Search locations by area, like downtown, Pasadena, or Hollywood...';
searchval[5] = 'Search locations by style, like art deco, tudor, or industrial...';
searchval[6] = 'Search locations by feature, like fireplace, pond, or tiled floors...';
} else {
searchval[0] = 'Modify your search by type, like apartment, office, or retais...';
searchval[1] = 'Modify your search by area, like downtown, Pasadena, or Hollywood...';
searchval[2] = 'Modify your search by style, like art deco, tudor, or industrial...';
searchval[3] = 'Modify your search by feature, like fireplace, pond, or tiled floors...';
searchval[4] = 'Modify your search…';
searchval[5] = 'Modify your search by zip code, like 90012…';
}
searchkey = Math.floor(Math.random() * searchval.length);
$('#s').val(searchval[searchkey]);
} else {
searchval[0] = 'Find a location…';
$('#s').val(searchval[0]);
inputReplace();
}
$('#s').val()andinputReplace()if necessary, or do you also want to keepsearchvalandsearchkeyaround? \$\endgroup\$