text: // Generated by CoffeeScript 1.10.0
  (function() {
    var REPO_INPUT, _repoInList, addRepoToLog, analyze, checkForPermalink, enterWasHit, refreshRateInfo, setNewUrl, setupEvents, showError, showRepo, signIn, signOut, startAnalysis;
  
    REPO_INPUT = "#github-repo";
  
    $(function() {
      setupEvents();
      refreshRateInfo();
      return checkForPermalink();
    });
  
    setupEvents = function() {
      $(REPO_INPUT).keyup(function(e) {
        if (enterWasHit(e)) {
          return startAnalysis();
        }
      });
      $("#github-password").keyup(function(e) {
        if (enterWasHit(e)) {
          return signIn();
        }
      });
      $("button#analyze").click(startAnalysis);
      $("button#sign-in").click(signIn);
      $("button#sign-out").click(signOut);
      $("#github-repo").keyup(function(e) {
        return $("button#analyze").prop("disabled", e.target.value === "");
      });
      return $("#github-username").keyup(function(e) {
        return $("button#sign-in").prop("disabled", e.target.value === "");
      });
    };
  
    refreshRateInfo = function() {
      return App.Github.rateLimit(function(rateData) {
        return App.UI.showRateInfo(rateData);
      });
    };
  
    checkForPermalink = function() {
      var repoSpec;
      if (window.location.hash) {
        repoSpec = decodeURIComponent(window.location.hash.slice(1));
        $(REPO_INPUT).val(repoSpec);
        return startAnalysis();
      }
    };
  
    signIn = function() {
      var password, username;
      username = $("#github-username").val();
      password = $("#github-password").val();
      if (username && password) {
        App.octo = new Octokat({
          username: username,
          password: password
        });
        App.UI.signedInMode();
        return refreshRateInfo();
      }
    };
  
    signOut = function() {
      App.octo = new Octokat();
      App.UI.anonymousMode();
      return refreshRateInfo();
    };
  
    startAnalysis = function() {
      var userInput;
      userInput = $(REPO_INPUT).val();
      setNewUrl(userInput);
      App.UI.hideResults();
      App.UI.hideResultsDisplay();
      App.UI.progress(5);
      return App.repo = new App.Repo(userInput, showRepo, analyze, showError);
    };
  
    setNewUrl = function(userInput) {
      var error, error1, slug;
      try {
        slug = '#' + encodeURIComponent(userInput);
        return history.pushState(null, null, slug);
      } catch (error1) {
        error = error1;
        return console.log(error);
      }
    };
  
    showRepo = function(repo) {
      App.UI.hideError();
      refreshRateInfo();
      App.UI.showProgressBar();
      $("#results").show();
      return $("#results h2").text(repo.name);
    };
  
    analyze = function(repo) {
      var icon_class;
      App.UI.hideError();
      refreshRateInfo();
      icon_class = "icon fa " + App.Metrics.repoEffectivenessIcon(repo);
      $("#effectiveness-icon").attr("class", icon_class);
      $("#effectiveness-desc").text(App.Metrics.repoEffectivenessDesc(repo));
      $(".effectiveness").text(sprintf('%.1f', repo.effectiveness()));
      $(".pr-effectiveness").text(sprintf('%.1f', repo.prEffectiveness()));
      $(".issue-effectiveness").text(sprintf('%.1f', repo.issueEffectiveness()));
      $('.open-prs').text(repo.openPullRequestCount());
      $('.closed-prs').text(repo.closedPullRequestCount());
      $('.open-issues').text(repo.openIssueCount());
      $('.closed-issues').text(repo.closedIssueCount());
      addRepoToLog(repo);
      window.setTimeout(App.UI.hideProgressBar, 500);
      window.setTimeout(App.UI.showResultsDisplay, 500);
      return window.setTimeout(App.UI.drawChart, 500);
    };
  
    addRepoToLog = function(repo) {
      if (!_repoInList(repo, App.log)) {
        App.log.push(repo);
        return App.UI.refreshLog(App.log);
      }
    };
  
    showError = function(message) {
      App.UI.hideProgressBar();
      App.UI.showError(message);
      return refreshRateInfo();
    };
  
    enterWasHit = function(event) {
      return event.keyCode === 13;
    };
  
    _repoInList = function(repo, repos) {
      return _.some(repos, function(r) {
        return r.equals(repo);
      });
    };
  
  }).call(this);
  