summaryrefslogtreecommitdiff
path: root/js/util.js
diff options
context:
space:
mode:
authorSarven Capadisli <csarven@status.net>2009-12-31 16:34:07 +0000
committerSarven Capadisli <csarven@status.net>2009-12-31 16:34:07 +0000
commitccf78976a51aff886f4ab5f3dfe5a9a76cebba76 (patch)
tree8a2a3f549a4e474bf92b39a38013cb363a325b57 /js/util.js
parent58465d74bac0413b530f8a266c767da2c2f82648 (diff)
NoticeLocationAttach() slightly more readable
Diffstat (limited to 'js/util.js')
-rw-r--r--js/util.js34
1 files changed, 25 insertions, 9 deletions
diff --git a/js/util.js b/js/util.js
index a02a30a12..8716a3360 100644
--- a/js/util.js
+++ b/js/util.js
@@ -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();