]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Added errorCallback() to geoCurrentPosition() i.e., if user doesn't
authorSarven Capadisli <csarven@status.net>
Mon, 4 Jan 2010 09:52:35 +0000 (09:52 +0000)
committerSarven Capadisli <csarven@status.net>
Mon, 4 Jan 2010 09:52:35 +0000 (09:52 +0000)
grant permission, removes the Geo processing and (if any) existing geo
location data from notice form.

js/util.js

index f7c54e469f65a5c5c782685c2b72cb9345ce13a3..c1cc08a7145ec24e395d7139d8ecde756afbb5d0 100644 (file)
@@ -493,44 +493,57 @@ var SN = { // StatusNet
                                 return false;
                             });
 
-                            navigator.geolocation.getCurrentPosition(function(position) {
-                                $('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
-                                $('#'+SN.C.S.NoticeLon).val(position.coords.longitude);
-
-                                var data = {
-                                    'lat': position.coords.latitude,
-                                    'lon': position.coords.longitude,
-                                    'token': $('#token').val()
-                                };
-
-                                $.getJSON(geocodeURL, data, function(location) {
-                                    NLN.replaceWith('<a id="notice_data-location_name"/>');
-                                    NLN = $('#'+SN.C.S.NoticeLocationName);
-
-                                    if (typeof(location.location_ns) != 'undefined') {
-                                        $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns);
-                                    }
+                            navigator.geolocation.getCurrentPosition(
+                                function(position) {
+                                    $('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
+                                    $('#'+SN.C.S.NoticeLon).val(position.coords.longitude);
+
+                                    var data = {
+                                        'lat': position.coords.latitude,
+                                        'lon': position.coords.longitude,
+                                        'token': $('#token').val()
+                                    };
+
+                                    $.getJSON(geocodeURL, data, function(location) {
+                                        NLN.replaceWith('<a id="notice_data-location_name"/>');
+                                        NLN = $('#'+SN.C.S.NoticeLocationName);
+
+                                        if (typeof(location.location_ns) != 'undefined') {
+                                            $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns);
+                                        }
 
-                                    if (typeof(location.location_id) != 'undefined') {
-                                        $('#'+SN.C.S.NoticeLocationId).val(location.location_id);
-                                    }
+                                        if (typeof(location.location_id) != 'undefined') {
+                                            $('#'+SN.C.S.NoticeLocationId).val(location.location_id);
+                                        }
 
-                                    if (typeof(location.name) == 'undefined') {
-                                        NLN_text = position.coords.latitude + ';' + position.coords.longitude;
-                                    }
-                                    else {
-                                        NLN_text = location.name;
-                                    }
+                                        if (typeof(location.name) == 'undefined') {
+                                            NLN_text = position.coords.latitude + ';' + position.coords.longitude;
+                                        }
+                                        else {
+                                            NLN_text = location.name;
+                                        }
 
-                                    NLN.attr('href', location.url);
-                                    NLN.text(NLN_text);
-                                    NLN.click(function() {
-                                        window.open(location.url);
+                                        NLN.attr('href', location.url);
+                                        NLN.text(NLN_text);
+                                        NLN.click(function() {
+                                            window.open(location.url);
 
-                                        return false;
+                                            return false;
+                                        });
                                     });
-                                });
-                            });
+                                },
+
+                                function(error) {
+                                    if (error.PERMISSION_DENIED == 1) {
+                                        $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked');
+                                        NDGS.hide();
+                                        $('#'+SN.C.S.NoticeLat).val('');
+                                        $('#'+SN.C.S.NoticeLon).val('');
+                                        $('#'+SN.C.S.NoticeLocationNs).val('');
+                                        $('#'+SN.C.S.NoticeLocationId).val('');
+                                    }
+                                }
+                            );
                         }
                         else {
                             $('label[for='+SN.C.S.NoticeDataGeo+']').removeClass('checked');