Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 2752f4f

Browse files
committed
refactoring and making the events.js code more readable
Getting read of some unused variables, making variable names more readable.
1 parent a3f5d14 commit 2752f4f

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

static/js/events.js

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ var Codeweek = window.Codeweek || {};
7171
selectItemByValue(choice, country);
7272
}
7373

74-
75-
function updateAddress(new_position) {
74+
function updateAddress(new_latLng) {
7675
geocoder = new google.maps.Geocoder();
77-
geocoder.geocode({'latLng': new_position}, function (results, status) {
76+
geocoder.geocode({'latLng': new_latLng}, function (results, status) {
7877
if (status === google.maps.GeocoderStatus.OK) {
7978
document.getElementById("autocomplete").value = results[0].formatted_address;
8079
// the last item in the geocoder for latLng results array is the country
@@ -127,19 +126,11 @@ var Codeweek = window.Codeweek || {};
127126
}
128127

129128
function fillInAddress() {
130-
var place = autocomplete.getPlace(),
131-
components = place.address_components,
132-
output = autocomplete.getPlace().geometry.location,
133-
outputLat = output.lat(),
134-
outputLng = output.lng(),
135-
locLatlng = new google.maps.LatLng(outputLat, outputLng);
136-
137-
document.getElementById("id_geoposition_0").value = outputLat;
138-
document.getElementById("id_geoposition_1").value = outputLng;
139-
140-
createMarker(locLatlng);
141-
updateCountrySelection(output);
142-
129+
// geoLatLng contains the Google Maps geocoded latitude, longitude
130+
var geoLatLng = autocomplete.getPlace().geometry.location;
131+
132+
createMarker(geoLatLng);
133+
updateAddress(geoLatLng);
143134
}
144135

145136
function auto_complete() {

0 commit comments

Comments
 (0)