PageSourceSearch

https://mountainhighoutfitters.com/cdn/shop/t/72/assets/frd-stores.js?v=48214228139007463191777277177

js mountainhighoutfitters.com collected 2026-09-25 23:38:56 UTC 17,583 bytes, 89 lines download raw bytes

1let FRDStores={ready(){(document.readyState==="ready"||document.readyState==="complete")&&FRDStores.initialize(),document.readyState!=="ready"&&document.readyState!=="complete"&&(document.onreadystatechange=async function(){document.readyState=="complete"&&await FRDStores.initialize()})},async initialize(){await FRDStores.create_elements(),await FRDStores.header_anchors(),FRDStores.dropdown_toggle(),FRDStores.lightbox_toggle(),FRDStores.geolocation_get_position()},async create_elements(){const my_mho_store_id=localStorage.getItem("my_mho_store_id"),store=await FRDStores.get_store(my_mho_store_id),frd_my_store_header=document.querySelector("div[frd-my-store-header]"),frd_my_store_overlay=document.createElement("div");frd_my_store_overlay.setAttribute("frd-stores-overlay",""),document.body.appendChild(frd_my_store_overlay);const frd_my_store_lightbox=document.createElement("div");let frd_stores_lightbox_header=`
2      <div frd-stores-lightbox-header>
3        <span frd-stores-lightbox-title>Choose a store</span>
4        <button type="button" frd-stores-lightbox-close>
5          X
6        </button>
7        <form name="frd-stores-search" method="post" action="#">
8          <fieldset>
9            <label for="miles">Find a store within</label>
10            <input name="miles" type="text" placeholder="10" required>
11            <label for="postal-code">miles of postal code</label>
12            <input name="postal-code" type="text" placeholder="90210" required>
13            <button name="search" type="submit">
14              Search
15            </button>
16          </fieldset>
17        </form>
18      </div>
19      <div frd-stores-lightbox-content></div>
20    `;if(frd_my_store_lightbox.setAttribute("frd-stores-lightbox",""),frd_my_store_lightbox.insertAdjacentHTML("afterbegin",frd_stores_lightbox_header),frd_my_store_overlay.append(frd_my_store_lightbox),!store)return;const frd_my_store_dropdown=document.createElement("div"),store_component=FRDStores.store_component(store,"header");frd_my_store_dropdown.setAttribute("frd-my-store-header-dropdown",""),frd_my_store_dropdown.insertAdjacentHTML("afterbegin",store_component),frd_my_store_header.append(frd_my_store_dropdown)},store_component(store=null,render_in=null,re_render=!1){if(!store)return;const my_mho_store_id=localStorage.getItem("my_mho_store_id");
20let store_inventory="",store_contact_subtitle="",store_phone_link="",store_email_link="",view_store_button="",view_store_button_header="",get_directions_url=`https://www.google.com/maps/dir/?api=1&destination=${encodeURI(store.address.replaceAll("<br>"," "))}`,view_all_stores_button="",store_distance="",set_store_button="";store.inventory>=0&&(store_inventory=`
21        <p class="inventory">
22          ${store.inventory} in stock
23        </p>
24      `),(store.phone||store.email)&&(store_contact_subtitle=`
25        <span class="subtitle">
26          Contact
27        </span>
28      `),store.phone&&(store_phone_link=`
29        <a class="phone" href="tel:${store.phone}" title="Call store">
30          ${store.phone}
31        </a>
32      `),store.email&&(store_email_link=`
33        <a class="email" href="mailto:${store.email}" title="Email store">
34          ${store.email}
35        </a>
36      `),store.url&&render_in==="header"&&(view_store_button_header=`
37        <a class="view-store" href="${store.url}" title="View store" target="_blank">
38          View store
39        </a>
40      `),store.distance!==void 0&&(store_distance=`
41        <span class="distance">
42          ${store.distance.toFixed(2)} miles
43        </span>
44      `);let set_store_button_class="",set_store_button_icon="&#9734;",set_store_button_text="Set as my store";store.id==my_mho_store_id&&(set_store_button_class=' class="active" disabled aria-disabled="true"',set_store_button_icon="&#9733;",set_store_button_text="My store"),render_in==="lightbox"&&(set_store_button=`
45        <button type="button" frd-set-store-id="${store.id}"${set_store_button_class}>
46          <span class="icon-star">${set_store_button_icon}</span> ${set_store_button_text}
47        </button>
48      `),store.url&&render_in==="lightbox"&&(view_store_button=`
49        <a class="view-store" href="${store.url}" title="View store" target="_blank">
50          View store
51        </a>
52      `),render_in==="header"&&re_render===!1&&(view_all_stores_button=`
53        <button type="button" frd-stores-lightbox>
54          View all stores
55        </button>
56      `);const container_div_open=re_render===!1?"<div>":"",container_div_close=re_render===!1?"</div>":"";return`
57      ${container_div_open}
58        <span class="title">
59          ${store.title}
60        </span>
61        ${store_inventory}
62        <span class="subtitle">
63          Address
64        </span>
65        <p class="address">
66          ${store.address}
67        </p>
68        <a class="get-directions" href="${get_directions_url}" title="Get directions" target="_blank">
69          Get directions
70        </a>
71        ${store_contact_subtitle}
72        ${store_phone_link}
73        ${store_email_link}
74        ${view_store_button_header}
75      ${container_div_close}
76      ${container_div_open}
77        ${store_distance}
78        ${set_store_button}
79        ${view_store_button}
80        ${view_all_stores_button}
81      ${container_div_close}
82    `},async header_anchors(){const my_mho_store_id=localStorage.getItem("my_mho_store_id"),store=await FRDStores.get_store(my_mho_store_id);let button=document.querySelector("div[frd-my-store-header] button[frd-stores-lightbox]");store&&(button.removeAttribute("frd-stores-lightbox"),button.setAttribute("frd-my-store-id",store.title),button.textContent=my_mho_store_id)},dropdown_toggle(){const frd_my_store_dropdown_anchor=document.querySelector("div[frd-my-store-header] button[frd-my-store-id]");frd_my_store_dropdown_anchor&&(frd_my_store_dropdown_anchor.addEventListener("click",event=>{event.stopPropagation();let frd_my_store_dropdown=document.querySelector("div[frd-my-store-header-dropdown]");if(console.log("hi"),!!frd_my_store_dropdown){if(!frd_my_store_dropdown.classList.contains("active")){frd_my_store_dropdown.classList.add("active");return}if(frd_my_store_dropdown.classList.contains("active")){frd_my_store_dropdown.classList.remove("active");return}}}),document.addEventListener("click",event=>{const frd_my_store_dropdown=document.querySelector("div[frd-my-store-header-dropdown]"),isClickInsideDropdown=frd_my_store_dropdown&&frd_my_store_dropdown.contains(event.target),isClickOnAnchor=frd_my_store_dropdown_anchor.contains(event.target);frd_my_store_dropdown&&frd_my_store_dropdown.classList.contains("active")&&!isClickInsideDropdown&&!isClickOnAnchor&&frd_my_store_dropdown.classList.remove("active")}))}
82,lightbox_toggle(){const frd_my_store_lightbox_anchors=document.querySelectorAll("button[frd-stores-lightbox]");let frd_my_store_overlay=document.querySelector("div[frd-stores-overlay]"),frd_my_store_lightbox=document.querySelector("div[frd-stores-lightbox]"),frd_my_store_lightbox_content=document.querySelector("div[frd-stores-lightbox-content]"),frd_stores_lightbox_close_button=document.querySelector("button[frd-stores-lightbox-close]");const frd_stores_search_form=document.querySelector('form[name="frd-stores-search"]');let search_miles_input=frd_stores_search_form.querySelector('input[name="miles"]'),search_postal_code_input=frd_stores_search_form.querySelector('input[name="postal-code"]'),search_button=frd_stores_search_form.querySelector('button[name="search"]');frd_my_store_lightbox_anchors&&(frd_my_store_lightbox_anchors.forEach(frd_my_store_lightbox_anchor=>{frd_my_store_lightbox_anchor.addEventListener("click",async event=>{const search_form=document.querySelector('form[name="frd-stores-search"]');frd_my_store_overlay=document.querySelector("div[frd-stores-overlay]"),frd_my_store_lightbox=document.querySelector("div[frd-stores-lightbox]");const product_id=Number(frd_my_store_lightbox_anchor.getAttribute("frd-product-id")),variant_id=Number(frd_my_store_lightbox_anchor.getAttribute("frd-variant-id"));if(variant_id||(search_form.style.display="block"),variant_id&&(search_form.style.display="none"),!frd_my_store_lightbox.classList.contains("active")){frd_my_store_lightbox.querySelector("div[frd-stores-lightbox-content]").innerHTML="",frd_my_store_lightbox_content.insertAdjacentHTML("afterbegin",await FRDStores.get_stores_markup(product_id,variant_id)),FRDStores.set_store(),frd_my_store_overlay.classList.add("active"),frd_my_store_lightbox.classList.add("active");return}if(frd_my_store_lightbox.classList.contains("active")){frd_my_store_overlay.classList.remove("active"),frd_my_store_lightbox.classList.remove("active");return}})}),frd_stores_search_form.addEventListener("submit",async event=>{event.preventDefault();let search_miles=Number(frd_stores_search_form.querySelector('input[name="miles"]').value),search_postal_code=frd_stores_search_form.querySelector('input[name="postal-code"]').value;if(search_miles&&search_postal_code){const user_coordinatesx=await FRDStores.get_coordinates(search_postal_code),user_latitude=user_coordinatesx.results[0].geometry.location.lat,user_longitude=user_coordinatesx.results[0].geometry.location.lng,stores_by_distance=await FRDStores.get_stores_by_distance(user_latitude,user_longitude,search_miles),frd_my_store_lightbox2=document.querySelector("div[frd-stores-lightbox]"),frd_my_store_lightbox_content2=document.querySelector("div[frd-stores-lightbox-content]");stores_by_distance.length===0&&(frd_my_store_lightbox2.querySelector("div[frd-stores-lightbox-content]").innerHTML=`
83            <p class="no-results">
84              There are no stores within <i>${search_miles}</i> miles of <i>${search_postal_code}</i>.
85            </p>
86          `),stores_by_distance.length>0&&(frd_my_store_lightbox2.querySelector("div[frd-stores-lightbox-content]").innerHTML="",frd_my_store_lightbox_content2.insertAdjacentHTML("afterbegin",await FRDStores.get_stores_markup(null,null,!0,stores_by_distance)),FRDStores.set_store())}}),frd_my_store_overlay.addEventListener("click",event=>{let clicked_attributes=event.target.attributes,clicked_attribute_name=null;clicked_attributes.length>0&&(clicked_attribute_name=clicked_attributes[0].name),clicked_attribute_name==="frd-stores-overlay"&&(frd_my_store_overlay.classList.remove("active"),frd_my_store_lightbox.classList.remove("active"),search_miles_input.value="",search_postal_code_input.value="")}),frd_stores_lightbox_close_button.addEventListener("click",event=>{frd_my_store_overlay.classList.remove("active"),frd_my_store_lightbox.classList.remove("active"),search_miles_input.value="",search_postal_code_input.value=""}))},async get_stores(product_id=null,variant_id=null){let stores=frd_stores.stores;if(variant_id){const product_id2=Number(document.querySelector("[frd-product-id]").getAttribute("frd-product-id"));stores=await frd_get_variant_stores(product_id2,variant_id),stores=JSON.parse(stores)}return stores.sort(function(a,b){return a.title<b.title?-1:a.title>b.title?1:0}),stores},async get_stores_by_distance(user_latitude=null,user_longitude=null,miles=null,product_id=null){let stores=Object.assign([],await FRDStores.get_stores()),stores_by_distance=await Promise.all(stores.map(async store=>{let new_store=Object.assign({},store),distance=await FRDStores.get_distance_between(store.id,user_latitude,user_longitude);return new_store.distance=distance,new_store}));return stores_by_distance=stores_by_distance.filter(function(store){return store.distance<=miles}),stores_by_distance.sort(function(a,b){return a.distance-b.distance}),stores_by_distance},async get_stores_markup(product_id=null,variant_id=null,re_render=!1,re_render_stores=null){const my_mho_store_id=localStorage.getItem("my_mho_store_id"),global_settings=frd_stores.global_settings;let stores=await FRDStores.get_stores();variant_id&&(stores=await FRDStores.get_stores(product_id,variant_id)),re_render===!0&&(stores=re_render_stores),stores.sort(function(a,b){return a.title<b.title?-1:a.title>b.title?1:0});let stores_markup="";for(let store of stores){const store_info=await FRDStores.get_store(store.id);store.title=store_info.title,store.address=store_info.address,store.email=store_info.email,store.phone=store_info.phone,store.url=store_info.url,store.delivery_method_settings=store_info.delivery_method_settings,store.latitude=store_info.latitude,store.longitude=store_info.longitude;const store_component=FRDStores.store_component(store,"lightbox");stores_markup+=`<li frd-stores-list-item>
87        ${store_component}
88      </li>`}return`<ul frd-stores-list>${stores_markup}</ul>`},async get_store(store_id=null){return store_id?(await FRDStores.get_stores()).filter(function(store2){return store2.id==store_id})[0]:void 0}
88,async set_store(){let my_store_button=document.querySelector("button[frd-my-store-id]");const set_store_buttons=document.querySelectorAll("button[frd-set-store-id]"),frd_my_store_dropdown=document.querySelector("div[frd-my-store-header-dropdown] div:first-child");my_store_button||(my_store_button=document.querySelector("button[frd-stores-lightbox]")),set_store_buttons.forEach(set_store_button=>{set_store_button.addEventListener("click",async event=>{let active_set_store_button=document.querySelector("button[frd-set-store-id].active"),set_store_id=set_store_button.getAttribute("frd-set-store-id"),set_store_title=set_store_button.parentElement.parentElement.querySelector("span.title").textContent,store=await FRDStores.get_store(set_store_id),store_component=FRDStores.store_component(store,"header",!0);localStorage.setItem("my_mho_store_id",set_store_id),active_set_store_button&&(active_set_store_button.classList.remove("active"),active_set_store_button.innerHTML='<span class="icon-star">&#9734;</span> Set as my store',active_set_store_button.removeAttribute("disabled"),active_set_store_button.removeAttribute("aria-disabled")),set_store_button.classList.add("active"),set_store_button.innerHTML='<span class="icon-star">&#9733;</span> My store',set_store_button.setAttribute("disabled",!0),set_store_button.setAttribute("aria-disabled",!0),my_store_button.removeAttribute("frd-stores-lightbox"),my_store_button.setAttribute("frd-my-store-id",store.address),my_store_button.textContent=store.id,frd_my_store_dropdown&&(frd_my_store_dropdown.innerHTML="",frd_my_store_dropdown.insertAdjacentHTML("afterbegin",store_component))})})},get_global_settings(){return frd_stores.global_settings},async get_store_settings(store_id=null){return store_id?(await FRDStores.get_stores()).filter(function(store2){return store2.id==store_id})[0].delivery_method_settings:void 0},async get_distance_between(store_id,user_latitude,user_longitude){const store=await FRDStores.get_store(store_id);if(!store)return;const store_latitude=store.latitude,store_longitude=store.longitude;if(user_latitude===store_latitude&&user_longitude===store_longitude)return 0;let radlat1=Math.PI*user_latitude/180,radlat2=Math.PI*store_latitude/180,theta=user_longitude-store_longitude,radtheta=Math.PI*theta/180,dist=Math.sin(radlat1)*Math.sin(radlat2)+Math.cos(radlat1)*Math.cos(radlat2)*Math.cos(radtheta);return dist>1&&(dist=1),dist=Math.acos(dist),dist=dist*180/Math.PI,dist=dist*60*1.1515,dist},async get_coordinates(postal_code){const url=`https://maps.googleapis.com/maps/api/geocode/json?address=${postal_code},US&key=AIzaSyC0loMynFaT9vx0o9unZm1L0W9bjra4BNI`;try{return await(await fetch(url)).json()}catch(error){console.log(error)}},geolocation_get_permissions(){navigator.geolocation&&navigator.permissions.query({name:"geolocation"}).then(function(response){response.state==="granted"&&console.log("geolocation_get_permissions() granted"),response.state==="denied"&&console.log("geolocation_get_permissions() denied")})},geolocation_get_position(){navigator.geolocation&&navigator.geolocation.getCurrentPosition(FRDStores.geolocation_success,FRDStores.geolocation_error,{timeout:5e3})},async geolocation_success(position){const latitude=position.coords.latitude,longitude=position.coords.longitude,stores_by_distance=await FRDStores.get_stores_by_distance(latitude,longitude,50);let my_store_button=document.querySelector("button[frd-my-store-id]");const frd_my_store_dropdown=document.querySelector("div[frd-my-store-header-dropdown] div:first-child");if(my_store_button||(my_store_button=document.querySelector("button[frd-stores-lightbox]")),localStorage.setItem("my_mho_coords",`${latitude}|${longitude}`),stores_by_distance.length>0){const closest_store=stores_by_distance[0],closest_store_id=closest_store.id,closest_store_title=closest_store.title,store_component=FRDStores.store_component(closest_store,"header",!0);localStorage.setItem("my_mho_store_id",closest_store_id),my_store_button.setAttribute("frd-my-store-id",closest_store_id),my_store_button.removeAttribute("frd-stores-lightbox"),my_store_button.textContent=closest_store_title,frd_my_store_dropdown&&(frd_my_store_dropdown.innerHTML="",frd_my_store_dropdown.insertAdjacentHTML("afterbegin",store_component))}},geolocation_error(){localStorage.removeItem("my_mho_coords")}};FRDStores.ready(),document.addEventListener("DOMContentLoaded",function(){const header=document.querySelector("div[frd-my-store-header]");
88if(!header)return;const svgIcon=header.querySelector("svg"),button=header.querySelector("button[frd-stores-lightbox], button[frd-my-store-id]");svgIcon&&button&&(svgIcon.style.cursor="pointer",svgIcon.addEventListener("click",function(event){event.stopPropagation(),button.click()}))});
89//# sourceMappingURL=/cdn/shop/t/72/assets/frd-stores.js.map?v=48214228139007463191777277177

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.