jonnybarnes.uk/public/assets/js/newnote.js

2 lines
7.3 KiB
JavaScript
Raw Normal View History

2016-12-10 22:54:18 +00:00
function getLocation(){navigator.geolocation.getCurrentPosition(function(e){addPlacesMap(e.coords.latitude,e.coords.longitude,e.coords.accuracy)})}function addPlacesMap(e,t,a){fetch("/places/near/"+e+"/"+t+"?u="+a,{credentials:"same-origin",method:"get"}).then(function(e){return e.json()}).then(function(a){if(a.error===!0&&(alertify.reset(),alertify.error(a.error_description)),a.places.length>0){var n,d=[];for(n=0;n<a.places.length;++n){var l=parseLocation(a.places[n].location),r=a.places[n].name,c=a.places[n].uri;d.push([r,c,l[0],l[1]])}addMap(e,t,d)}else addMap(e,t)}).catch(function(e){console.error(e)})}function addMap(e,t,a){2==arguments.length&&(a=null);var n=document.querySelector(".note-ui"),d=document.createElement("div");d.classList.add("map"),n.appendChild(d),mapboxgl.accessToken="pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiY2l2cDhjYW04MDAwcjJ0cG1uZnhqcm82ayJ9.qA2zeVA-nsoMh9IFrd5KQw";var l=new mapboxgl.Map({container:d,style:"mapbox://styles/mapbox/streets-v9",center:[t,e],zoom:15});l.addControl(new mapboxgl.NavigationControl);var r=document.createElement("div");r.classList.add("marker");var c=document.createElement("div");c.classList.add("map-menu");var i=document.createElement("input");i.setAttribute("id","streets"),i.setAttribute("type","radio"),i.setAttribute("name","toggle"),i.setAttribute("value","streets"),i.setAttribute("checked","checked"),i.addEventListener("click",function(){l.setStyle("mapbox://styles/mapbox/streets-v9")});var o=document.createElement("label");o.setAttribute("for","streets"),o.appendChild(document.createTextNode("Streets"));var u=document.createElement("input");u.setAttribute("id","satellite"),u.setAttribute("type","radio"),u.setAttribute("name","toggle"),u.setAttribute("value","streets"),u.addEventListener("click",function(){l.setStyle("mapbox://styles/mapbox/satellite-v9")});var p=document.createElement("label");p.setAttribute("for","satellite"),p.appendChild(document.createTextNode("Satellite")),c.appendChild(i),c.appendChild(o),c.appendChild(u),c.appendChild(p),d.appendChild(c),new mapboxgl.Marker(r,{offset:[-10,-20]}).setLngLat([t,e]).addTo(l);var s=document.createElement("div"),m=document.createElement("select");m.setAttribute("name","location");var b=document.createElement("option");b.setAttribute("value","no-location"),b.appendChild(document.createTextNode("Dont send location")),m.appendChild(b);var v=document.createElement("option");v.setAttribute("selected","selected"),v.setAttribute("id","option-coords"),v.setAttribute("value","geo:"+e+","+t),v.dataset.latitude=e,v.dataset.longitude=t,v.appendChild(document.createTextNode("Send co-ordinates")),m.appendChild(v),s.appendChild(m),n.insertBefore(s,d),null!==a&&(a.forEach(function(e){var t=document.createElement("option");t.setAttribute("value",e[1]);var a=document.createTextNode(e[0]);t.appendChild(a),t.dataset.latitude=e[2],t.dataset.longitude=e[3],m.appendChild(t);var n=document.createElement("div");n.classList.add("marker"),new mapboxgl.Marker(n,{offset:[-10,-20]}).setLngLat([e[3],e[2]]).addTo(l),n.addEventListener("click",function(){l.flyTo({center:[e[3],e[2]]}),selectPlace(e[1])})}),m.addEventListener("change",function(){if("no-location"!==m.value){var e=m[m.selectedIndex].dataset.latitude,t=m[m.selectedIndex].dataset.longitude;l.flyTo({center:[t,e]})}}));var h=document.createElement("button");h.setAttribute("type","button"),h.setAttribute("id","create-new-place"),h.appendChild(document.createTextNode("Create New Place?")),h.addEventListener("click",function(){var e=document.createElement("div"),t=document.createElement("label");t.setAttribute("for","place-name"),t.classList.add("place-label"),t.appendChild(document.createTextNode("Place Name:"));var a=document.createElement("input");a.setAttribute("placeholder","Name"),a.setAttribute("name","place-name"),a.setAttribute("id","place-name"),a.setAttribute("type","text"),e.appendChild(t),e.appendChild(a);var d=document.createElement("div"),r=document.createElement("label");r.setAttribute("for","place-description"),r.classList.add("place-label"),r.appendChild(document.createTextN
Squashed commit of the following: commit bb79d80d284bf22ae17857b37630d3075635057e Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Mon Dec 5 11:06:53 2016 +0000 Update changelog regarding Makefile commit d74d0ac99da0b898d1a08ed270629bb00b492e34 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Dec 4 19:24:09 2016 +0000 make output commit 5c7ad5830ec881a5c22bd737cac1ec3430577eb3 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Dec 4 19:22:25 2016 +0000 Remove gulp commit 160947dcd346d3c0016a15fe3b64d6f194d33bfc Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Dec 4 19:10:57 2016 +0000 Updated fetch dependency commit 25b8f300d93c3e6e129c7ac6ab31e85c12cebc6a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Dec 4 18:45:21 2016 +0000 Copy frontend assets into place commit 65b02a14e98215899efc4f5673953bdf23f4c942 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Sun Dec 4 18:40:28 2016 +0000 Add the target file for `sass`, and set the scss files as the prerequisits commit 7442df5040ac1459d5f088690390ef043f968852 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Dec 2 21:44:19 2016 +0000 Makefile output so far commit 8580a61aa2fb6326b99f58cb2d0418a45d734054 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Dec 2 21:42:32 2016 +0000 Create sourcemaps during js uglification commit facdbbf81f4907ce394dcb5719b76451fd45e539 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Fri Dec 2 21:40:48 2016 +0000 We can now uglify js files and compress all frontend assets commit 866c4fa0d70377f80061533989c4d8e6d00c818c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Dec 1 15:57:49 2016 +0000 A simple makefile
2016-12-05 11:07:22 +00:00
//# sourceMappingURL=public/assets/js/newnote.js.map