<!doctype html>

<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Go Report Card | Go project code quality report cards</title>
    <link rel="stylesheet" href="/assets/bulma.0.0.23.min.css">
    <link rel="stylesheet" href="/assets/goreportcard.css">
    <link rel="stylesheet" href="/assets/easy-autocomplete.css">
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', '[[ .google_analytics_key ]]', 'auto');
      ga('send', 'pageview');

    </script>
</head>
<body>
  <div id="notifications">
  </div>
  <header class="header">
  <div class="container">
        <!-- Left side -->
        <div class="header-left">
          <a class="header-item" href="/">
            <h3 class="title">Go Report Card</h3>
          </a>
        </div>

        <!-- Hamburger menu (on mobile) -->
        <span class="header-toggle">
          <span></span>
          <span></span>
          <span></span>
        </span>

        <!-- Right side -->
        <div class="header-right header-menu">
          <span class="header-item">
            <a href="/high_scores">High Scores</a>
          </span>
          <span class="header-item">
            <a href="https://github.com/gojp/goreportcard">GitHub</a>
          </span>
          <span class="header-item">
            <a href="/about">About</a>
          </span>
        </div>
      </div>
  </header>
  <section class="hero is-primary is-medium has-text-centered gopher">
    <div class="hero-content">
      <div class="container">
        <h2 class="subtitle">
          Enter the <strong>go get</strong> path to the project below:
        </h2>
        <form method="POST" action="/checks" id="check_form">
          <div>
            <p class="url">
              <input name="repo" type="text" class="input-box" placeholder="github.com/gojp/goreportcard"/>
            </p>
          </div>
          <div>
            <button type="submit" class="button btn-test is-large" href="#" role="button">Generate Report</button>
          </div>
        </form>
      </div>
    </div>
  </section>
  <section class="section container-suggestions">
      <div class="container">
          <div class="columns">
              <div class="column is-half">
                  <table class="table">
                    <thead>
                      <tr>
                        <th>Popular Report Cards</th>
                      </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td class="table-link"><a href="/report/github.com/golang/crypto">github.com/golang/crypto</a></td>
                        </tr>
                        <tr>
                            <td class="table-link"><a href="/report/github.com/cockroachdb/cockroach">github.com/cockroachdb/cockroach</a></td>
                        </tr>
                        <tr>
                            <td class="table-link"><a href="/report/github.com/gojp/goreportcard">github.com/gojp/goreportcard</a></td>
                        </tr>
                        <tr>
                            <td class="table-link"><a href="/report/github.com/boltdb/bolt">github.com/boltdb/bolt</a></td>
                        </tr>
                        <tr>
                            <td class="table-link"><a href="/report/github.com/docker/docker">github.com/docker/docker</a></td>
                        </tr>
                    </tbody>
                  </table>
              </div>
              <div class="column is-half">
                  <table class="table">
                    <thead>
                      <tr>
                        <th>Recently Generated</th>
                      </tr>
                    </thead>
                    <tbody>
                        [[ range .Recent ]]
                        <tr>
                            <td class="table-link"><a href="/report/[[ . ]]">[[ . ]]</td>
                        </tr>
                        [[ end ]]
                    </tbody>
                  </table>
              </div>
          </div>
      </div>
  </section>

  <section class="section container-results hidden">
    <div class="container">
        <div class="columns results-text">
        </div>
        <div class="columns">
          <div class="column is-quarter">
            <nav class="menu results">
            </nav>
            <div class="container-update">
            </div>
          </div>
          <div class="column">
              <div class="results-details">
              </div>
          </div>
        </div>
    </div>
  </section>

  <footer class="footer">
    <div class="container">
      <div class="content has-text-centered">
        <p>
            <strong>Go Report Card</strong> by
              <a href="https://twitter.com/shawnps">Shawn Smith</a> and
              <a href="https://twitter.com/ironzeb">Herman Schaaf</a>.
        </p>
        <p>
            <a href="https://www.digitalocean.com/" class="dolink">
                <img width="15%" src="/assets/do-proudly-hosted.png">
            </a>
        </p>
      </div>
    </div>
  </footer>

  <script type="text/javascript" src="/assets/jquery.min.js"></script>
  <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.js"></script>
  <script type="text/javascript" src="/assets/jquery.easy-autocomplete.js"></script>
  <script id="template-alert" type="text/x-handlebars-template">
      <div class="notification is-warning">
          <button class="delete"></button>
          {{{message}}}
      </div>
    </div>
  </script>
  <script type="text/javascript">
    var loading = false;
    // initialize handlebars templates
    var templates = {};
    $("script[id^=template]").each(function(){
      var name = $(this).attr("id").substring(9);
      var source   = $(this).html();
      templates[name] = Handlebars.compile(source);
    });
    function alertMessage(msg){
      var html = templates.alert({message: msg});
      var $alert = $(html);
      $alert.find(".delete").on("click", function(){
          $(this).closest(".notification").remove();
      })
      $alert.hide();
      $alert.appendTo("#notifications");
      $alert.slideDown();
    }
    var loadData = function(getRequest){
      loading = true;
      var $form = $(this),
          url = $form.attr("action"),
          method = $form.attr("method"),
          data = {};
      $("#check_form .button").addClass("is-loading");
      $form.serializeArray().map(function(x){data[x.name] = x.value;});
      $.ajax({
          type: getRequest ? "GET" : "POST",
          url: url,
          data: data,
          dataType: "json"
      }).fail(function(xhr, status, err){
          alertMessage("There was an error processing your request: " + xhr.responseText);
      }).done(function(data, textStatus, jqXHR){
        if (data.redirect) {
            window.location.href = data.redirect;
        }
      }).always(function(){
          loading = false;
          $("a.refresh-button").removeClass("is-loading");
          $("#check_form .button").removeClass("is-loading");
      });
      return false;
    };
    // on ready
    $(function(){
      // handle form submission
      $("form#check_form").submit(loadData);

      var options = {

        url: function(phrase) {
          return "/suggest/";
        },

        getValue: function(element) {
          return element.name;
        },

        ajaxSettings: {
          dataType: "json",
          method: "GET",
          data: {
            dataType: "json"
          }
        },

        preparePostData: function(data) {
          data.q = $("input[name=repo]").eq(0).val();
          return data;
        },

        requestDelay: 400
      };

      $("input[name=repo]").easyAutocomplete(options);

    });
  </script>
</body>
</html>
