diff --git a/dist/bundle.js b/dist/bundle.js deleted file mode 100644 index 532e843..0000000 --- a/dist/bundle.js +++ /dev/null @@ -1 +0,0 @@ -!function(e){var t={};function s(o){if(t[o])return t[o].exports;var i=t[o]={i:o,l:!1,exports:{}};return e[o].call(i.exports,i,i.exports,s),i.l=!0,i.exports}s.m=e,s.c=t,s.d=function(e,t,o){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(s.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)s.d(o,i,function(t){return e[t]}.bind(null,i));return o},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=0)}([function(e,t,s){"use strict";s.r(t);class o{constructor(e){this.data,this.emitter=e,this.elem=document.querySelector(".js-btn-removed"),this.onClick=this.onClick.bind(this),this.elem.addEventListener("click",this.onClick)}onClick(){const e=document.querySelector(".btn-status--active");e&&e.classList.remove("btn-status--active"),this.elem.classList.add("btn-status--active");const t={...this.data,status:"removed"};this.emitter.emit("data-update",t)}}class i{constructor(e){this.data,this.emitter=e,this.elem=document.querySelector(".js-btn-present"),this.onClick=this.onClick.bind(this),this.elem.addEventListener("click",this.onClick)}onClick(){const e=document.querySelector(".btn-status--active");e&&e.classList.remove("btn-status--active"),this.elem.classList.add("btn-status--active");const t={...this.data,status:"present"};this.emitter.emit("data-update",t)}}class n{constructor(e){this.elem=document.querySelector(".js-btn-save"),this.emitter=e,this.active=!1,this.data=[],this.update=this.update.bind(this),this.onClick=this.onClick.bind(this),this.elem.addEventListener("click",this.onClick)}async onClick(){await fetch("https://khab7rvd6c.execute-api.us-east-1.amazonaws.com/dev/mailbox",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(this.data)}),this.data={},this.emitter.emit("data-save")}update(e){this.active||(this.active=!0,this.elem.disabled=!1),this.data=e}}var a=class{constructor(e){this.emitter=e,this.containerElem=document.querySelector(".js-data-entry-container"),this.removedBtn=new o(e),this.presentBtn=new i(e),this.saveBtn=new n(e),this.collectionBoxInfo=document.querySelector(".js-collection-box-info"),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.update=this.update.bind(this)}update(e){const t=e.properties,s={outlet:t.OUTLETID,lat:e.geometry.coordinates[1],lng:e.geometry.coordinates[0]},o=document.querySelector(".btn-status--active");o&&o.classList.remove("btn-status--active"),this.removedBtn.data=s,this.presentBtn.data=s,this.collectionBoxInfo.innerHTML=`
Outlet ID: ${t.OUTLETID}
Type: ${t.BUSNAME}
Address: ${t.ADDR1}
`}show(e){this.containerElem.classList.remove("data-entry-container--hidden"),this.update(e)}hide(){this.containerElem.classList.remove("data-entry-container--hidden")}};class c{constructor(e){this.emitter=e,this.elem=document.querySelector(".js-btn-back"),this.show=this.show.bind(this),this.hide=this.hide.bind(this),this.onClick=this.onClick.bind(this),this.elem.addEventListener("click",this.onClick)}onClick(){this.emitter.emit("show-map"),this.hide()}show(){this.elem.classList.remove("btn-back--hidden")}hide(){this.elem.classList.add("btn-back--hidden")}}var r=class{constructor(){this.timeOut,this.elem=document.querySelector(".snack"),this.showSnack=this.showSnack.bind(this)}showSnack(){clearTimeout(this.timeOut),this.elem.classList.remove("snack--hidden"),this.elem.classList.add("snack--visible"),this.timeOut=setTimeout(()=>{this.elem.classList.remove("snack--visible"),setTimeout(()=>{this.elem.classList.add("snack--hidden")},500)},2500)}};var l,d=class{constructor(e){this.emitter=e,this.modal=document.querySelector(".js-modal"),this.background=document.querySelector(".js-modal__background"),this.title=document.querySelector(".modal-title"),this.body=document.querySelector(".js-modal__body"),this.continueBtn=document.querySelector(".js-modal-continue-btn"),this.aboutBtn=document.querySelector(".js-btn-about"),this.open=this.open.bind(this),this.close=this.close.bind(this),this.addEventListeners()}addEventListeners(){this.continueBtn.addEventListener("click",this.close),this.aboutBtn.addEventListener("click",this.open)}open(){this.modal.classList.add("modal--visible"),this.background.classList.add("modal__background--visible"),this.body.classList.add("modal__body--visible")}close(){this.modal.classList.remove("modal--visible"),this.background.classList.remove("modal__background--visible"),this.body.classList.remove("modal__body--visible"),this.emitter.emit("modal-close")}};{const e={all:l=l||new Map,on:function(e,t){var s=l.get(e);s&&s.push(t)||l.set(e,[t])},off:function(e,t){var s=l.get(e);s&&s.splice(s.indexOf(t)>>>0,1)},emit:function(e,t){(l.get(e)||[]).slice().map((function(e){e(t)})),(l.get("*")||[]).slice().map((function(s){s(e,t)}))}};let t=!1;new d(e);const s=new a(e),o=new c(e),i=new r(e);function u(){document.querySelector(".overview-container").classList.remove("overview-container--hidden")}e.on("point-select",s.show),e.on("point-select",(function(){document.querySelector(".overview-container").classList.add("overview-container--hidden")})),e.on("point-select",o.show),e.on("data-update",s.saveBtn.update),e.on("show-map",u),e.on("show-map",s.hide),e.on("data-save",u),e.on("data-save",s.hide),e.on("data-save",i.showSnack),e.on("data-save",o.hide),e.on("data-save",()=>{fetch("https://khab7rvd6c.execute-api.us-east-1.amazonaws.com/dev/mailbox").then(e=>e.json()).then(e=>{n.getSource("collection-box-surveyed-src").setData(e)})}),e.on("modal-close",(function(){t||navigator.geolocation&&navigator.geolocation.getCurrentPosition(h);t=!0})),mapboxgl.accessToken="pk.eyJ1IjoicnVzc2JpZ2dzIiwiYSI6ImNrZHg2am55ejE3aHYyeWtqOGtocjh4ejgifQ.Qg_LH8LUNchJZBPsqDme9g";const n=new mapboxgl.Map({container:"map",style:"mapbox://styles/mapbox/streets-v11",center:[-98.5795,39.8283],zoom:5});function h(e){n.flyTo({center:[e.coords.longitude,e.coords.latitude],zoom:12})}n.addControl(new MapboxGeocoder({accessToken:mapboxgl.accessToken,mapboxgl:mapboxgl})),n.addControl(new mapboxgl.NavigationControl),n.addControl(new mapboxgl.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0})),n.on("load",(function(){fetch("https://khab7rvd6c.execute-api.us-east-1.amazonaws.com/dev/mailbox").then(e=>e.json()).then(e=>{n.addSource("collection-box-surveyed-src",{type:"geojson",data:e});n.addLayer({id:"collection-boxes-surveyed",type:"circle",source:"collection-box-surveyed-src",paint:{"circle-color":["match",["get","status"],"removed","#FF0000","present","#008000","#004B87"],"circle-radius":{base:4,stops:[[9,4],[12,6],[16,8],[18,10],[22,180]]}}})}),n.addSource("collection-box-src",{type:"vector",url:"mapbox://mikelmaron.3ws9y5k1"}),n.addLayer({id:"collection-boxes",type:"circle",source:"collection-box-src","source-layer":"collection_box_trim_valid-0tbyft",paint:{"circle-color":"#004B87","circle-radius":{base:4,stops:[[9,4],[12,6],[16,8],[18,10],[22,180]]}}}),n.on("mouseenter","collection-boxes-surveyed",(function(){n.getCanvas().style.cursor="pointer"})),n.on("mouseleave","collection-boxes-surveyed",(function(){n.getCanvas().style.cursor=""})),n.on("mouseenter","collection-boxes",(function(){n.getCanvas().style.cursor="pointer"})),n.on("mouseleave","collection-boxes",(function(){n.getCanvas().style.cursor=""})),n.on("click","collection-boxes",(function(e){})),n.on("click",(function(t){let s=n.queryRenderedFeatures(t.point,{layers:["collection-boxes-surveyed"]});if(s.length){const e=s[0].geometry.coordinates.slice(),o=s[0].properties.status,i=s[0].properties.outlet;for(;Math.abs(t.lngLat.lng-e[0])>180;)e[0]+=t.lngLat.lng>e[0]?360:-360;(new mapboxgl.Popup).setLngLat(e).setHTML(`Outlet ID: ${i}Status: ${o}
`).addTo(n)}else s=n.queryRenderedFeatures(t.point,{layers:["collection-boxes"]}),s.length&&e.emit("point-select",s[0])}))}));"mediaDevices"in navigator&&console.log("media supported")}}]); \ No newline at end of file diff --git a/dist/style.css b/dist/style.css deleted file mode 100644 index 494a4a8..0000000 --- a/dist/style.css +++ /dev/null @@ -1 +0,0 @@ -button{display:inline-block;border:none;margin:0;text-decoration:none;font-family:sans-serif;font-size:1rem;cursor:pointer;text-align:center;transition:background 250ms ease-in-out, transform 150ms ease;-webkit-appearance:none;-moz-appearance:none}button:focus{outline:none}button:active{transform:scale(0.99)}.btn{display:flex;flex-direction:row;align-items:center;padding:10px 20px;margin:10px;background-color:#004B87;color:white}.btn-about{background-image:url("/static/svg/info.svg");background-repeat:no-repeat;background-position:center;width:40px;height:40px;text-align:center;vertical-align:middle;margin:0 10px}.btn-status--active span::after{content:'\0000a0\2713'}.btn-back{background-image:url("/static/svg/chevron-left.svg");background-repeat:no-repeat;background-position:center;width:40px;height:40px;text-align:center;vertical-align:middle;margin:0px 10px}.btn-back--hidden{visibility:hidden}.btn-removed{background-color:red}.btn-present{background-color:green}.btn-save:disabled{background-color:#999;cursor:not-allowed}.btn-photo--hidden{display:none}.snack{z-index:9;text-align:center;position:fixed;left:calc(50% - 140px);height:60px;padding:15px;width:280px;color:white;background-color:#333;line-height:20px;opacity:0.9;bottom:0;transform:translateY(72px);will-change:transform;transition:transform 0.4s ease-in-out}.snack--hidden{background-color:white}.snack--visible{transform:none}.modal{visibility:hidden;display:flex;top:0;left:0;position:fixed;align-items:center;justify-content:center;z-index:999;width:100vw;height:100vh}.modal__background{display:block;background-color:#2b2b2b;width:100%;height:100%;opacity:0;text-align:center;transition:opacity 0.3s ease-out}.modal--visible{visibility:visible}.modal__background--visible{display:inherit;opacity:0.8}.modal__body{display:inline-block;text-align:center;position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);-ms-transform:translateX(-50%) translateY(-50%);-webkit-transform:translateX(-50%),translateY(-50%);transform:translate(-50%, -50%);background-color:white;box-shadow:2px 2px 5px #000;padding:20px;opacity:0;z-index:9999;width:90%;min-height:150px;will-change:opacity;transition:opacity 0.3s ease-in-out}.modal__body--visible{opacity:1}.modal-continue-btn{margin:0 auto;width:150px;position:relative;margin-top:20px;padding:10px;cursor:pointer;border:none;text-align:center;color:white;background-color:#004B87}.modal-title{margin-top:0;text-align:center}*{box-sizing:border-box;font-family:'Poppins', sans-serif}body,html{height:100%;margin:0;padding:0}body{height:100vh}.header{width:100vw;height:40px;background-color:#004B87;display:flex;display:-webkit-flex;justify-content:space-between;-webkit-justify-content:space-between}.title{margin:0px 5px;padding:0;line-height:40px;font-size:18px;color:white}main{display:flex;flex-direction:column}.data-entry-container{display:flex;flex-direction:column;height:calc(100vh - 40px);width:100vw;margin:10px;overflow-y:auto}.collection-box-info{display:flex;flex-direction:column}.collection-box-info p{margin:0px}.data-entry-container--hidden{display:none}.overview-container{height:calc(100vh - 40px);width:100vw;overflow-y:auto}.btn-row{display:flex;flex-direction:column;align-items:center}.overview-container--hidden{display:none}.media-row--hidden{display:none}#map{width:100%;height:100%;position:relative}