Permalink
Browse files

minor refactor to make it easier to provide a callback for handling f…

…etched geography data
  • Loading branch information...
1 parent c0fb91f commit c1875cfd44cbc24b5031381471eedce49bf77c46 @JoeGermuska JoeGermuska committed Aug 20, 2011
Showing with 6 additions and 3 deletions.
  1. +5 −0 censusweb/media/js/common.js
  2. +1 −3 censusweb/media/js/data.js
View
5 censusweb/media/js/common.js
@@ -56,6 +56,11 @@ function do_with_available_states(handler) {
function do_with_labels(handler) {
apiRequest("/" + window.DATASET + "_labels.jsonp", "labels_" + window.DATASET, handler);
}
+
+function do_with_sf1_data(geoid, callback) {
+ var state = geoid.substring(0, 2);
+ apiRequest("/" + state + "/" + geoid + ".jsonp", "geoid_" + geoid, callback);
+}
STATES = {
"Alabama": "01",
"Alaska": "02",
View
4 censusweb/media/js/data.js
@@ -92,9 +92,7 @@ $(function(){
geographies = new Array();
_.each(geoids, function(geoid) {
- var state = geoid.substring(0, 2);
-
- apiRequest("/" + state + "/" + geoid + ".jsonp", "geoid_" + geoid, function(geography_data) {
+ do_with_sf1_data(geoid,function(geography_data) {
geographies.push(geography_data);
// If all geographies have been loaded, make reports

0 comments on commit c1875cf

Please sign in to comment.