]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
NoticeLocationAttach() slightly more readable
authorSarven Capadisli <csarven@status.net>
Thu, 31 Dec 2009 16:34:07 +0000 (16:34 +0000)
committerSarven Capadisli <csarven@status.net>
Thu, 31 Dec 2009 16:34:07 +0000 (16:34 +0000)
js/util.js

index a02a30a1254458771329e4e866bd94dfd2fa9f57..8716a336095b98eb9d64d1479a119f834fe707f8 100644 (file)
@@ -446,17 +446,32 @@ var SN = { // StatusNet
                         if ($('#notice_data-location_enabled').attr('checked') === true) {
                             $('#'+SN.C.S.NoticeLocationName).show();
                             $('#'+SN.C.S.NoticeLocationName).addClass('processing');
+
                             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()};
+
+                                var data = {
+                                    'lat': position.coords.latitude,
+                                    'lon': position.coords.longitude,
+                                    'token': $('#token').val()
+                                };
+
                                 $.getJSON($('#notice_data-location_enabled_container').attr('data-geocode-url'), data,function(location) {
                                     $('#'+SN.C.S.NoticeLocationName).removeClass('processing');
-                                    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.name)=="undefined") {
+
+                                    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.name) == 'undefined') {
                                         $('#'+SN.C.S.NoticeLocationName).text(position.coords.latitude + ' ' + position.coords.longitude);
-                                    } else {
+                                    }
+                                    else {
                                         $('#'+SN.C.S.NoticeLocationName).text(location.name);
                                         $('#'+SN.C.S.NoticeLocationName).attr('href',location.url);
                                     }
@@ -465,12 +480,13 @@ var SN = { // StatusNet
                         }
                         else {
                             $('#'+SN.C.S.NoticeLocationName).hide();
-                            $('#'+SN.C.S.NoticeLat).val("");
-                            $('#'+SN.C.S.NoticeLon).val("");
-                            $('#'+SN.C.S.NoticeLocationNs).val("");
-                            $('#'+SN.C.S.NoticeLocationId).val("");
+                            $('#'+SN.C.S.NoticeLat).val('');
+                            $('#'+SN.C.S.NoticeLon).val('');
+                            $('#'+SN.C.S.NoticeLocationNs).val('');
+                            $('#'+SN.C.S.NoticeLocationId).val('');
                         }
                     });
+
                     var cookieVal = $.cookie(SN.C.S.NoticeLocationCookieName);
                     $('#notice_data-location_enabled').attr('checked',(cookieVal == null || cookieVal == 'true'));
                     $('#notice_data-location_enabled').change();