From 795419e819e80c852f4cf4610b057ee8fbde67d3 Mon Sep 17 00:00:00 2001 From: Mike Koch Date: Tue, 19 May 2015 22:05:50 -0400 Subject: [PATCH] #204 Add javascript for obtaining location --- js/modsForHesk-javascript.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/js/modsForHesk-javascript.js b/js/modsForHesk-javascript.js index a8bc674d..70286685 100644 --- a/js/modsForHesk-javascript.js +++ b/js/modsForHesk-javascript.js @@ -106,4 +106,34 @@ function changeText(id, checkedValue, uncheckedValue, object) { } } +function requestUserLocation() { + if (navigator.geolocation) { + navigator.geolocation.getCurrentPosition(function(position) { + setLatLon(position.coords.latitude, position.coords.longitude); + }, function(error) { + switch(error.code) { + case error.PERMISSION_DENIED: + setLatLon('E-1','E-1'); + break; + case error.POSITION_UNAVAILABLE: + setLatLon('E-2','E-2'); + break; + case error.TIMEOUT: + setLatLon('E-3','E-3'); + break; + case error.UNKNOWN_ERROR: + setLatLon('E-4','E-4'); + break; + } + }); + } else { + setLatLon('E-5','E-5'); + } +} + +function setLatLon(lat, lon) { + $('#latitude').val(lat); + $('#longitude').val(lon); +} + jQuery(document).ready(loadJquery);