<ul class="nav nav-tabs">
  <li id="main-search-tab" class="search-tabs active"><a href="#simple">Simple Search</a></li>
  <li id="aggregated-search-tab" class="search-tabs"><a href="#aggregate">Aggregated Search</a></li>
  <li id="advanced-search-tab" class="search-tabs"><a href="#advanced">Advanced Search</a></li>
</ul>

<div class="tab-content" id="search-tab-content">
  <div id="main-search-tab-content" class="search tab-pane active">

  <p>The relay search tool displays data about single relays and bridges in the
Tor network. It provides useful information on how relays are configured along
with graphs about their past.</p>
  <form id="home-search">
    <div class="input-group">
      <input class="search-query form-control" id="query" placeholder="Query" type="text" autocorrect="off" autocapitalize="none">
      <span class="input-group-btn"><button id="do-search" class="btn btn-primary" type="button">Search</button><button class="btn btn-secondary" type="button" id="do-top-relays">Top Relays</button></span>
    </div>
  </form>
</div>

  <div id="aggregated-search-tab-content" class="search tab-pane">

  <p>The aggregated search tool displays aggregated data about relays in the
Tor network. It provides insight into diversity in the network and the
probabilities of using relays in a particular country or AS as a guard, middle
or exit relay. The results are restricted to only currently running relays and
do not include bridge data.</p>
  <form id="home-aggregate-search">
    <div class="input-group">
      <input class="search-query form-control" id="aggregated-query" placeholder="Query" type="text" autocorrect="off" autocapitalize="none">
      <span class="input-group-btn"><button id="do-aggregate" class="btn btn-primary" type="button">Aggregate</button><button class="btn btn-secondary" type="button" id="do-full-aggregation">Entire Network</button></span>
    </div>
  </form>
  </div>
</div>

<div id="advanced-search-tab-content" class="search tab-pane">

  <p>The advanced search tool allows you to build advanced queries to search
for data about single relays and bridges in the Tor network or aggregated data about currently running relays. For single relays, it provides useful
information on how relays are configured along with graphs about their
past. Aggregated data provides insight into diversity in the network and the
probabilities of using relays in a particular country or AS as a guard, middle
or exit relay filtered by the search parameters.</p>
<div class="panel panel-default"><div class="panel-body">
  <form id="home-advanced-search">
    <div class="row">
    <div class="col-md-6">
    <div class="form-group">
      <label for="advanced-search-nickname">Nickname:</label>
      <input type="text" class="form-control search-query" autocorrect="off" autocapitalize="off" id="advanced-search-nickname">
    </div>
    <div class="form-group">
      <label for="advanced-search-fingerprint">Fingerprint:</label>
      <div class="input-group">
        <input type="text" class="form-control" autocorrect="off" autocapitalize="off" id="advanced-search-fingerprint">
        <span class="input-group-addon"><input type="checkbox" id="advanced-search-family"> Include Family</span>
      </div>
    </div>
    <div class="form-group">
      <label for="advanced-search-contact">Contact:</label>
      <input type="text" class="form-control search-query" autocorrect="off" autocapitalize="off" id="advanced-search-contact">
    </div>
    <div class="form-group">
      <label for="advanced-search-flag">Flag:</label>
      <select class="form-control" id="advanced-search-flag">
        <option value="">Any</option>
        <option value="stable">Stable</option>
        <option value="running">Running</option>
        <option value="fast">Fast</option>
        <option value="guard">Guard</option>
        <option value="exit">Exit</option>
        <option value="authority">Authority</option>
        <option value="noedconsensus">NoEdConsensus</option>
      </select>
    </div>
    <div class="form-group">
      <label for="advanced-search-country">Country:</label>
      <select class="form-control" id="advanced-search-country">
        <option value="">Any</option>
        <% var knownCountries = Object.keys(countries); knownCountries.sort(); %>
        <% _.each(knownCountries, function(country){ %>
          <option value="<%= country %>"><%= country %> - <%= countries[country] %></option>
        <% }); %>
      </select>
    </div>
     <div class="form-group">
      <label for="advanced-search-as">Autonomous System:</label>
      <div class="input-group">
        <span class="input-group-addon">AS</span>
        <input type="text" id="advanced-search-as" class="search-query form-control">
      </div>
     </div>
    </div><!-- col-md-6 -->
    <div class="col-md-6">
    <div class="form-group">
      <label for="advanced-search-hostname">Hostname:</label>
      <input type="text" class="form-control search-query" autocorrect="off" autocapitalize="off" id="advanced-search-hostname">
    </div>
    <div class="form-group">
      <label for="advanced-search-first-seen-from">First Seen:</label><br>
      From <input type="number" id="advanced-search-first-seen-from" class="form-control day-spinner" value="0"> to <input type="number" id="advanced-search-first-seen-to" class="form-control day-spinner" value="0"> days ago
    </div>
    <div class="form-group">
      <label for="advanced-search-last-seen-from">Last Seen:</label><br>
      From <input type="number" id="advanced-search-last-seen-from" class="form-control day-spinner" value="0"> to <input type="number" id="advanced-search-last-seen-to" class="form-control day-spinner" value="0"> days ago
    </div>
    <div class="form-group">
      <label for="advanced-search-version">Version:</label>
      <input type="text" class="form-control search-query" autocorrect="off" autocapitalize="off" id="advanced-search-version">
    </div>
    <div class="form-group">
      <label for="advanced-search-type">Type<sup>&dagger;</sup>:</label>
      <select class="form-control" id="advanced-search-type">
        <option value="">Any</option>
        <option value="relay">Only Relays</option>
        <option value="bridge">Only Bridges</option>
      </select>
    </div>
    <div class="form-group">
      <label for="advanced-search-running">Running<sup>&dagger;</sup>:</label>
      <select class="form-control" id="advanced-search-running">
        <option value="">Any</option>
        <option value="true">Only Running Relays</option>
        <option value="false">Only Offline Relays</option>
      </select>
    </div>
    </div><!-- col-md-6 -->
    </div><!-- row -->
    <p><button id="do-advanced" class="btn btn-primary" type="submit">Advanced Search</button></p>
    <p>
      <button id="do-advanced-aggregation" class="btn btn-primary" type="button">Advanced Aggregation</button>
      <button id="do-advanced-aggregation-as" class="btn btn-secondary tip" type="button" title="Aggregate by Autonomous System">by AS</button>
      <button id="do-advanced-aggregation-cc" class="btn btn-secondary tip" type="button" title="Aggregate by Country">by CC</button>
      <button id="do-advanced-aggregation-ascc" class="btn btn-secondary tip" type="button" title="Aggregate by both Autonomous System and Country">by AS+CC</button>
      <button id="do-advanced-aggregation-version" class="btn btn-secondary tip" type="button" title="Aggregate by Version">by Version</button>
    </p>
  </form>
  <p><sup>&dagger;</sup> These options are ignored when performing an aggregation as the aggregated searches are restricted to only currently running relays.</p>
</div></div><!-- /panel -->
  </div>
</div>

  <div class="well">
  <p>You can search for Tor relays and bridges by using keywords. In
particular, this tool enables you to search for (partial) nicknames (e.g.,
“moria”), IP addresses (e.g., “<a href="#search/128.31.">128.31.</a>”), and
fingerprints (e.g., “<a href="#search/9695DFC3">9695DFC3</a>”).  It is also
possible to combine searches, e.g., “<a href="#search/moria%20128.31.">moria
128.31.</a>”. Finally, you can use qualifiers to search for relays in specific
countries (e.g., “<a href="#search/moria%20country:us">moria country:us</a>”),
with specific contact information (e.g., “<a
href="#search/contact:arma">contact:arma</a>”), or with specific flags (e.g.,
“<a href="#search/flag:Authority">flag:Authority</a>”).</p>
  <p>If you are searching for a bridge, you will need to search by the hashed
fingerprint. This prevents leaking the fingerprint of the bridge when
searching. You can find this in the <code>hashed-fingerprint</code> file in the
Tor data directory. On Debian systems, this is in <code>/var/lib/tor</code> but
may be in another location on your system. The location is specified as
<code>DataDirectory</code> in your <code>torrc</code>.</p>
  </div>

