{"size": 1374, "ext": "js", "max_stars_repo_path": "src/interface.js", "max_stars_repo_name": "twigz826/Thermostat", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/interface.js", "max_issues_repo_name": "twigz826/Thermostat", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/interface.js", "max_forks_repo_name": "twigz826/Thermostat", "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": 23.6896551724, "max_line_length": 73, "alphanum_fraction": 0.6266375546}
$(document).ready(function() {
  let thermostat = new Thermostat();
  updateTemperature();
  updateSaveStatus();

  $('#temperature-up').on('click',function(){
    thermostat.increaseTemp();
    updateTemperature();
  })

  $('#temperature-down').on('click',function(){
    thermostat.decreaseTemp();
    updateTemperature();
  })

  $('#temperature-reset').on('click',function(){
    thermostat.reset();
    updateTemperature();
  })

  $('#powersaving-on').on('click',function(){
    thermostat.saveModeOn();
    updateTemperature();
    updateSaveStatus();
  })

  $('#powersaving-off').on('click',function(){
    thermostat.saveModeOff();
    updateTemperature();
    updateSaveStatus();
  })

  $('#select-city').submit(function(event){
    event.preventDefault();
    let city = $('#current-city').val();
    displayWeather(city);
  })

  function displayWeather(city) {
    let url = 'http://api.openweathermap.org/data/2.5/weather?q=' + city;
    let token = '&appid=' + API_KEY;
    let units = '&units=metric';
    $.get(url + token + units, function(data){
      $('#current-temperature').text(data.main.temp);
    })
  }

  function updateTemperature() {
    $('#temperature').text(thermostat._temp);
    $('#temperature').attr('class',thermostat.usage());
  }

  function updateSaveStatus() {
    $('#power-saving-status').text(thermostat._saveStatus);
  }

})
