diff --git a/gulpfile.js b/gulpfile.js index 4abcfafa..484de8d6 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -23,7 +23,9 @@ gulp.task('js-assets', function () { // .pipe(gulp.dest('./public/assets/js')); pump([ gulp.src(['resources/assets/js/**/*']), - uglify({outSourceMap: 'out.js.map'}), + sourcemaps.init(), + uglify(), + sourcemaps.write('./maps'), gulp.dest('./public/assets/js') ]); }); diff --git a/public/assets/js/form-save.js b/public/assets/js/form-save.js index 20d8f0a7..ce4018c5 100644 --- a/public/assets/js/form-save.js +++ b/public/assets/js/form-save.js @@ -1,69 +1,2 @@ -/* global alertify, store */ -var feature = { - addEventListener : !!window.addEventListener, - querySelectorAll : !!document.querySelectorAll -}; - -if (feature.addEventListener && feature.querySelectorAll) { - var keys = getKeys(); - for (var i = 0; i < keys.length; i++) { - if (store.get(keys[i])) { - var formId = keys[i].split('~')[1]; - document.getElementById(formId).value = store.get(keys[i]); - } - } -} - -var timerId = window.setInterval(function() { - var saved = false; - var inputs = document.querySelectorAll('input[type=text], textarea'); - for (var i = 0; i < inputs.length; i++) { - var key = getFormElement(inputs[i]).id + '~' + inputs[i].id; - if (store.get(key) !== inputs[i].value && inputs[i].value !== '') { - store.set(key, inputs[i].value); - saved = true; - } - } - if (saved === true) { - alertify.logPosition('top right'); - alertify.success('Auto saved text'); - } -}, 5000); -var forms = document.querySelectorAll('form'); -for (var f = 0; f < forms.length; f++) { - var form = forms[f]; - form.addEventListener('submit', function() { - window.clearInterval(timerId); - var formId = form.id; - var storedKeys = store.keys(); - for (var i = 0; i < storedKeys.length; i++) { - if (storedKeys[i].indexOf(formId) > -1) { - store.remove(storedKeys[i]); - } - } - }); -} -function getKeys() { - var keys = []; - var formFields = document.querySelectorAll('input[type=text], textarea'); - for (var f = 0; f < formFields.length; f++) { - var parent = getFormElement(formFields[f]); - if (parent !== false) { - var key = parent.id + '~' + formFields[f].id; - keys.push(key); - } - } - return keys; -} -function getFormElement(elem) { - if (elem.nodeName.toLowerCase() !== 'body') { - var parent = elem.parentNode; - if (parent.nodeName.toLowerCase() === 'form') { - return parent; - } else { - return getFormElement(parent); - } - } else { - return false; - } -} +function getKeys(){for(var e=[],t=document.querySelectorAll("input[type=text], textarea"),r=0;r-1&&store.remove(t[r])})} +//# sourceMappingURL=maps/form-save.js.map diff --git a/public/assets/js/links.js b/public/assets/js/links.js index 5871e0e3..1b49fbaf 100644 --- a/public/assets/js/links.js +++ b/public/assets/js/links.js @@ -1,26 +1,2 @@ -/* global Autolinker */ -//the autlinker object -var autolinker = new Autolinker(); - -//the youtube regex -var ytidregex = /watch\?v=([A-Za-z0-9\-_]+)/; - -//grab the notes and loop through them -var notes = document.querySelectorAll('.e-content'); -for (var i = 0; i < notes.length; i++) { - //get Youtube ID - var ytid = notes[i].textContent.match(ytidregex); - if (ytid !== null) { - var id = ytid[1]; - var iframe = document.createElement('iframe'); - iframe.classList.add('youtube'); - iframe.setAttribute('src', '//www.youtube.com/embed/' + id); - iframe.setAttribute('frameborder', 0); - iframe.setAttribute('allowfullscreen', 'true'); - notes[i].appendChild(iframe); - } - //now linkify everything - var orig = notes[i].innerHTML; - var linked = autolinker.link(orig); - notes[i].innerHTML = linked; -} +for(var autolinker=new Autolinker,ytidregex=/watch\?v=([A-Za-z0-9\-_]+)/,notes=document.querySelectorAll(".e-content"),i=0;i, then adds map -var mapDivs = document.querySelectorAll('.map'); -for (var i = 0; i < mapDivs.length; i++) { - var mapDiv = mapDivs[i]; - var latitude = mapDiv.dataset.latitude; - var longitude = mapDiv.dataset.longitude; - L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w'; - var map = L.mapbox.map(mapDiv, 'jonnybarnes.gnoihnim') - .setView([latitude, longitude], 15) - .addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', { - detectRetina: true - })); - L.marker([latitude, longitude]).addTo(map); - map.scrollWheelZoom.disable(); -} +for(var mapDivs=document.querySelectorAll(".map"),i=0;i -1) {\n store.remove(storedKeys[i]);\n }\n }\n });\n}\nfunction getKeys() {\n var keys = [];\n var formFields = document.querySelectorAll('input[type=text], textarea');\n for (var f = 0; f < formFields.length; f++) {\n var parent = getFormElement(formFields[f]);\n if (parent !== false) {\n var key = parent.id + '~' + formFields[f].id;\n keys.push(key);\n }\n }\n return keys;\n}\nfunction getFormElement(elem) {\n if (elem.nodeName.toLowerCase() !== 'body') {\n var parent = elem.parentNode;\n if (parent.nodeName.toLowerCase() === 'form') {\n return parent;\n } else {\n return getFormElement(parent);\n }\n } else {\n return false;\n }\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/public/assets/js/maps/links.js.map b/public/assets/js/maps/links.js.map new file mode 100644 index 00000000..a916918f --- /dev/null +++ b/public/assets/js/maps/links.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["links.js"],"names":["autolinker","Autolinker","ytidregex","notes","document","querySelectorAll","i","length","ytid","textContent","match","id","iframe","createElement","classList","add","setAttribute","appendChild","orig","innerHTML","linked","link"],"mappings":"AASA,IAAK,GAPDA,YAAa,GAAIC,YAGjBC,UAAY,6BAGZC,MAAQC,SAASC,iBAAiB,cAC7BC,EAAI,EAAGA,EAAIH,MAAMI,OAAQD,IAAK,CAEnC,GAAIE,MAAOL,MAAMG,GAAGG,YAAYC,MAAMR,UACtC,IAAa,OAATM,KAAe,CACf,GAAIG,IAAKH,KAAK,GACVI,OAASR,SAASS,cAAc,SACpCD,QAAOE,UAAUC,IAAI,WACrBH,OAAOI,aAAa,MAAO,2BAA6BL,IACxDC,OAAOI,aAAa,cAAe,GACnCJ,OAAOI,aAAa,kBAAmB,QACvCb,MAAMG,GAAGW,YAAYL,QAGzB,GAAIM,MAAOf,MAAMG,GAAGa,UAChBC,OAASpB,WAAWqB,KAAKH,KAC7Bf,OAAMG,GAAGa,UAAYC","file":"links.js","sourcesContent":["/* global Autolinker */\n//the autlinker object\nvar autolinker = new Autolinker();\n\n//the youtube regex\nvar ytidregex = /watch\\?v=([A-Za-z0-9\\-_]+)/;\n\n//grab the notes and loop through them\nvar notes = document.querySelectorAll('.e-content');\nfor (var i = 0; i < notes.length; i++) {\n //get Youtube ID\n var ytid = notes[i].textContent.match(ytidregex);\n if (ytid !== null) {\n var id = ytid[1];\n var iframe = document.createElement('iframe');\n iframe.classList.add('youtube');\n iframe.setAttribute('src', '//www.youtube.com/embed/' + id);\n iframe.setAttribute('frameborder', 0);\n iframe.setAttribute('allowfullscreen', 'true');\n notes[i].appendChild(iframe);\n }\n //now linkify everything\n var orig = notes[i].innerHTML;\n var linked = autolinker.link(orig);\n notes[i].innerHTML = linked;\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/public/assets/js/maps/maps.js.map b/public/assets/js/maps/maps.js.map new file mode 100644 index 00000000..2380c714 --- /dev/null +++ b/public/assets/js/maps/maps.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["maps.js"],"names":["mapDivs","document","querySelectorAll","i","length","mapDiv","latitude","dataset","longitude","L","mapbox","accessToken","map","setView","addLayer","tileLayer","detectRetina","marker","addTo","scrollWheelZoom","disable"],"mappings":"AAGA,IAAK,GADDA,SAAUC,SAASC,iBAAiB,QAC/BC,EAAI,EAAGA,EAAIH,QAAQI,OAAQD,IAAK,CACrC,GAAIE,QAASL,QAAQG,GACjBG,SAAWD,OAAOE,QAAQD,SAC1BE,UAAaH,OAAOE,QAAQC,SAChCC,GAAEC,OAAOC,YAAc,wEACvB,IAAIC,KAAMH,EAAEC,OAAOE,IAAIP,OAAQ,wBAC1BQ,SAASP,SAAUE,WAAY,IAC/BM,SAASL,EAAEC,OAAOK,UAAU,wBACzBC,cAAc,IAEtBP,GAAEQ,QAAQX,SAAUE,YAAYU,MAAMN,KACtCA,IAAIO,gBAAgBC","file":"maps.js","sourcesContent":["/* global L */\n//This code runs on page load and looks for
, then adds map\nvar mapDivs = document.querySelectorAll('.map');\nfor (var i = 0; i < mapDivs.length; i++) {\n var mapDiv = mapDivs[i];\n var latitude = mapDiv.dataset.latitude;\n var longitude = mapDiv.dataset.longitude;\n L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w';\n var map = L.mapbox.map(mapDiv, 'jonnybarnes.gnoihnim')\n .setView([latitude, longitude], 15)\n .addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', {\n detectRetina: true\n }));\n L.marker([latitude, longitude]).addTo(map);\n map.scrollWheelZoom.disable();\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/public/assets/js/maps/newnote.js.map b/public/assets/js/maps/newnote.js.map new file mode 100644 index 00000000..e2027f6f --- /dev/null +++ b/public/assets/js/maps/newnote.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["newnote.js"],"names":["getLocation","navigator","geolocation","getCurrentPosition","position","addPlacesMap","coords","latitude","longitude","fetch","credentials","method","then","response","json","j","error","alertify","reset","error_description","length","i","places","latlng","parseLocation","location","name","slug","push","addMap","catch","err","console","arguments","form","button","parentNode","div","document","createElement","setAttribute","appendChild","L","mapbox","accessToken","map","setView","addLayer","tileLayer","detectRetina","marker","draggable","addTo","on","placeFormLatitude","querySelector","value","getLatitudeFromMapboxMarker","getLatLng","placeFormLongitude","getLongitudeFromMapboxMarker","selectEl","noLocation","noLocText","createTextNode","insertBefore","forEach","item","option","text","dataset","placeMarker","icon","marker-size","marker-symbol","marker-color","bindPopup","closeButton","panTo","selectPlace","addEventListener","placeLat","selectedIndex","placeLon","newLocButton","nameLabel","classList","add","nameEl","descLabel","descEl","latLabel","latEl","lonLabel","lonEl","placeSubmit","formData","FormData","append","body","placeJson","Error","urlParts","split","pop","removeChild","labels","querySelectorAll","removeLayer","newOption","newPlaceMarker","newName","placeError","point","re","resultArray","exec","selected","replace","disabled"],"mappings":"AAWA,QAASA,eACLC,UAAUC,YAAYC,mBAAmB,SAAUC,GAE/CC,aAAaD,EAASE,OAAO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AW,EAClBpF,OAAO6C,iBAAiB,QAAShF","file":"newnote.js","sourcesContent":["/* global L, alertify */\nif ('geolocation' in navigator) {\n var button = document.querySelector('#locate');\n if (button.addEventListener) {\n //if we have javascript, event listeners and geolocation, make the locate\n //button clickable and add event\n button.disabled = false;\n button.addEventListener('click', getLocation);\n }\n}\n\nfunction getLocation() {\n navigator.geolocation.getCurrentPosition(function (position) {\n //the locate button has been clicked so add the places/map\n addPlacesMap(position.coords.latitude, position.coords.longitude);\n });\n}\n\nfunction addPlacesMap(latitude, longitude) {\n //get the nearby places\n fetch('/places/near/' + latitude + '/' + longitude, {\n credentials: 'same-origin',\n method: 'get'\n }).then(function (response) {\n return response.json();\n }).then(function (j) {\n if (j.error == true) {\n alertify.reset();\n alertify.error(j.error_description);\n }\n if (j.length > 0) {\n var i;\n var places = [];\n for (i = 0; i < j.length; ++i) {\n var latlng = parseLocation(j[i].location);\n var name = j[i].name;\n var slug = j[i].slug;\n places.push([name, slug, latlng[0], latlng[1]]);\n }\n //add a map with the nearby places\n addMap(latitude, longitude, places);\n } else {\n //add a map with just current location\n addMap(latitude, longitude);\n }\n }).catch(function (err) {\n console.error(err);\n });\n}\n\nfunction addMap(latitude, longitude, places) {\n //make places null if not supplied\n if (arguments.length == 2) {\n places = null;\n }\n var form = button.parentNode;\n var div = document.createElement('div');\n div.setAttribute('id', 'map');\n //add the map div\n form.appendChild(div);\n L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w';\n var map = L.mapbox.map('map', 'jonnybarnes.gnoihnim')\n .setView([latitude, longitude], 15)\n .addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', {\n detectRetina: true\n }));\n //add a marker for the current location\n var marker = L.marker([latitude, longitude], {\n draggable: true\n }).addTo(map);\n //when the location marker is dragged, if the new place form elements exist\n //update the lat/lng values\n marker.on('dragend', function () {\n var placeFormLatitude = document.querySelector('#place-latitude');\n if (placeFormLatitude !== null) {\n placeFormLatitude.value = getLatitudeFromMapboxMarker(marker.getLatLng());\n }\n var placeFormLongitude = document.querySelector('#place-longitude');\n if (placeFormLongitude !== null) {\n placeFormLongitude.value = getLongitudeFromMapboxMarker(marker.getLatLng());\n }\n });\n //create the \n places.forEach(function (item) {\n var option = document.createElement('option');\n option.setAttribute('value', item[1]);\n var text = document.createTextNode(item[0]);\n option.appendChild(text);\n option.dataset.latitude = item[2];\n option.dataset.longitude = item[3];\n selectEl.appendChild(option);\n var placeMarker = L.marker([item[2], item[3]], {\n icon: L.mapbox.marker.icon({\n 'marker-size': 'large',\n 'marker-symbol': 'building',\n 'marker-color': '#fa0'\n })\n }).addTo(map);\n var name = 'Name: ' + item[0];\n placeMarker.bindPopup(name, {\n closeButton: true\n });\n placeMarker.on('click', function () {\n map.panTo([item[2], item[3]]);\n selectPlace(item[1]);\n });\n });\n //add an event listener\n selectEl.addEventListener('change', function () {\n if (selectEl.value !== 'no-location') {\n var placeLat = selectEl[selectEl.selectedIndex].dataset.latitude;\n var placeLon = selectEl[selectEl.selectedIndex].dataset.longitude;\n map.panTo([placeLat, placeLon]);\n }\n });\n }\n //add a button to add a new place\n var newLocButton = document.createElement('button');\n newLocButton.setAttribute('type', 'button');\n newLocButton.setAttribute('id', 'create-new-place');\n newLocButton.appendChild(document.createTextNode('Create New Place?'));\n //the event listener\n newLocButton.addEventListener('click', function() {\n //add the form elements\n var nameLabel = document.createElement('label');\n nameLabel.setAttribute('for', 'place-name');\n nameLabel.classList.add('place-label');\n nameLabel.appendChild(document.createTextNode('Place Name:'));\n var nameEl = document.createElement('input');\n nameEl.setAttribute('placeholder', 'Name');\n nameEl.setAttribute('name', 'place-name');\n nameEl.setAttribute('id', 'place-name');\n nameEl.setAttribute('type', 'text');\n var descLabel = document.createElement('label');\n descLabel.setAttribute('for', 'place-description');\n descLabel.classList.add('place-label');\n descLabel.appendChild(document.createTextNode('Place Description:'));\n var descEl = document.createElement('input');\n descEl.setAttribute('placeholder', 'Description');\n descEl.setAttribute('name', 'place-description');\n descEl.setAttribute('id', 'place-description');\n descEl.setAttribute('type', 'text');\n var latLabel = document.createElement('label');\n latLabel.setAttribute('for', 'place-latitude');\n latLabel.classList.add('place-label');\n latLabel.appendChild(document.createTextNode('Place Latitude:'));\n var latEl = document.createElement('input');\n latEl.setAttribute('name', 'place-latitude');\n latEl.setAttribute('id', 'place-latitude');\n latEl.setAttribute('type', 'text');\n latEl.value = getLatitudeFromMapboxMarker(marker.getLatLng());\n var lonLabel = document.createElement('label');\n lonLabel.setAttribute('for', 'place-longitude');\n lonLabel.classList.add('place-label');\n lonLabel.appendChild(document.createTextNode('Place Longitude:'));\n var lonEl = document.createElement('input');\n lonEl.setAttribute('name', 'place-longitude');\n lonEl.setAttribute('id', 'place-longitude');\n lonEl.setAttribute('type', 'text');\n lonEl.value = getLongitudeFromMapboxMarker(marker.getLatLng());\n var placeSubmit = document.createElement('button');\n placeSubmit.setAttribute('id', 'place-submit');\n placeSubmit.setAttribute('value', 'Submit New Place');\n placeSubmit.setAttribute('name', 'place-submit');\n placeSubmit.setAttribute('type', 'button');\n placeSubmit.appendChild(document.createTextNode('Submit New Place'));\n form.appendChild(nameLabel);\n form.appendChild(nameEl);\n form.appendChild(descLabel);\n form.appendChild(descEl);\n form.appendChild(latLabel);\n form.appendChild(latEl);\n form.appendChild(lonLabel);\n form.appendChild(lonEl);\n form.appendChild(placeSubmit);\n //the event listener for the new place form\n placeSubmit.addEventListener('click', function () {\n //create the form data to send\n var formData = new FormData();\n formData.append('place-name', document.querySelector('#place-name').value);\n formData.append('place-description', document.querySelector('#place-description').value);\n formData.append('place-latitude', document.querySelector('#place-latitude').value);\n formData.append('place-longitude', document.querySelector('#place-longitude').value);\n //post the new place\n fetch('/places/new', {\n //send cookies with the request\n credentials: 'same-origin',\n method: 'post',\n body: formData\n })\n .then(function (response) {\n return response.json();\n })\n .then(function (placeJson) {\n if (placeJson.error == true) {\n throw new Error(placeJson.error_description);\n }\n //create the slug from the url\n var urlParts = placeJson.split('/');\n var slug = urlParts.pop();\n //remove un-needed form elements\n form.removeChild(document.querySelector('#place-name'));\n form.removeChild(document.querySelector('#place-description'));\n form.removeChild(document.querySelector('#place-latitude'));\n form.removeChild(document.querySelector('#place-longitude'));\n var labels = document.querySelectorAll('.place-label');\n for (var i = 0; i < labels.length; ++i) {\n form.removeChild(labels[i]);\n }\n form.removeChild(document.querySelector('#place-submit'));\n form.removeChild(document.querySelector('#create-new-place'));\n //remove location marker\n map.removeLayer(marker);\n //add place marker\n var newOption = document.createElement('option');\n newOption.setAttribute('value', slug);\n newOption.appendChild(document.createTextNode(placeJson['name']));\n newOption.dataset.latitude = placeJson['latitude'];\n newOption.dataset.longitude = placeJson['longitude'];\n selectEl.appendChild(newOption);\n var newPlaceMarker = L.marker([placeJson['latitude'], placeJson['longitude']], {\n icon: L.mapbox.marker.icon({\n 'marker-size': 'large',\n 'marker-symbol': 'building',\n 'marker-color': '#fa0'\n })\n }).addTo(map);\n var newName = 'Name: ' + placeJson['name'];\n newPlaceMarker.bindPopup(newName, {\n closeButton: true\n });\n newPlaceMarker.on('click', function () {\n map.panTo([placeJson['latitude'], placeJson['longitude']]);\n selectPlace(slug);\n });\n //make selected\n selectPlace(slug);\n }).catch(function (placeError) {\n alertify.reset();\n alertify.error(placeError);\n });\n });\n });\n form.insertBefore(newLocButton, div);\n}\n\nfunction parseLocation(point) {\n var re = /\\((.*)\\)/;\n var resultArray = re.exec(point);\n var location = resultArray[1].split(' ');\n\n return [location[1], location[0]];\n}\n\nfunction selectPlace(slug) {\n document.querySelector('select [value=' + slug + ']').selected = true;\n}\n\nfunction getLatitudeFromMapboxMarker(latlng) {\n var resultArray = /\\((.*)\\)/.exec(latlng);\n var location = resultArray[1].split(' ');\n\n return location[0].replace(',', '');\n}\n\nfunction getLongitudeFromMapboxMarker(latlng) {\n var resultArray = /\\((.*)\\)/.exec(latlng);\n var location = resultArray[1].split(' ');\n\n return location[1];\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/public/assets/js/maps/newplace.js.map b/public/assets/js/maps/newplace.js.map new file mode 100644 index 00000000..1a6a5855 --- /dev/null +++ b/public/assets/js/maps/newplace.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["newplace.js"],"names":["getLocation","navigator","geolocation","getCurrentPosition","position","updateForm","coords","latitude","longitude","addMap","inputLatitude","document","querySelector","inputLongitude","value","form","div","createElement","setAttribute","appendChild","L","mapbox","accessToken","map","setView","addLayer","tileLayer","detectRetina","marker","draggable","addTo","on","markerLocation","getLatLng","lat","lng","button","addEventListener","attachEvent"],"mappings":"AASA,QAASA,eACD,eAAiBC,YACjBA,UAAUC,YAAYC,mBAAmB,SAASC,GAC9CC,WAAWD,EAASE,OAAOC,SAAUH,EAASE,OAAOE,WACrDC,OAAOL,EAASE,OAAOC,SAAUH,EAASE,OAAOE,aAK7D,QAASH,YAAWE,EAAUC,GAC1B,GAAIE,GAAgBC,SAASC,cAAc,aACvCC,EAAiBF,SAASC,cAAc,aAC5CF,GAAcI,MAAQP,EACtBM,EAAeC,MAAQN,EAG3B,QAASC,QAAOF,EAAUC,GACtB,GAAIO,GAAOJ,SAASC,cAAc,QAC9BI,EAAML,SAASM,cAAc,MACjCD,GAAIE,aAAa,KAAM,OACvBH,EAAKI,YAAYH,GACjBI,EAAEC,OAAOC,YAAc,wEACvB,IAAIC,GAAMH,EAAEC,OAAOE,IAAI,MAAO,wBACzBC,SAASjB,EAAUC,GAAY,IAC/BiB,SAASL,EAAEC,OAAOK,UAAU,wBACzBC,cAAc,KAElBC,EAASR,EAAEQ,QAAQrB,EAAUC,IAC7BqB,WAAW,IACZC,MAAMP,EACTK,GAAOG,GAAG,UAAW,WACjB,GAAIC,GAAiBJ,EAAOK,WAC5B5B,YAAW2B,EAAeE,IAAKF,EAAeG,OAxCtD,GAAIC,QAASzB,SAASC,cAAc,UAEhCwB,QAAOC,iBACPD,OAAOC,iBAAiB,QAASrC,aAEjCoC,OAAOE,YAAY,UAAWtC","file":"newplace.js","sourcesContent":["/* global L */\nvar button = document.querySelector('#locate');\n\nif (button.addEventListener) {\n button.addEventListener('click', getLocation);\n} else {\n button.attachEvent('onclick', getLocation);\n}\n\nfunction getLocation() {\n if ('geolocation' in navigator) {\n navigator.geolocation.getCurrentPosition(function(position) {\n updateForm(position.coords.latitude, position.coords.longitude);\n addMap(position.coords.latitude, position.coords.longitude);\n });\n }\n}\n\nfunction updateForm(latitude, longitude) {\n var inputLatitude = document.querySelector('#latitude');\n var inputLongitude = document.querySelector('#longitude');\n inputLatitude.value = latitude;\n inputLongitude.value = longitude;\n}\n\nfunction addMap(latitude, longitude) {\n var form = document.querySelector('form');\n var div = document.createElement('div');\n div.setAttribute('id', 'map');\n form.appendChild(div);\n L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w';\n var map = L.mapbox.map('map', 'jonnybarnes.gnoihnim')\n .setView([latitude, longitude], 15)\n .addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', {\n detectRetina: true\n }));\n var marker = L.marker([latitude, longitude], {\n draggable: true\n }).addTo(map);\n marker.on('dragend', function () {\n var markerLocation = marker.getLatLng();\n updateForm(markerLocation.lat, markerLocation.lng);\n });\n}\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/public/assets/js/newnote.js b/public/assets/js/newnote.js index 0ea0874b..80ed1088 100644 --- a/public/assets/js/newnote.js +++ b/public/assets/js/newnote.js @@ -1,282 +1,2 @@ -/* global L */ -if ('geolocation' in navigator) { - var button = document.querySelector('#locate'); - if (button.addEventListener) { - //if we have javascript, event listeners and geolocation, make the locate - //button clickable and add event - button.disabled = false; - button.addEventListener('click', getLocation); - } -} - -function getLocation() { - navigator.geolocation.getCurrentPosition(function (position) { - //the locate button has been clicked so add the places/map - addPlacesMap(position.coords.latitude, position.coords.longitude); - }); -} - -function addPlacesMap(latitude, longitude) { - //get the nearby places - fetch('/places/near/' + latitude + '/' + longitude, { - credentials: 'same-origin', - method: 'get' - }).then(function (response) { - return response.json(); - }).then(function (j) { - if (j.error == true) { - alertify.reset(); - alertify.error(j.error_description); - } - if (j.length > 0) { - var i; - var places = []; - for (i = 0; i < j.length; ++i) { - var latlng = parseLocation(j[i].location); - var name = j[i].name; - var slug = j[i].slug; - places.push([name, slug, latlng[0], latlng[1]]); - } - //add a map with the nearby places - addMap(latitude, longitude, places); - } else { - //add a map with just current location - addMap(latitude, longitude); - } - }).catch(function (err) { - console.error(err); - }); -} - -function addMap(latitude, longitude, places) { - //make places null if not supplied - if (arguments.length == 2) { - places = null; - } - var form = button.parentNode; - var div = document.createElement('div'); - div.setAttribute('id', 'map'); - //add the map div - form.appendChild(div); - L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w'; - var map = L.mapbox.map('map', 'jonnybarnes.gnoihnim') - .setView([latitude, longitude], 15) - .addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', { - detectRetina: true - })); - //add a marker for the current location - var marker = L.marker([latitude, longitude], { - draggable: true - }).addTo(map); - //when the location marker is dragged, if the new place form elements exist - //update the lat/lng values - marker.on('dragend', function () { - var placeFormLatitude = document.querySelector('#place-latitude'); - if (placeFormLatitude !== null) { - placeFormLatitude.value = getLatitudeFromMapboxMarker(marker.getLatLng()); - } - var placeFormLongitude = document.querySelector('#place-longitude'); - if (placeFormLongitude !== null) { - placeFormLongitude.value = getLongitudeFromMapboxMarker(marker.getLatLng()); - } - }); - //create the - places.forEach(function (item) { - var option = document.createElement('option'); - option.setAttribute('value', item[1]); - var text = document.createTextNode(item[0]); - option.appendChild(text); - option.dataset.latitude = item[2]; - option.dataset.longitude = item[3]; - selectEl.appendChild(option); - var placeMarker = L.marker([item[2], item[3]], { - icon: L.mapbox.marker.icon({ - 'marker-size': 'large', - 'marker-symbol': 'building', - 'marker-color': '#fa0' - }) - }).addTo(map); - var name = 'Name: ' + item[0]; - placeMarker.bindPopup(name, { - closeButton: true - }); - placeMarker.on('click', function () { - map.panTo([item[2], item[3]]); - selectPlace(item[1]); - }); - }); - //add an event listener - selectEl.addEventListener('change', function () { - if (selectEl.value !== 'no-location') { - var placeLat = selectEl[selectEl.selectedIndex].dataset.latitude; - var placeLon = selectEl[selectEl.selectedIndex].dataset.longitude; - map.panTo([placeLat, placeLon]); - } - }); - } - //add a button to add a new place - var newLocButton = document.createElement('button'); - newLocButton.setAttribute('type', 'button'); - newLocButton.setAttribute('id', 'create-new-place'); - newLocButton.appendChild(document.createTextNode('Create New Place?')); - //the event listener - newLocButton.addEventListener('click', function() { - //add the form elements - var nameLabel = document.createElement('label'); - nameLabel.setAttribute('for', 'place-name'); - nameLabel.classList.add('place-label'); - nameLabel.appendChild(document.createTextNode('Place Name:')); - var nameEl = document.createElement('input'); - nameEl.setAttribute('placeholder', 'Name'); - nameEl.setAttribute('name', 'place-name'); - nameEl.setAttribute('id', 'place-name'); - nameEl.setAttribute('type', 'text'); - var descLabel = document.createElement('label'); - descLabel.setAttribute('for', 'place-description'); - descLabel.classList.add('place-label'); - descLabel.appendChild(document.createTextNode('Place Description:')); - var descEl = document.createElement('input'); - descEl.setAttribute('placeholder', 'Description'); - descEl.setAttribute('name', 'place-description'); - descEl.setAttribute('id', 'place-description'); - descEl.setAttribute('type', 'text'); - var latLabel = document.createElement('label'); - latLabel.setAttribute('for', 'place-latitude'); - latLabel.classList.add('place-label'); - latLabel.appendChild(document.createTextNode('Place Latitude:')); - var latEl = document.createElement('input'); - latEl.setAttribute('name', 'place-latitude'); - latEl.setAttribute('id', 'place-latitude'); - latEl.setAttribute('type', 'text'); - latEl.value = getLatitudeFromMapboxMarker(marker.getLatLng()); - var lonLabel = document.createElement('label'); - lonLabel.setAttribute('for', 'place-longitude'); - lonLabel.classList.add('place-label'); - lonLabel.appendChild(document.createTextNode('Place Longitude:')); - var lonEl = document.createElement('input'); - lonEl.setAttribute('name', 'place-longitude'); - lonEl.setAttribute('id', 'place-longitude'); - lonEl.setAttribute('type', 'text'); - lonEl.value = getLongitudeFromMapboxMarker(marker.getLatLng()); - var placeSubmit = document.createElement('button'); - placeSubmit.setAttribute('id', 'place-submit'); - placeSubmit.setAttribute('value', 'Submit New Place'); - placeSubmit.setAttribute('name', 'place-submit'); - placeSubmit.setAttribute('type', 'button'); - placeSubmit.appendChild(document.createTextNode('Submit New Place')); - form.appendChild(nameLabel); - form.appendChild(nameEl); - form.appendChild(descLabel); - form.appendChild(descEl); - form.appendChild(latLabel); - form.appendChild(latEl); - form.appendChild(lonLabel); - form.appendChild(lonEl); - form.appendChild(placeSubmit); - //the event listener for the new place form - placeSubmit.addEventListener('click', function () { - //create the form data to send - var formData = new FormData(); - formData.append('place-name', document.querySelector('#place-name').value); - formData.append('place-description', document.querySelector('#place-description').value); - formData.append('place-latitude', document.querySelector('#place-latitude').value); - formData.append('place-longitude', document.querySelector('#place-longitude').value); - //post the new place - fetch('/places/new', { - //send cookies with the request - credentials: 'same-origin', - method: 'post', - body: formData - }) - .then(function (response) { - return response.json(); - }) - .then(function (placeJson) { - if (placeJson.error == true) { - throw new Error(placeJson.error_description); - } - //create the slug from the url - var urlParts = placeJson.split('/'); - var slug = urlParts.pop(); - //remove un-needed form elements - form.removeChild(document.querySelector('#place-name')); - form.removeChild(document.querySelector('#place-description')); - form.removeChild(document.querySelector('#place-latitude')); - form.removeChild(document.querySelector('#place-longitude')); - var labels = document.querySelectorAll('.place-label'); - for (var i = 0; i < labels.length; ++i) { - form.removeChild(labels[i]); - } - form.removeChild(document.querySelector('#place-submit')); - form.removeChild(document.querySelector('#create-new-place')); - //remove location marker - map.removeLayer(marker); - //add place marker - var newOption = document.createElement('option'); - newOption.setAttribute('value', slug); - newOption.appendChild(document.createTextNode(placeJson['name'])); - newOption.dataset.latitude = placeJson['latitude']; - newOption.dataset.longitude = placeJson['longitude']; - selectEl.appendChild(newOption); - var newPlaceMarker = L.marker([placeJson['latitude'], placeJson['longitude']], { - icon: L.mapbox.marker.icon({ - 'marker-size': 'large', - 'marker-symbol': 'building', - 'marker-color': '#fa0' - }) - }).addTo(map); - var newName = 'Name: ' + placeJson['name']; - newPlaceMarker.bindPopup(newName, { - closeButton: true - }); - newPlaceMarker.on('click', function () { - map.panTo([placeJson['latitude'], placeJson['longitude']]); - selectPlace(slug); - }); - //make selected - selectPlace(slug); - }).catch(function (placeError) { - alertify.reset(); - alertify.error(placeError); - }); - }); - }); - form.insertBefore(newLocButton, div); -} - -function parseLocation(point) { - var re = /\((.*)\)/; - var resultArray = re.exec(point); - var location = resultArray[1].split(' '); - - return [location[1], location[0]]; -} - -function selectPlace(slug) { - document.querySelector('select [value=' + slug + ']').selected = true; -} - -function getLatitudeFromMapboxMarker(latlng) { - var resultArray = /\((.*)\)/.exec(latlng); - var location = resultArray[1].split(' '); - - return location[0].replace(',', ''); -} - -function getLongitudeFromMapboxMarker(latlng) { - var resultArray = /\((.*)\)/.exec(latlng); - var location = resultArray[1].split(' '); - - return location[1]; -} +function getLocation(){navigator.geolocation.getCurrentPosition(function(e){addPlacesMap(e.coords.latitude,e.coords.longitude)})}function addPlacesMap(e,t){fetch("/places/near/"+e+"/"+t,{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