Skip to content

Commit

Permalink
Merge pull request #61 from a-musing-moose/correct_dashboard_for_jque…
Browse files Browse the repository at this point in the history
…ry_1.9

Wrap parseJSON in a try catch
  • Loading branch information
Jonathan Moss committed Apr 16, 2013
2 parents 4478405 + 6b0a742 commit 51c20f0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions stores/static/stores/js/dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ stores.dashboard = {
defaultLat: 144.9661415816081,

getLatLngFromGeoJSON: function (data) {
var point = jQuery.parseJSON(data);
var point = null;
try {
point = jQuery.parseJSON(data);
} catch (e) {}

if (!point || point.type.toLowerCase() !== "point") {
return new google.maps.LatLng(
stores.dashboard.defaultLng,
stores.dashboard.defaultLat
);
);
}

// the GeoJSON format provides latitude and longitude
Expand All @@ -20,7 +23,7 @@ stores.dashboard = {
return new google.maps.LatLng(
point.coordinates[1],
point.coordinates[0]
);
);
},

getGeoJsonFromLatLng: function (data) {
Expand All @@ -35,7 +38,7 @@ stores.dashboard = {

init: function () {
var locationJSON = jQuery('#id_location').val(),
latLng;
latLng;

if (locationJSON) {
latLng = stores.dashboard.getLatLngFromGeoJSON(locationJSON);
Expand All @@ -44,9 +47,9 @@ stores.dashboard = {
}

var input = jQuery('#search-text-field'),
autocomplete = new google.maps.places.Autocomplete(input[0]),
zoom = 17,
marker = null;
autocomplete = new google.maps.places.Autocomplete(input[0]),
zoom = 17,
marker = null;

stores.dashboard.map = new google.maps.Map(document.getElementById('store-map'), {
zoom: zoom,
Expand Down Expand Up @@ -119,7 +122,7 @@ stores.dashboard = {
input.trigger('change');
}
}
);
);
},

updateMarkerPlace: function(marker, place) {
Expand Down Expand Up @@ -158,7 +161,7 @@ stores.dashboard = {
stores.dashboard.updateMarkerPlace(marker, results[0]);
}
}
);
);
}
};

Expand Down

0 comments on commit 51c20f0

Please sign in to comment.