UNPKG

@eqsmarketing/frontend-site

Version:

Equipmentshare's custom code for the Webflow build

20 lines (16 loc) 12.4 kB
"use strict";(()=>{var S="https://boards-api.greenhouse.io/v1/boards/";var A="equipmentsharecom",R="gh",f=`${R}-element`,T=`${R}-filter`;var Y={button_apply:`[${f}="apply"]`,title:`[${f}="title"]`,description:`[${f}="description"]`,location:`[${f}="office"]`,department:`[${f}="department"]`,anchor_element:`[${f}="link"]`,nested:`[${f}="nested"]`},W={department:`[${T}="department"]`,location:`[${T}="location"]`,office:`[${T}="office"]`};var z=`[${R}-custom-position]`;var w=async o=>{try{let e=`${S}${A}/jobs/${o}?questions=true`,t=await fetch(e);if(!t.ok)throw new Error("Failed to fetch position details from Greenhouse api");return await t.json()}catch{return}};var v=async o=>{try{let e=`${S}${A}/departments/${o}?render_as=tree&content=true`;return await(await fetch(e)).json()}catch{return}},D=async()=>{try{let o=`${S}${A}/jobs?content=true`;return await(await fetch(o)).json()}catch{return{jobs:[],meta:0}}};var C=async(o,e)=>{let t=[],r=[],i=[];if(o){let n=await v(o);n&&n.jobs.length>0&&(await Promise.all(n.jobs.map(async a=>{let s=await w(a.id);s&&t.push(s)})),await Promise.all(n.children.map(async a=>{a.jobs.length>0&&await Promise.all(a.jobs.map(async s=>{let l=await w(s.id);l&&t.push(l)}))})))}else{let n=await D();if(!n)return{jobs:[],departments:[],offices:[]};t=n.jobs}return e&&(t=t.filter(n=>{let a=n.metadata.find(s=>s.name===e.name);if(a&&a.value===e.value)return!0})),r=[...new Set(t.map(n=>n.departments).flat().filter((n,a,s)=>s.findIndex(l=>l.name===n.name)===a))],i=[...new Set(t.map(n=>n.offices).flat().filter((n,a,s)=>s.findIndex(l=>l.name===n.name)===a))],r.sort(L),i.sort(L),{jobs:t,departments:r,offices:i}},L=(o,e)=>(o.name.trim(),e.name.trim(),o.name<e.name?-1:o.name>e.name?1:0);var $=o=>{let e=o.streetAddress.split(" ").join("+"),t=o.city.split(" ").join("+"),r=o.state.split(" ").join("+"),i=o.zip.split(" ").join("+");return`Equipment+Share,${e},${t},${r}+${i}`};var x="AIzaSyArViqWboJDFymZ6y4MYh6iUijW3NPpn1g",G={ON_LOAD:13},m={LOCATION_DATA:{name:"fs-location-element",value:"json-data"},GET_DIRECTIONS_LINK:{name:"fs-location-element",value:"get-directions-link"},MAP:{name:"fs-location-element",value:"map"},OPENINGS_SECTION:{name:"fs-location-element",value:"openings-section"},NO_OPENINGS_SECTION:{name:"fs-location-element",value:"no-openings-section"},RESULTS_WRAPPER:{name:"fs-nearby-element",value:"results-wrapper"},RESULTS_CARD:{name:"fs-nearby-element",value:"results-card"},NEARBY_CARD_HEADING:{name:"fs-nearby-element",value:"heading"},NEARBY_CARD_ADDRESS:{name:"fs-nearby-element",value:"address"},NEARBY_CARD_DISTANCE:{name:"fs-nearby-element",value:"distance"},NEARBY_CARD_PHONE:{name:"fs-nearby-element",value:"phone-link"},NEARBY_CARD_PHONE_TEXT:{name:"fs-nearby-element",value:"phone-text"},NEARBY_CARD_OPEN_HOURS:{name:"fs-nearby-element",value:"open-hours-text"},NEARBY_CARD_LOCATION_DETAILS_BUTTON:{name:"fs-nearby-element",value:"location-details-button"},NEARBY_CARD_GET_DIRECTIONS_LINK:{name:"fs-nearby-element",value:"get-directions-link"},NEARBY_CARD_SKELETON_LOADER:{name:"fs-nearby-element",value:"skeleton-loader"},OPENINGS_LIST:{name:"fs-openings-element",value:"openings-list"},OPENINGS_BLOCK:{name:"fs-openings-element",value:"block"},OPENINGS_DEPARTMENT_HEADING:{name:"fs-openings-element",value:"department-heading"},OPENINGS_CARD_LIST:{name:"fs-openings-element",value:"card-list"},OPENINGS_CARD:{name:"fs-openings-element",value:"card"},OPENINGS_CARD_CITY_STATE_TEXT:{name:"fs-openings-element",value:"city-state-text"},OPENINGS_CARD_POSITION_TITLE:{name:"fs-openings-element",value:"position-title-text"},OPENINGS_CARD_VIEW_OPENINGS_LINK:{name:"fs-openings-element",value:"view-opening-link"}},j="https://uploads-ssl.webflow.com/60cb2013a506c737cfeddf74/651d99151ac303b66bcae4ad_Group.svg",M=36,k=36;function J(o,e,t,r){function i(n){return n instanceof t?n:new t(function(a){a(n)})}return new(t||(t=Promise))(function(n,a){function s(c){try{p(r.next(c))}catch(u){a(u)}}function l(c){try{p(r.throw(c))}catch(u){a(u)}}function p(c){c.done?n(c.value):i(c.value).then(s,l)}p((r=r.apply(o,e||[])).next())})}var U=function o(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){if(e.constructor!==t.constructor)return!1;var r,i,n;if(Array.isArray(e)){if(r=e.length,r!=t.length)return!1;for(i=r;i--!==0;)if(!o(e[i],t[i]))return!1;return!0}if(e.constructor===RegExp)return e.source===t.source&&e.flags===t.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===t.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===t.toString();if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,n[i]))return!1;for(i=r;i--!==0;){var a=n[i];if(!o(e[a],t[a]))return!1}return!0}return e!==e&&t!==t},H="__googleMapsScriptId",h;(function(o){o[o.INITIALIZED=0]="INITIALIZED",o[o.LOADING=1]="LOADING",o[o.SUCCESS=2]="SUCCESS",o[o.FAILURE=3]="FAILURE"})(h||(h={}));var d=class{constructor({apiKey:e,authReferrerPolicy:t,channel:r,client:i,id:n=H,language:a,libraries:s=[],mapIds:l,nonce:p,region:c,retries:u=3,url:_="https://maps.googleapis.com/maps/api/js",version:g}){if(this.callbacks=[],this.done=!1,this.loading=!1,this.errors=[],this.apiKey=e,this.authReferrerPolicy=t,this.channel=r,this.client=i,this.id=n||H,this.language=a,this.libraries=s,this.mapIds=l,this.nonce=p,this.region=c,this.retries=u,this.url=_,this.version=g,d.instance){if(!U(this.options,d.instance.options))throw new Error(`Loader must not be called again with different options. ${JSON.stringify(this.options)} !== ${JSON.stringify(d.instance.options)}`);return d.instance}d.instance=this}get options(){return{version:this.version,apiKey:this.apiKey,channel:this.channel,client:this.client,id:this.id,libraries:this.libraries,language:this.language,region:this.region,mapIds:this.mapIds,nonce:this.nonce,url:this.url,authReferrerPolicy:this.authReferrerPolicy}}get status(){return this.errors.length?h.FAILURE:this.done?h.SUCCESS:this.loading?h.LOADING:h.INITIALIZED}get failed(){return this.done&&!this.loading&&this.errors.length>=this.retries+1}createUrl(){let e=this.url;return e+="?callback=__googleMapsCallback",this.apiKey&&(e+=`&key=${this.apiKey}`),this.channel&&(e+=`&channel=${this.channel}`),this.client&&(e+=`&client=${this.client}`),this.libraries.length>0&&(e+=`&libraries=${this.libraries.join(",")}`),this.language&&(e+=`&language=${this.language}`),this.region&&(e+=`&region=${this.region}`),this.version&&(e+=`&v=${this.version}`),this.mapIds&&(e+=`&map_ids=${this.mapIds.join(",")}`),this.authReferrerPolicy&&(e+=`&auth_referrer_policy=${this.authReferrerPolicy}`),e}deleteScript(){let e=document.getElementById(this.id);e&&e.remove()}load(){return this.loadPromise()}loadPromise(){return new Promise((e,t)=>{this.loadCallback(r=>{r?t(r.error):e(window.google)})})}importLibrary(e){return this.execute(),google.maps.importLibrary(e)}loadCallback(e){this.callbacks.push(e),this.execute()}setScript(){var e,t;if(document.getElementById(this.id)){this.callback();return}let r={key:this.apiKey,channel:this.channel,client:this.client,libraries:this.libraries.length&&this.libraries,v:this.version,mapIds:this.mapIds,language:this.language,region:this.region,authReferrerPolicy:this.authReferrerPolicy};Object.keys(r).forEach(n=>!r[n]&&delete r[n]),!((t=(e=window==null?void 0:window.google)===null||e===void 0?void 0:e.maps)===null||t===void 0)&&t.importLibrary||(n=>{let a,s,l,p="The Google Maps JavaScript API",c="google",u="importLibrary",_="__ib__",g=document,E=window;E=E[c]||(E[c]={});let y=E.maps||(E.maps={}),P=new Set,I=new URLSearchParams,q=()=>a||(a=new Promise((b,O)=>J(this,void 0,void 0,function*(){var N;yield s=g.createElement("script"),s.id=this.id,I.set("libraries",[...P]+"");for(l in n)I.set(l.replace(/[A-Z]/g,F=>"_"+F[0].toLowerCase()),n[l]);I.set("callback",c+".maps."+_),s.src=this.url+"?"+I,y[_]=b,s.onerror=()=>a=O(Error(p+" could not load.")),s.nonce=this.nonce||((N=g.querySelector("script[nonce]"))===null||N===void 0?void 0:N.nonce)||"",g.head.append(s)})));y[u]?console.warn(p+" only loads once. Ignoring:",n):y[u]=(b,...O)=>P.add(b)&&q().then(()=>y[u](b,...O))})(r);let i=this.libraries.map(n=>this.importLibrary(n));i.length||i.push(this.importLibrary("core")),Promise.all(i).then(()=>this.callback(),n=>{let a=new ErrorEvent("error",{error:n});this.loadErrorCallback(a)})}reset(){this.deleteScript(),this.done=!1,this.loading=!1,this.errors=[],this.onerrorEvent=null}resetIfRetryingFailed(){this.failed&&this.reset()}loadErrorCallback(e){if(this.errors.push(e),this.errors.length<=this.retries){let t=this.errors.length*Math.pow(2,this.errors.length);console.error(`Failed to load Google Maps script, retrying in ${t} ms.`),setTimeout(()=>{this.deleteScript(),this.setScript()},t)}else this.onerrorEvent=e,this.callback()}callback(){this.done=!0,this.loading=!1,this.callbacks.forEach(e=>{e(this.onerrorEvent)}),this.callbacks=[]}execute(){if(this.resetIfRetryingFailed(),this.done)this.callback();else{if(window.google&&window.google.maps&&window.google.maps.version){console.warn("Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."),this.callback();return}this.loading||(this.loading=!0,this.setScript())}}};async function B(o,e){let t=new d({apiKey:x,version:"weekly",libraries:["maps","places","geocoding","geometry"]}),r={center:{lat:o.latitude,lng:o.longitude},zoom:G.ON_LOAD,mapTypeControl:!1,streetViewControl:!1,fullscreenControl:!1};try{let{Map:i}=await t.importLibrary("maps");await t.importLibrary("geometry");let n=new i(e,r);return new google.maps.Marker({position:{lat:o.latitude,lng:o.longitude},map:n,icon:{url:j,scaledSize:new google.maps.Size(M,k)}}),n}catch(i){if(i instanceof Error)throw new Error("Error loading Google Maps library: "+i.message)}}async function K(){let o=document.querySelectorAll(`[${m.LOCATION_DATA.name}=${m.LOCATION_DATA.value}]`);if(o===void 0||o.length===0){console.error("Location data embed not found");return}return Array.from(o).map(t=>{let r=t.querySelector("script");if(!r){console.error("No script tag found in location embed");return}let i=JSON.parse(r.innerHTML);return i.latitude=parseFloat(i.latitude.toString()),i.longitude=parseFloat(i.longitude.toString()),i})}window.Webflow||(window.Webflow=[]);window.Webflow.push(async()=>{let o=await K();if(o===void 0||o.length===0){console.error("Location not initialized");return}let e=o[0];if(!e){console.error("First Location not found");return}let t=$(e),r=document.querySelector(`[${m.GET_DIRECTIONS_LINK.name}="${m.GET_DIRECTIONS_LINK.value}"]`);r&&r.setAttribute("href",`https://www.google.com/maps?q=${t}`);let i=document.querySelectorAll(`[${m.MAP.name}=${m.MAP.value}]`);o.forEach(async(s,l)=>{if(!s){console.error("Location not defined");return}let p=i[l];if(!p){console.error("Map container not found");return}try{await B(s,p)}catch(c){console.error("Error loading Google Maps library: "+c.message)}});let{jobs:n}=await C();if(!n){console.error("Jobs not initialized");return}if(n.filter(s=>{let[l,p]=s.location.name.split(", ");return p===e.state&&l===e.name}).length===0){let s=document.querySelector(`[${m.OPENINGS_SECTION.name}=${m.OPENINGS_SECTION.value}]`),l=document.querySelector(`[${m.NO_OPENINGS_SECTION.name}=${m.NO_OPENINGS_SECTION.value}]`);s&&l&&(s.setAttribute("hidden","true"),l.removeAttribute("hidden"))}});})(); /*! Bundled license information: @googlemaps/js-api-loader/dist/index.esm.js: (*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** *) */