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AAUgB,OAAO,sBAE7B,EAXGC,CAAa5C,GACTnB,GAAgBmB,EAAEH,SAAQhB,EAAe,GACzCA,EAAe,IAAGA,EAAgBmB,EAAEH,OAAS,GAEjDG,EAAEnB,GAAc8C,UAAUC,IAAI,sBACjC,CAOD,SAASzC,EAAc0D,GAInB,IADA,IAAI7C,EAAItC,SAASoF,uBAAuB,sBAC/BrB,EAAI,EAAGA,EAAIzB,EAAEH,OAAQ4B,IACtBoB,GAAS7C,EAAEyB,IAAMoB,GAASlE,GAC1BqB,EAAEyB,GAAGlC,WAAWwD,YAAY/C,EAAEyB,GAGzC,CAxKD9C,EAAI0D,iBAAiB,QAASvD,KAC9BH,EAAI0D,iBAAiB,QAASvD,KAE9BH,EAAI0D,iBAAiB,WAAW,SAAUC,GACtC,IAAItC,EAAItC,SAASsF,eAAe1E,KAAKgB,GAAK,qBACtCU,IAAGA,EAAIA,EAAEiD,qBAAqB,OACjB,IAAbX,EAAEY,SAGFrE,IAEA6D,EAAU1C,IACU,IAAbsC,EAAEY,SAGTrE,IAEA6D,EAAU1C,IACU,IAAbsC,EAAEY,UAETZ,EAAEa,iBACEtE,GAAgB,GAEZmB,GAAGA,EAAEnB,GAAcoE,qBAAqB,KAAK,GAAGG,QAG/D,IAgJD1F,SAAS2E,iBAAiB,SAAS,SAAUC,GACzCnD,EAAcmD,EAAEe,OACnB,GACJ,CA3LeC,CAAa5F,SAASsF,eAAe,mBAAoBvF,EAEhE,EACD8F,MAAO,SAAUC,GAChB,GAGR,GA3BL,C","sources":["webpack://Watermark.web/./wwwroot/scripts/src/site/communitiesAutocomplete.js"],"sourcesContent":["const $ = require(\"jquery\");\r\n\r\nexport default () => {\r\n /*An array containing all the city listings:*/\r\n var cityList = [];\r\n //Get city listing\r\n $(document).ready(function () {\r\n\r\n $.ajax({\r\n type: \"GET\",\r\n url: \"/RetirementCommunities/GetCityItems\",\r\n dataType: \"json\",\r\n success: function (result) {\r\n cityList = [];\r\n $.each(result.cityAutoCompletItems, function () {\r\n var obj = {\r\n City: this.cityItem,\r\n Communities: this.communityModels\r\n }\r\n cityList.push(obj);\r\n });\r\n if (cityList != null) {\r\n autocomplete(document.getElementById(\"eSearchLocation\"), cityList);\r\n }\r\n },\r\n error: function (err) {\r\n }\r\n })\r\n\r\n });\r\n function autocomplete(inp, arr) {\r\n\r\n /*the autocomplete function takes two arguments,\r\n the text field element and an array of possible autocompleted values:*/\r\n var currentFocus;\r\n /*execute a function when someone writes in the text field:*/\r\n inp.addEventListener(\"input\", generateTree());\r\n inp.addEventListener(\"click\", generateTree());\r\n /*execute a function presses a key on the keyboard:*/\r\n inp.addEventListener(\"keydown\", function (e) {\r\n var x = document.getElementById(this.id + \"autocomplete-list\");\r\n if (x) x = x.getElementsByTagName(\"li\");\r\n if (e.keyCode == 40) {\r\n /*If the arrow DOWN key is pressed,\r\n increase the currentFocus variable:*/\r\n currentFocus++;\r\n /*and and make the current item more visible:*/\r\n addActive(x);\r\n } else if (e.keyCode == 38) { //up\r\n /*If the arrow UP key is pressed,\r\n decrease the currentFocus variable:*/\r\n currentFocus--;\r\n /*and and make the current item more visible:*/\r\n addActive(x);\r\n } else if (e.keyCode == 13) {\r\n /*If the ENTER key is pressed, prevent the form from being submitted,*/\r\n e.preventDefault();\r\n if (currentFocus > -1) {\r\n /*and simulate a click on the \"active\" item:*/\r\n if (x) x[currentFocus].getElementsByTagName(\"a\")[0].click();\r\n }\r\n }\r\n });\r\n function generateTree() {\r\n return function () {\r\n var a, b, i, val = this.value;\r\n /*close any already open lists of autocompleted values*/\r\n closeAllLists();\r\n //if (!val) { return false; }\r\n //if (val.length < 3) { return false; }\r\n currentFocus = -1;\r\n /*create a DIV element that will contain the items (values):*/\r\n a = document.createElement(\"DIV\");\r\n a.setAttribute(\"id\", this.id + \"autocomplete-list\");\r\n a.setAttribute(\"class\", \"autocomplete-items\");\r\n /*append the DIV element as a child of the autocomplete container:*/\r\n this.parentNode.appendChild(a);\r\n\r\n var commFiltered = [];\r\n var csFiltered = [];\r\n var hasComms = arr.filter(item => item.Communities.length > 0);\r\n\r\n hasComms.forEach(item => {\r\n var filteredComms = item.Communities.filter(x => x.communityHomePage.toLowerCase().includes(val.toLowerCase())).filter(x => x.communityHomePage.length > 0);\r\n commFiltered.push(...filteredComms.map(x => ({\r\n \"city\": item.City.city,\r\n \"cityNodeAliasPath\": item.City.nodeAliasPath,\r\n \"cityUrl\" : item.City.cityUrl,\r\n \"state\": item.City.state,\r\n \"stateUrl\": item.City.stateUrl,\r\n \"stateNodeAliasPath\": item.City.stateNodeAliasPath,\r\n \"communityHomePage\": x.communityHomePage,\r\n \"url\": x.url,\r\n \"external\": x.external\r\n })));\r\n\r\n });\r\n\r\n var cityStateFiltered = arr.filter(item => item.City.city.toLowerCase().includes(val.toLowerCase()) || item.City.state.toLowerCase().includes(val.toLowerCase()));\r\n cityStateFiltered.forEach(item => {\r\n var filteredComms = item.Communities.filter(x => x.communityHomePage.length > 0);\r\n csFiltered.push(...filteredComms.map(x => ({\r\n \"city\": item.City.city,\r\n \"cityNodeAliasPath\": item.City.nodeAliasPath,\r\n \"cityUrl\": item.City.cityUrl,\r\n \"state\": item.City.state,\r\n \"stateUrl\": item.City.stateUrl,\r\n \"stateNodeAliasPath\": item.City.stateNodeAliasPath,\r\n \"communityHomePage\": x.communityHomePage,\r\n \"url\": x.url,\r\n \"external\": x.external\r\n })));\r\n });\r\n\r\n //remove duplicates\r\n const farr = [...new Map([...commFiltered, ...csFiltered].map(v => [JSON.stringify(v), v])).values()].sort((a, b) => a.state.localeCompare(b.state) || a.city.localeCompare(b.city) || a.communityHomePage.localeCompare(b.communityHomePage)\r\n );\r\n\r\n var groups = ['state', 'city'], grouped = {};\r\n\r\n // take existing object, or generate new obj, or at last, then an array\r\n farr.forEach(function (a) {\r\n groups.reduce(function (o, g, i) {\r\n o[a[g]] = o[a[g]] || (i + 1 === groups.length ? [] : {});\r\n return o[a[g]];\r\n }, grouped).push(a);\r\n });\r\n\r\n\r\n /*for each item in the array...*/\r\n for (var state in grouped) {\r\n //console.log(state);\r\n //console.log(Object.values(grouped[state])[0][0].stateNodeAliasPath);\r\n\r\n /*create a DIV element for each matching element:*/\r\n b = document.createElement(\"DIV\");\r\n b.setAttribute(\"class\", \"menu\");\r\n var stateUl = document.createElement(\"ul\");\r\n stateUl.classList.add(\"state\");\r\n\r\n stateUl.innerHTML += \"
  • \" + state + \"
  • \";\r\n\r\n var cityUl = document.createElement(\"ul\");\r\n cityUl.classList.add(\"city\");\r\n\r\n for (var city in grouped[state]) {\r\n console.log(Object.values(grouped[state][city])[0]);\r\n cityUl.innerHTML += \"
  • \" + city + \"
  • \";\r\n /*insert a input field that will hold the current array item's Campus Name:*/\r\n //b.innerHTML += \"\";\r\n var comUl = document.createElement(\"ul\");\r\n comUl.classList.add(\"community\");\r\n\r\n for (var com of Object.values(grouped[state][city])) {\r\n comUl.innerHTML += \"
  • \" + com.communityHomePage + \"
  • \";\r\n }\r\n cityUl.append(comUl);\r\n }\r\n stateUl.append(cityUl);\r\n b.append(stateUl);\r\n\r\n /*execute a function when someone clicks on the item value (DIV element):*/\r\n b.addEventListener(\"click\", function (e) {\r\n closeAllLists();\r\n });\r\n a.appendChild(b);\r\n\r\n }\r\n\r\n if (Object.keys(grouped).length === 0) {\r\n var nilMsg = document.createElement(\"div\");\r\n nilMsg.classList.add(\"no-results\");\r\n nilMsg.innerText = \"Sorry, no results are found.\";\r\n a.append(nilMsg);\r\n }\r\n\r\n };\r\n }\r\n\r\n function addActive(x) {\r\n /*a function to classify an item as \"active\":*/\r\n if (!x) return false;\r\n /*start by removing the \"active\" class on all items:*/\r\n removeActive(x);\r\n if (currentFocus >= x.length) currentFocus = 0;\r\n if (currentFocus < 0) currentFocus = (x.length - 1);\r\n /*add class \"autocomplete-active\":*/\r\n x[currentFocus].classList.add(\"autocomplete-active\");\r\n }\r\n function removeActive(x) {\r\n /*a function to remove the \"active\" class from all autocomplete items:*/\r\n for (var i = 0; i < x.length; i++) {\r\n x[i].classList.remove(\"autocomplete-active\");\r\n }\r\n }\r\n function closeAllLists(elmnt) {\r\n /*close all autocomplete lists in the document,\r\n except the one passed as an argument:*/\r\n var x = document.getElementsByClassName(\"autocomplete-items\");\r\n for (var i = 0; i < x.length; i++) {\r\n if (elmnt != x[i] && elmnt != inp) {\r\n x[i].parentNode.removeChild(x[i]);\r\n }\r\n }\r\n }\r\n /*execute a function when someone clicks in the document:*/\r\n document.addEventListener(\"click\", function (e) {\r\n closeAllLists(e.target);\r\n });\r\n }\r\n}\r\n"],"names":["$","require","cityList","document","ready","ajax","type","url","dataType","success","result","each","cityAutoCompletItems","obj","City","this","cityItem","Communities","communityModels","push","inp","arr","currentFocus","generateTree","a","b","val","value","closeAllLists","createElement","setAttribute","id","parentNode","appendChild","commFiltered","csFiltered","filter","item","length","forEach","filteredComms","x","communityHomePage","toLowerCase","includes","map","city","nodeAliasPath","cityUrl","state","stateUrl","stateNodeAliasPath","external","farr","Map","v","JSON","stringify","values","sort","localeCompare","groups","grouped","reduce","o","g","i","stateUl","classList","add","innerHTML","Object","cityUl","console","log","comUl","com","append","addEventListener","e","keys","nilMsg","innerText","addActive","remove","removeActive","elmnt","getElementsByClassName","removeChild","getElementById","getElementsByTagName","keyCode","preventDefault","click","target","autocomplete","error","err"],"sourceRoot":""}