<commit_before>{% extends "base.html" %}

{% block body %}

<div id="bs-home-intro-c" class="g-section">
  <div id="bs-home-recent-c">
    <div id="bs-home-recent">
      <h3>
        Recent tests
        {% if is_admin %}
          <a href="/clear_memcache?recent=1&continue=/" class="bs-admin">clear</a>
        {% endif %}
      </h3>
      <table id="bs-home-recent-tests" cellpadding="0" cellspacing="0">
        {% for test in recent_tests %}
          <tr>
            <td>{{ test.created|utc_to_pst|date:"P" }} PST</td>
            <td>{{ test.created|utc_to_pst|date:"N j" }}</td>
            <td>{{ test.category }}</td>
            <td>{{ test.user_agent_pretty }}</td>
          </tr>
        {% endfor %}
      </table>
    </div>
  </div>

  <p id="bs-home-intro">
    {{ app_title }} is a community-driven project for profiling web browsers.
    The goals are to foster innovation by tracking browser compatibility and performance and to be a resource for web developers.
  </p>
  <p id="bs-home-intro-sub">
    Gathering test results from users "in the wild" is the most important and useful feature of {{ app_title }} - and you can participate!
  </p>
  <p>
    <a href="/alltests" class="bs-btn">Run the Tests »</a>
  </p>
  <p>
    So far <strong>X</strong> users have run the tests <strong>X</strong> times on <strong>X</strong> unique browsers.
  </p>
</div>

<h2 id="bs-results-title">Results</h2>
{% if message %}
  <p class="d-msg">{{ message }}</p>
{% endif %}
<div id="bs-results">
  <ul id="bs-results-bycat" class="bs-compact">
    {% for app_category in app_categories %}
      {% with app_category|by_key:0 as category %}
        <li
          id="{{ category }}-results">
          <h3>{{ app_category|by_key:1 }}</h3>
          {% ifequal stats_table_category category %}
            {{ stats_table }}
          {% else %}
            <a
              id="{{ category }}-results-link"
              href="/?category={{ category }}&{{ results_params }}">View the {{ app_category|by_key:1 }} Results Table</a>
          {% endifequal %}
        </li>
      {% endwith %}
    {% endfor %}
  </ul>
</div>
<script src="{{ "xhrio.js"|resource_path }}"></script>
<script>
(function(){
  var xhrLoading = {};
  var changeCategoryClickHandler = function() {
    var link = this;
    if (selectedCategoryLink == link) {
      return;
    }
    categorySections[selectedCategoryLink.category].style.display = 'none';
    selectedCategoryLink.parentNode.className = '';

    // Reset to be the new one.
    selectedCategoryLink = link;
    selectedCategoryLink.parentNode.className = 'bs-sel';
    var el = categorySections[selectedCategoryLink.category];
    el.style.display = '';

    // XHR if we need to.
    if (el.innerHTML == '' && !xhrLoading[selectedCategoryLink.category]) {
      el.className = 'bs-loading';
      el.innerHTML = 'Loading the ' + selectedCategoryLink.category + ' Results...';
      xhrLoading[selectedCategoryLink.category] = true;
      var url = '/?category=' + selectedCategoryLink.category +
          '&xhr=1&{{ results_params }}';
      goog.net.XhrIo.send(url, function(e) {
        loadStatsTableCallback(e, selectedCategoryLink.category);
      }, 'get', null, null, 10000);
    }
  };
  var loadStatsTableCallback = function(e, category) {
    categorySections[category].className = '';
    var xhrio = e.target;
    if (xhrio.isSuccess()) {
      var html = xhrio.getResponseText();
      categorySections[category].innerHTML = html;
    } else {
      alert('Oops, looks like we encountered a server error. ' +
          'The appropriate nerd has been notified, feel free to try again.');
      xhrLoading[category] = false;
      categorySections[category].innerHTML = '';
    }
  };

  var categoriesList = document.createElement('ul');
  categoriesList.id = 'bs-results-cats';
  categoriesList.className = 'bs-compact';
  var categories = [];
  var categorySections = {};
  var parent, h3;<commit_msg>15sec timeout for homepage xhr<commit_after>{% extends "base.html" %}

{% block body %}

<div id="bs-home-intro-c" class="g-section">
  <div id="bs-home-recent-c">
    <div id="bs-home-recent">
      <h3>
        Recent tests
        {% if is_admin %}
          <a href="/clear_memcache?recent=1&continue=/" class="bs-admin">clear</a>
        {% endif %}
      </h3>
      <table id="bs-home-recent-tests" cellpadding="0" cellspacing="0">
        {% for test in recent_tests %}
          <tr>
            <td>{{ test.created|utc_to_pst|date:"P" }} PST</td>
            <td>{{ test.created|utc_to_pst|date:"N j" }}</td>
            <td>{{ test.category }}</td>
            <td>{{ test.user_agent_pretty }}</td>
          </tr>
        {% endfor %}
      </table>
    </div>
  </div>

  <p id="bs-home-intro">
    {{ app_title }} is a community-driven project for profiling web browsers.
    The goals are to foster innovation by tracking browser compatibility and performance and to be a resource for web developers.
  </p>
  <p id="bs-home-intro-sub">
    Gathering test results from users "in the wild" is the most important and useful feature of {{ app_title }} - and you can participate!
  </p>
  <p>
    <a href="/alltests" class="bs-btn">Run the Tests »</a>
  </p>
  <p>
    So far <strong>X</strong> users have run the tests <strong>X</strong> times on <strong>X</strong> unique browsers.
  </p>
</div>

<h2 id="bs-results-title">Results</h2>
{% if message %}
  <p class="d-msg">{{ message }}</p>
{% endif %}
<div id="bs-results">
  <ul id="bs-results-bycat" class="bs-compact">
    {% for app_category in app_categories %}
      {% with app_category|by_key:0 as category %}
        <li
          id="{{ category }}-results">
          <h3>{{ app_category|by_key:1 }}</h3>
          {% ifequal stats_table_category category %}
            {{ stats_table }}
          {% else %}
            <a
              id="{{ category }}-results-link"
              href="/?category={{ category }}&{{ results_params }}">View the {{ app_category|by_key:1 }} Results Table</a>
          {% endifequal %}
        </li>
      {% endwith %}
    {% endfor %}
  </ul>
</div>
<script src="{{ "xhrio.js"|resource_path }}"></script>
<script>
(function(){
  var xhrLoading = {};
  var changeCategoryClickHandler = function() {
    var link = this;
    if (selectedCategoryLink == link) {
      return;
    }
    categorySections[selectedCategoryLink.category].style.display = 'none';
    selectedCategoryLink.parentNode.className = '';

    // Reset to be the new one.
    selectedCategoryLink = link;
    selectedCategoryLink.parentNode.className = 'bs-sel';
    var el = categorySections[selectedCategoryLink.category];
    el.style.display = '';

    // XHR if we need to.
    if (el.innerHTML == '' && !xhrLoading[selectedCategoryLink.category]) {
      el.className = 'bs-loading';
      el.innerHTML = 'Loading the ' + selectedCategoryLink.category + ' Results...';
      xhrLoading[selectedCategoryLink.category] = true;
      var url = '/?category=' + selectedCategoryLink.category +
          '&xhr=1&{{ results_params }}';
      goog.net.XhrIo.send(url, function(e) {
        loadStatsTableCallback(e, selectedCategoryLink.category);
      }, 'get', null, null, 15000); // 15 second timeout
    }
  };
  var loadStatsTableCallback = function(e, category) {
    categorySections[category].className = '';
    var xhrio = e.target;
    if (xhrio.isSuccess()) {
      var html = xhrio.getResponseText();
      categorySections[category].innerHTML = html;
    } else {
      alert('Oops, looks like we encountered a server error. ' +
          'The appropriate nerd has been notified, feel free to try again.');
      xhrLoading[category] = false;
      categorySections[category].innerHTML = '';
    }
  };

  var categoriesList = document.createElement('ul');
  categoriesList.id = 'bs-results-cats';
  categoriesList.className = 'bs-compact';
  var categories = [];
  var categorySections = {};
  var parent, h3;
{'fraction_non_alphanumeric': 0.15959849435382686, 'fraction_numerical': 0.005269761606022585, 'mean_word_length': 2.7652338214454417, 'pattern_counts': {'":': 0, '<': 113, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2182755', 'n_tokens_mistral': 2581, 'n_tokens_neox': 2456, 'n_words': 608}