1jQuery(function ($) { 2 if ($("#homefinder-filter").length > 0) { 3 // filter out url params not relevant to homefinder 4 var paramValues = ['price', 'sqFt', 'homeType', 'beds', 'baths'] 5 var searchArr = location.search.replace("?", "").split("&").filter(el => paramValues.includes(el.split('=')[0])) 6 var price = "all" 7 var sqFt = "all" 8 var homeType = "all" 9 var beds = "all" 10 var baths = "all" 11 12 if (searchArr[0]) { 13 var priceArr = searchArr[0].split("="), 14 price = priceArr[1] 15 selectElement("homefinder-price", priceArr[1]) 16 } 17 18 if (searchArr[1]) { 19 var sqFtArr = searchArr[1].split("="), 20 sqFt = sqFtArr[1] 21 selectElement("homefinder-sq-ft", sqFtArr[1]) 22 } 23 24 if (searchArr[2]) { 25 var typeArr = searchArr[2].split("="), 26 homeType = typeArr[1] 27 selectElement("homefinder-home-type", typeArr[1]) 28 } 29 30 if (searchArr[3]) { 31 var bedsArr = searchArr[3].split("="), 32 beds = bedsArr[1] 33 selectElement("homefinder-beds", bedsArr[1]) 34 } 35 36 if (searchArr[4]) { 37 var bathsArr = searchArr[4].split("="), 38 baths = bathsArr[1] 39 selectElement("homefinder-baths", bathsArr[1]) 40 } 41 42 $("#homefinder-price").on("change", function () { 43 price = $(this).val() 44 }) 45 46 $("#homefinder-sq-ft").on("change", function () { 47 sqFt = $(this).val() 48 }) 49 50 $("#homefinder-home-type").on("change", function () { 51 homeType = $(this).val() 52 }) 53 54 $("#homefinder-beds").on("change", function () { 55 beds = $(this).val() 56 }) 57 58 $("#homefinder-baths").on("change", function () { 59 baths = $(this).val() 60 }) 61 62 $("#homefinder-form").on("keyup change paste", "input, select, button", function (e) { 63 formChange() 64 }) 65 66 $("#homefinder-form #homefinder-clear").on("click", function (e) { 67 formChange("clear") 68 }) 69 70 function formChange(action) { 71 var params = "?price=" + price + "&sqFt=" + sqFt + "&homeType=" + homeType + "&beds=" + beds + "&baths=" + baths 72 // console.log('price value: ', price); 73 // console.log('sqFt value: ', sqFt); 74 // console.log('homeType value: ', homeType); 75 // console.log('beds value: ', beds); 76 // console.log('baths value: ', baths); 77 if (action === "clear") { 78 params = "" 79 } 80 $("#homefinder-form").attr("action", "/neighborhoods" + params) 81 } 82 83 function selectElement(id, valueToSelect) { 84 let element = document.getElementById(id) 85 element.value = valueToSelect 86 } 87 88 $("#neighborhoods-wrap .dropdown-menu .dropdown-item").on("click keyup", function () { 89 let sort = $(this).data("sort"), 90 items = $(`#neighborhoods-list .homeItems[data-${sort}]`), 91 itemCounter = 0 92 93 $(".sort-button .sort-filter").text($(this).text()) 94 $(".sort-dropdown").toggleClass("show") 95 96 if (sort === "home-type") { 97 $(items).sort(sortType).appendTo($("#neighborhoods-list")) 98 } else if (sort === "price") { 99 $(items).each((index, item) => { 100 let itemPriceRange = $(item).data("range") 101 let itemPrice = parseInt($(item).data("price")) 102 let itemNeighborhood = $(item).data("neighborhood") 103 104 !itemPriceRange ? (itemPriceRange = "empty") : itemPriceRange 105 106 isNaN(itemPrice) ? (itemPrice = 0) : itemPrice 107 108 switch (itemPriceRange) { 109 case "low": 110 itemCounter = 0 111 break 112 case "mid": 113 itemCounter = 1 114 break 115 case "high": 116 itemCounter = 2 117 break 118 default: 119 itemCounter = 999999999 120 } 121 122 itemPrice = itemPrice + itemCounter 123 124 $(item).data("sort", itemPrice) 125 126 // console.log(`${itemNeighborhood}: ${itemPrice}`); 127 }) 128 129 $(items).sort(sortPrice).appendTo($("#neighborhoods-list")) 130 } 131 // else if (sort === 'size') { 132 // $(items).sort(sortSize).appendTo($("#neighborhoods-list")); 133 // } 134 }) 135 136 function sortPrice(a, b) { 137 return $(a).data("sort") - $(b).data("sort") 138 } 139 140 function sortSize(a, b) { 141 return $(a).data("sqft") - $(b).data("sqft") 142 } 143 144 function sortType(a, b) { 145 return $(a).data("home-type") < $(b).data("home-type") 146 ? 1 147 : $(a).data("home-type") > $(b).data("home-type") 148 ? -1 149 : 0 150 } 151 } 152 153 // $('#neighborhoods-wrap .sort-neighborhoods button').on('click',function(e) { 154 // var sortBy = $(this).attr("slug"); 155 // $('#neighborhoods-wrap .sort-wrap .homeItems').sort(function(a, b) { 156 // return $(b).data(sortBy) - $(a).data(sortBy); 157 // }).appendTo('#neighborhoods-wrap .sort-wrap'); 158 // }); 159 160 if ($("#homefinder-map").length > 0) { 161 var neighborhoodData = neighborhoods 162 var filteredNeighborhoodObj = {} 163 var isValidQueryString = window.location.href.indexOf("?") 164 165 for (var i = 0; i < filteredNeighborhoods.length; i++) { 166 var neighborhoodTitle = filteredNeighborhoods[i]["post_name"] 167 // console.log(filteredNeighborhoods[i]["post_name"]) 168 filteredNeighborhoodObj[neighborhoodTitle] = neighborhoodTitle // ?? 169 } 170 171 for (let hood in neighborhoodData) { 172 let fillColor, neighborhoodTitle 173 let neighborhood = neighborhoodData[hood] 174 let backgroundElement 175 176 if (isValidQueryString !== -1 && hood in filteredNeighborhoodObj) { 177 fillColor = neighborhood["color"] 178 neighborhoodTitle = filteredNeighborhoodObj[hood].toLowerCase().replace(/\s/g, "-") 179 } else { 180 fillColor = "#666666" 181 neighborhoodTitle = neighborhood.title.toLowerCase().replace(/\s/g, "-") 182 console.log(neighborhoodTitle) 183 } 184 185 backgroundElement = document.querySelector('[data-neighborhood="' + neighborhoodTitle + '"]') 186 187 backgroundElement ? backgroundElement.setAttribute("fill", fillColor) : "" 188 } 189 190 // for (let key in neighborhoodData) { 191 // let neighborhood = neighborhoodData[key];
192 // let title = key; 193 // let fillColor; 194 // 195 // if(isValidQueryString !== -1 && !(key in filteredNeighborhoodObj)) { 196 // fillColor = "#666666"; 197 // } else { 198 // fillColor = neighborhood["color"]; 199 // } 200 // backgroundElement = document.querySelectorAll('[data-neighborhood="'+title+'"]'); 201 // backgroundElement[0].setAttribute("fill", fillColor); 202 203 // $('#neighborhoods').find('#' + title + '-title').find("path").attr("fill", "#ffffff"); 204 // $('#neighborhoods').find('#' + title + '-house-icon').find("polygon").attr("fill", "#ffffff"); 205 206 // } 207 } 208})
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.