{"size": 1299, "ext": "js", "max_stars_repo_path": "ui/js/personality.js", "max_stars_repo_name": "watson-developer-cloud/social-customer-care", "max_stars_repo_stars_event_min_datetime": "2016-07-21T22:41:55.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-19T16:07:27.000Z", "max_issues_repo_path": "ui/js/personality.js", "max_issues_repo_name": "watson-developer-cloud/social-customer-care", "max_issues_repo_issues_event_min_datetime": "2016-07-01T14:55:26.000Z", "max_issues_repo_issues_event_max_datetime": "2019-07-15T13:24:07.000Z", "max_forks_repo_path": "ui/js/personality.js", "max_forks_repo_name": "watson-developer-cloud/social-customer-care", "max_forks_repo_forks_event_min_datetime": "2016-07-01T14:49:05.000Z", "max_forks_repo_forks_event_max_datetime": "2019-07-03T12:08:19.000Z"}
{"max_stars_count": 22, "max_issues_count": 20, "max_forks_count": 76, "avg_line_length": 28.2391304348, "max_line_length": 88, "alphanum_fraction": 0.6050808314}
$(document).ready(function() {
  var $loading = $('.profile-loading');
  var $account = $('.personality-insights--group_account');
  var $profile = $('.js-personality-characteristics');
  var $panel  = $('.personality-insights-container');

  var closeProfile = function() {
    $panel.removeClass('show');
    $('.tweet').removeClass('selected');
  };

  // Click on profile close
  $(document).on('click', '.personality-insights-container--cancel-icon', closeProfile);

  $(document).on('click', '.tweets--row', function () {
    if ($(this).find('.tweet').hasClass('selected')) {
      closeProfile();
      return;
    }
    $(this).find('.tweet').addClass('selected');
    showProfile($(this).data());
  });

  var showProfile = function(account) {
    $account.html(_.template(profileTemplate.innerHTML, account));
    $loading.show();

    $.get('/api/profile', { username: account.username })
    .done(function(response) {
      $profile.html(
        _.template(profileTraitTemplate.innerHTML, {
          traits: [response.big5, response.needs, response. values]
        })
      );
      $loading.hide();
    })
    .fail(function(error) {
      $loading.hide();
      console.log(error); // eslint-disable-line
      $profile.html(error);
    });

    $panel.addClass('show');
  };
});
