<commit_before><section id="content" role="main" class="ac-content">
  <form class="search-form aui">
    <input class="text search-field" type="text" id="search-query" name="search-query" placeholder="Rechercher dans l'historique">
  </form>

  <ul class="search-results"></ul>
</section>

<script id="results-template" type="text/x-handlebars-template">
  \{{#each results}}
    <li class="search-result">
      <div class="search-result-details">
        <span class="search-result-author">\{{this.author}}</span>
        <span class="search-result-date">- \{{this.date}}</span>
      </div>
      <div class="search-result-message">\{{this.message}}</div>
    </li>
  \{{/each}}
</script>

<script id="no-results-template" type="text/x-handlebars-template">
  <li class="search-result">Il n'y aucun message qui correspond à votre recherche.</li>
</script>

<script type="text/javascript">
  $(document).ready(function () {
    const searchResultsTemplate = Handlebars.compile($('#results-template').html().trim());
    const noResultsTemplate = Handlebars.compile($('#no-results-template').html().trim());

    function displayResults(results) {
      if (results.length === 0) {
        $('.search-results').html(noResultsTemplate());
        return;
      }
      $('.search-results').html(searchResultsTemplate({ results: results }));
    }

    $(".search-form").submit(function (event) {
      event.preventDefault();

      const searchQueryInput = $("input#search-query");
      const searchQuery = searchQueryInput.val().trim();
      if (searchQuery.length === 0) {
        return;
      }

      if (typeof HipChat === 'undefined') {
        // simulate
        displayResults([
          { author: "<NAME>", message: "MERDEUH", date: "20 Dec, 14:53" },
          { author: "<NAME>", message: "C'est pas le champ à utiliser mais bon…", date: "20 Dec, 15:12" },
          { author: "<NAME>", message: "Ça vaut le coup de regarder si c'est pas ce qu'ils ont fait, non ?", date: "19 Dec, 09:03" },
          { author: "<NAME>", message: "je déploie tearex", date: "19 Dec, 14:53" }
        ]);
        searchQueryInput.focusout();
        return;
      }
      HipChat.auth.withToken(function(err, token) {
        $.ajax({
          type: "POST",
          url: "{{endpoint}}/search",
          headers: { 'authorization': 'JWT ' + token },
          data: { query: searchQuery },
          dataType: 'json',
          error: (jqXHR, status) => console.error('fail', status),
          success: data => displayResults(data.map(result => result['_source']))
        });
      });
    });

  });
</script>
<commit_msg>use template string<commit_after><section id="content" role="main" class="ac-content">
  <form class="search-form aui">
    <input class="text search-field" type="text" id="search-query" name="search-query" placeholder="Rechercher dans l'historique">
  </form>

  <ul class="search-results"></ul>
</section>

<script id="results-template" type="text/x-handlebars-template">
  \{{#each results}}
    <li class="search-result">
      <div class="search-result-details">
        <span class="search-result-author">\{{this.author}}</span>
        <span class="search-result-date">- \{{this.date}}</span>
      </div>
      <div class="search-result-message">\{{this.message}}</div>
    </li>
  \{{/each}}
</script>

<script id="no-results-template" type="text/x-handlebars-template">
  <li class="search-result">Il n'y aucun message qui correspond à votre recherche.</li>
</script>

<script type="text/javascript">
  $(document).ready(function () {
    const searchResultsTemplate = Handlebars.compile($('#results-template').html().trim());
    const noResultsTemplate = Handlebars.compile($('#no-results-template').html().trim());

    function displayResults(results) {
      if (results.length === 0) {
        $('.search-results').html(noResultsTemplate());
        return;
      }
      $('.search-results').html(searchResultsTemplate({ results: results }));
    }

    $(".search-form").submit(function (event) {
      event.preventDefault();

      const searchQueryInput = $("input#search-query");
      const searchQuery = searchQueryInput.val().trim();
      if (searchQuery.length === 0) {
        return;
      }

      if (typeof HipChat === 'undefined') {
        // simulate
        displayResults([
          { author: "<NAME>", message: "MERDEUH", date: "20 Dec, 14:53" },
          { author: "<NAME>", message: "C'est pas le champ à utiliser mais bon…", date: "20 Dec, 15:12" },
          { author: "<NAME>", message: "Ça vaut le coup de regarder si c'est pas ce qu'ils ont fait, non ?", date: "19 Dec, 09:03" },
          { author: "<NAME>", message: "je déploie tearex", date: "19 Dec, 14:53" }
        ]);
        searchQueryInput.focusout();
        return;
      }
      HipChat.auth.withToken(function(err, token) {
        $.ajax({
          type: "POST",
          url: "{{endpoint}}/search",
          headers: { 'authorization': `JWT ${token}` },
          data: { query: searchQuery },
          dataType: 'json',
          error: (jqXHR, status) => console.error('fail', status),
          success: data => displayResults(data.map(result => result['_source']))
        });
      });
    });

  });
</script>

{'fraction_non_alphanumeric': 0.18928164196123148, 'fraction_numerical': 0.009882174078297225, 'mean_word_length': 2.9962034927866363, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 67, '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': '5091492', 'n_tokens_mistral': 1641, 'n_tokens_neox': 1579, 'n_words': 350}