Menu Account Store Cart (0)
Open today 7am-5pm
").children() : $storesContainer.children(); var $tbFilterText = jQuery("#mc-store-text-filter-header"); var textboxFilterTimeout = null; var zipCodeRegex = /^\d{5}(-\d{4})?$/; var textRemovalRegex = /(store information|shop this store|\d{3}-\d{3}-\d{4})/g; var tbFilterLatency = 300; // Populate stores array $stores.each(function() { var $this = jQuery(this); stores.push({ "StoreNumber": $this.find("span.d-none").text(), "Blob": $this.text().toLowerCase().replace(textRemovalRegex, ""), "Lat": $this.data("lat"), "Long": $this.data("long"), "UIElement": $this }); }); // Add textbox filter on keydown $tbFilterText.on("keydown", function() { clearTimeout(textboxFilterTimeout); textboxFilterTimeout = setTimeout(function () { var text = $tbFilterText.val().toLowerCase(); if (text.length === 0) { $filterTitle.html("Nearby Stores"); if (isHeader) { SetNearestStores(); return; } } if (zipCodeRegex.test(text)) { $filterTitle.html("Stores near " + text); var $xhr = jQuery.get("https://www.mccoys.com/mccoysapi/geocode/getlatlong?zipCode=" + text); $xhr.done(function(data) { // Make sure the filter text is still the zip code and hasnt changed if (data.Latitude !== 0 && data.Longitude !== 0) { RunClosestStoresFilter(data.Latitude, data.Longitude); } else { NotifyProblemLoadingClosestStores(); } }); $xhr.fail(NotifyProblemLoadingClosestStores); } else { if (text.length > 0) { $filterTitle.html("Stores matching \"" + text + "\""); } FilterStores(function (store) { return store.Blob.indexOf(text) !== -1; }, null, null); } }, tbFilterLatency); }); function FilterStores(predicate, action, sort) { for (var index = 0; index bText) { return 1; } return -1; }); $stores.detach().appendTo($storesContainer); } } function NotifyProblemLoadingClosestStores() { alert("There was a problem loading closest stores."); } function SetNearestStores() { RunClosestStoresFilter(29.863808, -97.962470); } function RunClosestStoresFilter(lat, long) { var closestStoresList = GetStoreNumbersOfStoresClosestToLatLong(lat, long); var closestStores = jQuery.map(closestStoresList, function(item) { return item.StoreNumber; }); FilterStores(function(store) { return closestStores.indexOf(store.StoreNumber) !== -1; }, function(store) { var distance = "Unknown"; for (var idx = 0; idx parseInt(bMiles, 10)) { return 1; } return -1; }); $stores.detach().appendTo($storesContainer); } function GetStoreNumbersOfStoresClosestToLatLong(startingLatitude, startingLongitude) { startingLatitude = ConvertDegreesToRadians(startingLatitude); startingLongitude = ConvertDegreesToRadians(startingLongitude); var storeDistances = []; for (var index = 0; index
My Store: San Marcos
Sign In
Sign Up
Cart 0 items Cart

TIPS & ADVICE

Home » Building Materials

Building Materials