{"size": 1400, "ext": "js", "max_stars_repo_path": "public/assets/js/burgers.js", "max_stars_repo_name": "ncmarsh/burger", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "public/assets/js/burgers.js", "max_issues_repo_name": "ncmarsh/burger", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "public/assets/js/burgers.js", "max_forks_repo_name": "ncmarsh/burger", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.9259259259, "max_line_length": 67, "alphanum_fraction": 0.5407142857}
// Will attach handlers when DOM is fully loaded
$(function() {
  // When the DEVOUR! button is clicked
  $(".devour_btn").on("click", function(event) {
    const id = $(this).data("id");
    const burger_name = $(this).data("burger_name");
    const nowDevoured = $(this).data("devoured");

    const nowDevouredState = {
      devoured: nowDevoured
    };

    // send the PUT request.
    $.ajax("/api/burgers/" + id, {
      type: "PUT",
      data: nowDevouredState
    }).then(
      function() {
        console.log("You have eaten a " + burger_name + " burger");
        // reload the page to get up to date lists
        location.reload();
      }
    );
  });

  // When the button is clicked to make a new burger
  $(".burger-form").on("submit", function(event) {
    if ($("#burger").val() === "") {
      console.log("No burger entered");
    } else {
      // preventDefault on a form submit event
      event.preventDefault();

      const notEaten = parseInt(0);
      const newBurger = {
        burger_name: $("#burger").val().trim(),
        devoured: notEaten
      };

      // send the POST request.
      $.ajax("/api/burgers", {
        type: "POST",
        data: newBurger
      }).then(
        function() {
          console.log("New burger grilled!");
          // reload the page to get up to date lists
          location.reload();
        }
      );
    }
  });
});
  