Untitled

mail@pastecode.io avatar
unknown
plain_text
21 days ago
51 kB
0
Indexable
Never
function getStateData() {
  var states = getColumn("US States", "State Name");
  var codes = getColumn("US States", "Code Name");
  var nicknames = getColumn("US States", "Nickname");
  var capitals = getColumn("US States", "Capital");
  var populations = getColumn("US States", "Population");
  var population_ranks = getColumn("US States", "Population Rank");
  var state_flags = getColumn("US States", "State Flag");
  var state_maps = getColumn("US States", "Map");
  var areas = getColumn("US States", "Area");
  var incomes = getColumn("US States", "Median Household Income");
  var poverties = getColumn("US States", "Percent in Poverty");
  var grads = getColumn("US States", "Percent of Adult College Graduates");
  var all_states = {};
  for (var i = 0; i < states.length; i++) {
      all_states[states[i]] = {
        name: states[i],
        code: codes[i],
        nickname: nicknames[i],
        capital: capitals[i],
        population: populations[i],
        pop_rank: population_ranks[i],
        flag: state_flags[i],
        map: state_maps[i],
        area: areas[i],
        income: incomes[i],
        poverty: poverties[i],
        grad: grads[i]
      };
  }
  return all_states;
}

function sort(list, property) {
  // given a list, return sorted list
  var i, j, temp;
  var swapped;
  for (i = 0; i < list.length - 1; i++) {
    swapped = false;
    for (j = 0; j < list.length - i - 1; j++) {
        if (list[j][property] > list[j + 1][property]) {
            temp = list[j];
            list[j] = list[j + 1];
            list[j + 1] = temp;
            swapped = true;
        }
    }

    if (swapped == false) {
      break;
    }
  }
}

function average(list) {
  var sum = 0;
  for (var i = 0; i < list.length; i++) {
    sum += list[i];
  }
  return sum / list.length;
}

function getAveragePopulation() {
  var list = getColumn("US States", "Population");
  var avg = average(list);
  console.log(avg);
  setScreen("avg_screen");
  setText("avg_label", "Average State Population");
  var text = "Average State Population: " + avg;
  setText("property_label", text);
}

function getAverageArea() {
  var list = getColumn("US States", "Area");
  var avg = average(list);
  console.log(avg);
  setScreen("avg_screen");
  setText("avg_label", "Average State Area (sq. ft.)");
  var text = "Average State Area: " + avg;
  setText("property_label", text);
}

function getAverageIncome() {
  var list = getColumn("US States", "Median Household Income");
  var avg = average(list);
  console.log(avg);
  setScreen("avg_screen");
  setText("avg_label", "Average State Household Income");
  var text = "Average State Household Income: $" + avg;
  setText("property_label", text);
}

function getAveragePoverty() {
  var list = getColumn("US States", "Percent in Poverty");
  var avg = average(list);
  console.log(avg);
  setScreen("avg_screen");
  setText("avg_label", "Average State Percentage in Poverty");
  var text = "Average Percentage: " + avg + "%";
  setText("property_label", text);
}

function getAverageGrads() {
  var list = getColumn("US States", "Percent of Adult College Graduates");
  var avg = average(list);
  console.log(avg);
  setScreen("avg_screen");
  setText("avg_label", "Average State Percentage of Adult College Graduates");
  var text = "Average Percentage: " + avg + "%";
  setText("property_label", text);
}

function getRankedPopulation() {
  var names = getColumn("US States", "State Name");
  var populations = getColumn("US States", "Population");
  var objects = [];
  for (var i = 0; i < names.length; i++) {
    var object = {
      name: names[i],
      population: populations[i]
    };
    appendItem(objects, object);
  }
  sort(objects, 'population');
  console.log(objects);
  setScreen("rank_screen");
  setText("rank_label", "Ranked State Population");
  var formattedText = "";
  for (var j = objects.length-1; j >= 0; j--) {
    formattedText = formattedText + (50-j) + ") " + objects[j].name + ": " + objects[j].population + "\n";
  }
  setText("text_area", formattedText);
}

function getRankedArea() {
  var names = getColumn("US States", "State Name");
  var areas = getColumn("US States", "Area");
  var objects = [];
  for (var i = 0; i < names.length; i++) {
    var object = {
      name: names[i],
      area: areas[i]
    };
    appendItem(objects, object);
  }
  sort(objects, 'area');
  console.log(objects);
  setScreen("rank_screen");
  setText("rank_label", "Ranked State Area (sq. ft.)");
  var formattedText = "";
  for (var j = objects.length - 1; j >= 0; j--) {
    formattedText = formattedText + (50-j) + ") " + objects[j].name + ": " + objects[j].area + " sq. ft. \n";
  }
  setText("text_area", formattedText);
}

function getRankedIncome() {
  var names = getColumn("US States", "State Name");
  var incomes = getColumn("US States", "Median Household Income");
  var objects = [];
  for (var i = 0; i < names.length; i++) {
    var object = {
      name: names[i],
      income: incomes[i]
    };
    appendItem(objects, object);
  }
  sort(objects, 'income');
  console.log(objects);
  setScreen("rank_screen");
  setText("rank_label", "Ranked State Household Income");
  var formattedText = "";
  for (var j = objects.length-1; j >= 0; j--) {
    formattedText = formattedText + (50-j) + ") " + objects[j].name + ": $" + objects[j].income + "\n";
  }
  setText("text_area", formattedText);
}

function getRankedPoverty() {
  var names = getColumn("US States", "State Name");
  var poverties = getColumn("US States", "Percent in Poverty");
  var objects = [];
  for (var i = 0; i < names.length; i++) {
    var object = {
      name: names[i],
      poverty: poverties[i]
    };
    appendItem(objects, object);
  }
  sort(objects, 'poverty');
  console.log(objects);
  setScreen("rank_screen");
  setText("rank_label", "Ranked State Poverty Percentage");
  var formattedText = "";
  for (var j = objects.length-1; j >= 0; j--) {
    formattedText = formattedText + (50-j) + ") " + objects[j].name + ": " + objects[j].poverty + "%\n";
  }
  setText("text_area", formattedText);
}

function getRankedGrads() {
  var names = getColumn("US States", "State Name");
  var grads = getColumn("US States", "Percent of Adult College Graduates");
  var objects = [];
  for (var i = 0; i < names.length; i++) {
    var object = {
      name: names[i],
      grad: grads[i]
    };
    appendItem(objects, object);
  }
  sort(objects, 'grad');
  console.log(objects);
  setScreen("rank_screen");
  setText("rank_label", "Ranked State College Graduate Percentage");
  var formattedText = "";
  for (var j = objects.length-1; j >= 0; j--) {
    formattedText = formattedText + (50-j) + ") " + objects[j].name + ": " + objects[j].grad + "%\n";
  }
  setText("text_area", formattedText);
}

// Navigation
onEvent("startButton", "click", function() {
  setScreen("states_screen");
});

onEvent("get_stats", "click", function() {
  setScreen("stats_screen");
});

onEvent("back_button1", "click", function() {
  setScreen("states_screen");
});

onEvent("back_button2", "click", function() {
  setScreen("stats_screen");
});

onEvent("back_button3", "click", function() {
  setScreen("states_screen");
});

onEvent("back_button4", "click", function() {
  setScreen("stats_screen");
});

onEvent("back_button5", "click", function() {
  setScreen("start_screen");
});

// Stats
onEvent("avg_population", "click", function() {
  getAveragePopulation();
});

onEvent("rank_population", "click", function() {
  getRankedPopulation();
});

onEvent("avg_area", "click", function() {
  getAverageArea();
});

onEvent("rank_area", "click", function() {
  getRankedArea();
});

onEvent("avg_income", "click", function() {
  getAverageIncome();
});

onEvent("rank_income", "click", function() {
  getRankedIncome();
});

onEvent("avg_poverty", "click", function() {
  getAveragePoverty();
});

onEvent("rank_poverty", "click", function() {
  getRankedPoverty();
});

onEvent("avg_college", "click", function() {
  getAverageGrads();
});

onEvent("rank_college", "click", function() {
  getRankedGrads();
});

// Click on State -> go to state page and show data


onEvent("alabama", "click", function() {
  var states = getStateData();
  var state = states["Alabama"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("alaska", "click", function() {
  var states = getStateData();
  var state = states["Alaska"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("arizona", "click", function() {
  var states = getStateData();
  var state = states["Arizona"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("arkansas", "click", function() {
  var states = getStateData();
  var state = states["Arkansas"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("california1", "click", function() {
  var states = getStateData();
  var state = states["California"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("california2", "click", function() {
  var states = getStateData();
  var state = states["California"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("colorado", "click", function() {
  var states = getStateData();
  var state = states["Colorado"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("connecticut", "click", function() {
  var states = getStateData();
  var state = states["Connecticut"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("delaware", "click", function() {
  var states = getStateData();
  var state = states["Delaware"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("florida", "click", function() {
  var states = getStateData();
  var state = states["Florida"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("georgia", "click", function() {
  var states = getStateData();
  var state = states["Georgia"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("hawaii", "click", function() {
  var states = getStateData();
  var state = states["Hawaii"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("idaho", "click", function() {
  var states = getStateData();
  var state = states["Idaho"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("illinois", "click", function() {
  var states = getStateData();
  var state = states["Illinois"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("indiana", "click", function() {
  var states = getStateData();
  var state = states["Indiana"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("iowa", "click", function() {
  var states = getStateData();
  var state = states["Iowa"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("kansas", "click", function() {
  var states = getStateData();
  var state = states["Kansas"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("kentucky", "click", function() {
  var states = getStateData();
  var state = states["Kentucky"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("louisiana", "click", function() {
  var states = getStateData();
  var state = states["Louisiana"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("maine", "click", function() {
 var states = getStateData();
  var state = states["Maine"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("maryland", "click", function() {
  var states = getStateData();
  var state = states["Maryland"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("massachusetts", "click", function() {
  var states = getStateData();
  var state = states["Massachusetts"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("michigan", "click", function() {
  var states = getStateData();
  var state = states["Michigan"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("minnesota", "click", function() {
  var states = getStateData();
  var state = states["Minnesota"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("mississippi", "click", function() {
  var states = getStateData();
  var state = states["Mississippi"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("missouri", "click", function() {
  var states = getStateData();
  var state = states["Missouri"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("montana", "click", function() {
  var states = getStateData();
  var state = states["Montana"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("nebraska", "click", function() {
  var states = getStateData();
  var state = states["Nebraska"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("nevada", "click", function() {
  var states = getStateData();
  var state = states["Nevada"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("new_hampshire", "click", function() {
  var states = getStateData();
  var state = states["New Hampshire"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("new_jersey", "click", function() {
  var states = getStateData();
  var state = states["New Jersey"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("new_mexico", "click", function() {
  var states = getStateData();
  var state = states["New Mexico"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("new_york", "click", function() {
  var states = getStateData();
  var state = states["New York"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("north_carolina", "click", function() {
  var states = getStateData();
  var state = states["North Carolina"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("north_dakota", "click", function() {
  var states = getStateData();
  var state = states["North Dakota"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("ohio", "click", function() {
  var states = getStateData();
  var state = states["Ohio"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("oklahoma", "click", function() {
  var states = getStateData();
  var state = states["Oklahoma"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("oregon", "click", function() {
  var states = getStateData();
  var state = states["Oregon"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("pennsylvania", "click", function() {
  var states = getStateData();
  var state = states["Pennsylvania"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("rhode_island", "click", function() {
  var states = getStateData();
  var state = states["Rhode Island"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("south_carolina", "click", function() {
  var states = getStateData();
  var state = states["South Carolina"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("south_dakota", "click", function() {
  var states = getStateData();
  var state = states["South Dakota"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("tennessee", "click", function() {
  var states = getStateData();
  var state = states["Tennessee"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("texas", "click", function() {
  var states = getStateData();
  var state = states["Texas"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("utah", "click", function() {
  var states = getStateData();
  var state = states["Utah"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("vermont", "click", function() {
  var states = getStateData();
  var state = states["Vermont"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("virginia", "click", function() {
  var states = getStateData();
  var state = states["Virginia"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("washington", "click", function() {
  var states = getStateData();
  var state = states["Washington"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("west_virginia", "click", function() {
  var states = getStateData();
  var state = states["West Virginia"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("wisconsin", "click", function() {
  var states = getStateData();
  var state = states["Wisconsin"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});

onEvent("wyoming", "click", function() {
  var states = getStateData();
  var state = states["Wyoming"];
  console.log(state);
  setScreen("state_screen");
  setImageURL("flag_img", state.flag);
  setImageURL("map_img", state.map);
  setText("name_label", state.name);
  setText("code_label", state.code);
  setText("nickname_label", "Nickname: " + state.nickname);
  setText("capital_label", "Capital City: " + state.capital);
  setText("area_label", "Area: " + state.area + " sq. ft.");
  setText("pop_label", "Population: " + state.population);
  setText("pop_rank_label", "Population Rank: #" + state.pop_rank);
  setText("grad_label", "Percent College Grads: " + state.grad + "%");
  setText("income_label", "Median Household Income: $" + state.income);
  setText("poverty_label", "Percent Poverty: " + state.poverty + "%");
});
Leave a Comment