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

3 lines
6.2 KiB
JavaScript
Raw Normal View History

Squashed commit of the following: commit e7f1c4c84579b959fe2997ff4d2315ee53acfe9a Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Thu Sep 29 11:22:44 2016 +0100 Add latest change, fix spelling errors in rest of changelog commit 637b5107b557f1c2a56327a40b3d7b4b7297fa29 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 21:13:06 2016 +0100 Add a test for uncertainty parameter commit 5e7504b323debf9c91e0cca428b4dca7dda0789d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 21:11:12 2016 +0100 Format the ternaty operator correctly commit 19c978a5ac59cd7dfdceee9a8f1aaa6539d8ac66 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:46:19 2016 +0100 Fix typo commit d4e5b5fc384d0ccd715ea28a51821f958f6c2caa Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:41:23 2016 +0100 Add paraphanalia commit a96f104894de6c06dc5e41044482de2355cb4965 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:35:17 2016 +0100 Add the geolocation uncertainty to nearby places request commit 0f6d5649e2f3316040d7453f5fcc96ac1f0ac783 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 20:34:38 2016 +0100 Use a query parameter for geolocation uncertainty commit a9147a074315fabb0d76e5991b34a70b2143761c Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 19:58:08 2016 +0100 Make use of uncertainty parameter when finding nearby places commit bad384b5d8be3ea8905d8f6ca3c20f448869853d Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Sep 28 19:28:42 2016 +0100 Support sending uncertainty value to micropub endpoint
2016-09-29 11:28:31 +01: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+"?"+a,{credentials:"same-origin",method:"get"}).then(function(e){return e.json()}).then(function(a){if(1==a.error&&(alertify.reset(),alertify.error(a.error_description)),a.length>0){var n,r=[];for(n=0;n<a.length;++n){var o=parseLocation(a[n].location),l=a[n].name,c=a[n].slug;r.push([l,c,o[0],o[1]])}addMap(e,t,r)}else addMap(e,t)}).catch(function(e){console.error(e)})}function addMap(e,t,a){2==arguments.length&&(a=null);var n=button.parentNode,r=document.createElement("div");r.setAttribute("id","map"),n.appendChild(r),L.mapbox.accessToken="pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w";var o=L.mapbox.map("map","jonnybarnes.gnoihnim").setView([e,t],15).addLayer(L.mapbox.tileLayer("jonnybarnes.gnoihnim",{detectRetina:!0})),l=L.marker([e,t],{draggable:!0}).addTo(o);l.on("dragend",function(){var e=document.querySelector("#place-latitude");null!==e&&(e.value=getLatitudeFromMapboxMarker(l.getLatLng()));var t=document.querySelector("#place-longitude");null!==t&&(t.value=getLongitudeFromMapboxMarker(l.getLatLng()))});var c=document.createElement("select");c.setAttribute("name","location");var i=document.createElement("option");i.setAttribute("selected","selected"),i.setAttribute("value","no-location");var d=document.createTextNode("Select no location");i.appendChild(d),c.appendChild(i),n.insertBefore(c,r),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],c.appendChild(t);var n=L.marker([e[2],e[3]],{icon:L.mapbox.marker.icon({"marker-size":"large","marker-symbol":"building","marker-color":"#fa0"})}).addTo(o),r="Name: "+e[0];n.bindPopup(r,{closeButton:!0}),n.on("click",function(){o.panTo([e[2],e[3]]),selectPlace(e[1])})}),c.addEventListener("change",function(){if("no-location"!==c.value){var e=c[c.selectedIndex].dataset.latitude,t=c[c.selectedIndex].dataset.longitude;o.panTo([e,t])}}));var u=document.createElement("button");u.setAttribute("type","button"),u.setAttribute("id","create-new-place"),u.appendChild(document.createTextNode("Create New Place?")),u.addEventListener("click",function(){var e=document.createElement("label");e.setAttribute("for","place-name"),e.classList.add("place-label"),e.appendChild(document.createTextNode("Place Name:"));var t=document.createElement("input");t.setAttribute("placeholder","Name"),t.setAttribute("name","place-name"),t.setAttribute("id","place-name"),t.setAttribute("type","text");var a=document.createElement("label");a.setAttribute("for","place-description"),a.classList.add("place-label"),a.appendChild(document.createTextNode("Place Description:"));var r=document.createElement("input");r.setAttribute("placeholder","Description"),r.setAttribute("name","place-description"),r.setAttribute("id","place-description"),r.setAttribute("type","text");var i=document.createElement("label");i.setAttribute("for","place-latitude"),i.classList.add("place-label"),i.appendChild(document.createTextNode("Place Latitude:"));var d=document.createElement("input");d.setAttribute("name","place-latitude"),d.setAttribute("id","place-latitude"),d.setAttribute("type","text"),d.value=getLatitudeFromMapboxMarker(l.getLatLng());var u=document.createElement("label");u.setAttribute("for","place-longitude"),u.classList.add("place-label"),u.appendChild(document.createTextNode("Place Longitude:"));var p=document.createElement("input");p.setAttribute("name","place-longitude"),p.setAttribute("id","place-longitude"),p.setAttribute("type","text"),p.value=getLongitudeFromMapboxMarker(l.getLatLng());var m=document.createElement("button");m.setAttribute("id","place-submit"),m.setAttribute("value","Submit New Place"),m.setAttribute("name","place-submit"),m.setAttribute("type","button"),m.appendChild(document.createTextNode("Submit New Place")),n.appendChild(e),
2016-09-26 13:19:52 +01:00
//# sourceMappingURL=maps/newnote.js.map