{"size": 1117, "ext": "js", "max_stars_repo_path": "js/main.js", "max_stars_repo_name": "AbhinandanVellanki/SLS", "max_stars_repo_stars_event_min_datetime": "2019-08-05T13:13:34.000Z", "max_stars_repo_stars_event_max_datetime": "2020-02-18T16:35:26.000Z", "max_issues_repo_path": "js/main.js", "max_issues_repo_name": "AbhinandanVellanki/SLS", "max_issues_repo_issues_event_min_datetime": "2018-03-30T09:54:12.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-12T07:32:20.000Z", "max_forks_repo_path": "js/main.js", "max_forks_repo_name": "AbhinandanVellanki/SLS", "max_forks_repo_forks_event_min_datetime": "2018-03-30T09:50:13.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-31T06:28:35.000Z"}
{"max_stars_count": 2, "max_issues_count": 7, "max_forks_count": 6, "avg_line_length": 30.1891891892, "max_line_length": 107, "alphanum_fraction": 0.6633840645}
addMachines = function(machines, machine_type, selector) {
  $.each(machines, function(key, machine){
    html_element = $('<li>').addClass('list-group-item d-flex justify-content-between align-items-center');
    html_element.text([machine_type, machine.id].join(' '));

    badge_element = $('<span>').addClass('badge badge-pill');
    if (machine.status.is_free) {
        badge_element.addClass('badge-success').text('Free');
        html_element.addClass('text-success');
    } else {
        badge_element.addClass('badge-danger').text('Busy');
    }
    html_element.append(badge_element);

    $(selector).append(html_element);
  });
};
getLaundryStatus = function() {
	endpoint_url = 'https://cstc.azurewebsites.net/laundry/status';
  $.get(endpoint_url, function(response) {
    addMachines(response.dryer, 'Dryer', '#dryer_status');
    addMachines(response.washer, 'Washer', '#washer_status');
  }).done(function(){
          $("#loading-indicator").hide();
  });

};

addLoadingIndicator = function() {
 	$("#loading-indicator").show();
}

$(function() {
	addLoadingIndicator();
	getLaundryStatus();
});
