";
}
google.maps.event.addListener(stores.marker, 'click', function() {
if( prev_infowindow ) {
prev_infowindow.close();
}
infowindow.close();
$("[data-value]").removeClass('active');
$("[data-value=store-"+storeId+"]").addClass('active');
$("[data-value=store-"+storeId+"]").click();
$(this).addClass('active');
})
});
}
function getStoresInView(){
var stores_in_view = [];
var bounds = offices_map.getBounds();
bounds = Object.values(bounds);
for(x in stores){
if((stores[x].longitude >= bounds[1].g && stores[x].longitude = bounds[0].g && stores[x].latitude {
$('li[data-value="store-' + index + '"]').parent().parent().prependTo('.storepickup-content');
});
$('.list-group-item.store-list-item.active').parent().parent().prependTo('.storepickup-content');
$('.storepickup-content').scrollTop(0);
}
function autocomplete(inp, stores) {
/*the autocomplete function takes two arguments,
the text field element and an array of possible autocompleted values:*/
var currentFocus;
var arr = [];
var storeNames = [];
var storeAddresses =[];
var zipCodes = [];
for (x in stores) {
arr.push(stores[x].name);
storeAddresses.push(stores[x].store_address.toLowerCase());
zipCodes.push(stores[x].zip_code.toLowerCase());
}
inp.addEventListener("input", function(e) {
var a, b, i, val = this.value;
var id = null;
closeAllLists();
if (!val) { return false;}
currentFocus = -1;
a = document.createElement("DIV");
a.setAttribute("id", this.id + "autocomplete-list");
a.setAttribute("class", "autocomplete-items");
this.parentNode.appendChild(a);
for (i = 0; i " + arr[i].substr(0, val.length) + "";
b.innerHTML += arr[i].substr(val.length);
b.innerHTML += "";
for (x in stores) {
if(arr[i] == stores[x].name) {
console.log(x);
id = x;
}
}
// Creatin a local scope with a function so .addEventListener wont paste the latest id, but the id corresponding to the for cycle.
(function(id) {
var id = id;
b.addEventListener("click", function(e) {
inp.value = this.getElementsByTagName("input")[0].value;
$("[data-value=store-"+id+"]").click();
//$(".store-list-item.active").get(0).scrollIntoView();
closeAllLists();
});
})(id);
a.appendChild(b);
}
}
});
inp.addEventListener("keydown", function(e) {
var x = document.getElementById(this.id + "autocomplete-list");
if (x) x = x.getElementsByTagName("div");
if (e.keyCode == 40) {
currentFocus++;
addActive(x);
} else if (e.keyCode == 38) {
currentFocus--;
addActive(x);
} else if (e.keyCode == 13) {
e.preventDefault();
if (currentFocus > -1) {
if (x) x[currentFocus].click();
}
}
});
function addActive(x) {
if (!x) return false;
removeActive(x);
if (currentFocus >= x.length) currentFocus = 0;
if (currentFocus " : '';
if(website_url){
if(working_hours) {
if(street_image) {
var infoContent = "