Skip to content

Commit

Permalink
Submit current time and coordinates
Browse files Browse the repository at this point in the history
  • Loading branch information
pbb72 committed Apr 21, 2016
1 parent bc3aba2 commit 6868c5a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions www/code/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ document.querySelector("form").addEventListener("submit", function(e) {
var data = new FormData();
data.append("observation[picture]", file);
data.append('observation[taxon_id]', query.id);
data.append('observation[observed_at]', '2009-10-26T04:47:09Z');
data.append('observation[latitude]', 0);
data.append('observation[longitude]', 0);
data.append('observation[observed_at]', this.elements["date"].value);
data.append('observation[latitude]', this.elements["coords"].value.split(";")[0]);
data.append('observation[longitude]', this.elements["coords"].value.split(";")[1]);

var xhr = new XMLHttpRequest();
xhr.open("POST", "https://api.biocaching.com/observations", true);
Expand Down Expand Up @@ -50,5 +50,9 @@ document.querySelector('#photo-file').addEventListener('change', function(e) {
(function() {

getData("https://api.biocaching.com/taxa/" + query.id, buildPage)
document.querySelector("#date").value = (new Date()).toISOString();
navigator.geolocation.getCurrentPosition(function(loc) {
document.querySelector("#coords").value = loc.coords.latitude + ";" + loc.coords.longitude;
});

})();
4 changes: 2 additions & 2 deletions www/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ <h1>Register observation</h1>
</main></section>
<form class="info" action="observation.html">
<input type="file" id="photo-file" name="photo-file" accept="image/*" />
<input class="text-field" value="25th august 2015, 11:39" />
<input class="text-field" value="61º 31' 7.5136&quot; N 8º 05' 1.2314&quot; E" />
<input id="date" class="text-field" value="" />
<input id="coords" class="text-field" value="" />
<input type="submit" class="button text-button" value="OK" />
</form>
</main>
Expand Down

0 comments on commit 6868c5a

Please sign in to comment.