jQuery select SN.C.S.NoticeLocationName once.

This commit is contained in:
Sarven Capadisli 2009-12-31 17:02:02 +00:00
parent 8872d91483
commit e84bf0aa98
1 changed files with 9 additions and 8 deletions

View File

@ -442,10 +442,11 @@ var SN = { // StatusNet
if (navigator.geolocation) { if (navigator.geolocation) {
$('#notice_data-location_enabled').change(function() { $('#notice_data-location_enabled').change(function() {
$.cookie(SN.C.S.NoticeLocationCookieName, $('#notice_data-location_enabled').attr('checked')); $.cookie(SN.C.S.NoticeLocationCookieName, $('#notice_data-location_enabled').attr('checked'));
NLN = $('#'+SN.C.S.NoticeLocationName);
if ($('#notice_data-location_enabled').attr('checked') === true) { if ($('#notice_data-location_enabled').attr('checked') === true) {
$('#'+SN.C.S.NoticeLocationName).show(); NLN.show();
$('#'+SN.C.S.NoticeLocationName).addClass('processing'); NLN.addClass('processing');
navigator.geolocation.getCurrentPosition(function(position) { navigator.geolocation.getCurrentPosition(function(position) {
$('#'+SN.C.S.NoticeLat).val(position.coords.latitude); $('#'+SN.C.S.NoticeLat).val(position.coords.latitude);
@ -457,8 +458,8 @@ var SN = { // StatusNet
'token': $('#token').val() 'token': $('#token').val()
}; };
$.getJSON($('#notice_data-location_enabled_container').attr('data-geocode-url'), data,function(location) { $.getJSON($('#notice_data-location_enabled_container').attr('data-geocode-url'), data, function(location) {
$('#'+SN.C.S.NoticeLocationName).removeClass('processing'); NLN.removeClass('processing');
if (typeof(location.location_ns) != 'undefined') { if (typeof(location.location_ns) != 'undefined') {
$('#'+SN.C.S.NoticeLocationNs).val(location.location_ns); $('#'+SN.C.S.NoticeLocationNs).val(location.location_ns);
@ -469,17 +470,17 @@ var SN = { // StatusNet
} }
if (typeof(location.name) == 'undefined') { if (typeof(location.name) == 'undefined') {
$('#'+SN.C.S.NoticeLocationName).text(position.coords.latitude + ';' + position.coords.longitude); NLN.text(position.coords.latitude + ';' + position.coords.longitude);
} }
else { else {
$('#'+SN.C.S.NoticeLocationName).text(location.name); NLN.text(location.name);
$('#'+SN.C.S.NoticeLocationName).attr('href',location.url); NLN.attr('href',location.url);
} }
}); });
}); });
} }
else { else {
$('#'+SN.C.S.NoticeLocationName).hide(); NLN.hide();
$('#'+SN.C.S.NoticeLat).val(''); $('#'+SN.C.S.NoticeLat).val('');
$('#'+SN.C.S.NoticeLon).val(''); $('#'+SN.C.S.NoticeLon).val('');
$('#'+SN.C.S.NoticeLocationNs).val(''); $('#'+SN.C.S.NoticeLocationNs).val('');