templates/terlaterie_search.html.twig line 1

  1. {% extends "base.html.twig" %}
  2. {% block title %}
  3.     {{ 'translation.search.title'|trans }}
  4. {% endblock %}
  5. {% block body %}
  6.     {{ form_start(form) }}
  7.     <div>
  8.         {{ form_errors(form) }}
  9.     </div>
  10.     <div class="row text-center align-items-start">
  11.         <div class="col-5">
  12.             <div class="row align-items-start">
  13.                 <div class="col-11">
  14.                     {{ form_row(form.searchString) }}
  15.                 </div>
  16.                 <div class="col-1"
  17.                      style="margin-top: 36px; font-size: 20px; margin-left: -55px; color: gray; cursor: pointer">
  18.                     <div id="empty_search">x</div>
  19.                 </div>
  20.             </div>
  21.         </div>
  22.         <div class="col-2">
  23.             {{ form_row(form.searchLanguage) }}
  24.         </div>
  25.         <div class="col-4">
  26.             {{ form_row(form.targetLanguages) }}
  27.         </div>
  28.         <div class="col-1">
  29.             {{ form_row(form.submit) }}
  30.         </div>
  31.     </div>
  32.     {{ form_end(form) }}
  33.     {#    {{ form(form) }} #}
  34.     <div class="row mb-2">
  35.         <div class="col-1">{{ 'translation.search_info_name'|trans }}</div>
  36.         <div class="col fw-bold">{{ search_string }}</div>
  37.     </div>
  38.     <div class="row align-items-center mb-4">
  39.         <div class="col-2">{{ 'translation.search.has_been_found_in'|trans }}</div>
  40.         <div class="col-10">
  41.             <list>
  42.                 <ul class="list-group list-group-horizontal">
  43.                     {% for projectKey, project in projects %}
  44.                         {% if translations[projectKey] is defined %}
  45.                             <li class="list-group-item text-bg-secondary"><a href="#title-{{ projectKey }}"
  46.                                                                              class="link-light link-offset-2 link-underline-opacity-25 link-underline-opacity-100-hover">{{ project.name }}</a>
  47.                             </li>
  48.                         {% endif %}
  49.                     {% endfor %}
  50.                 </ul>
  51.             </list>
  52.         </div>
  53.     </div>
  54.     {% for projectKey, project in projects %}
  55.         {% if translations[projectKey] is defined %}
  56.             <div class="container mb-4">
  57.                 <h3 id="title-{{ projectKey }}" class="text-center fw-bold">{{ project.name }}</h3>
  58.                 <p class="text-center small">
  59.                     {% if (project.source is defined and project.source != "") or (project.website is defined and project.website != "") %}
  60.                         (
  61.                         {% if project.source is defined and project.source != "" %}
  62.                             <a href="{{ project.source }}" class="link-info link-underline-opacity-25" target="_blank">Source</a>
  63.                         {% endif %}
  64.                         {% if (project.source is defined and project.source != "") and (project.website is defined and project.website != "") %}
  65.                             ;
  66.                         {% endif %}
  67.                         {% if project.website is defined and project.website != "" %}
  68.                             <a href="{{ project.website }}" class="link-info link-underline-opacity-25" target="_blank">Website</a>
  69.                         {% endif %}
  70.                         )
  71.                     {% endif %}
  72.                 </p>
  73.                 <table class="table table-dark table-striped table-hover table-bordered text-break">
  74.                     <thead>
  75.                     <tr>
  76.                         <th scope="col">{{ 'translation.search.key'|trans }}</th>
  77.                         {% for language in languages[projectKey] %}
  78.                             <th scope="col">{{ language }}</th>
  79.                         {% endfor %}
  80.                     </tr>
  81.                     </thead>
  82.                     <tbody class="table-group-divider">
  83.                     {% for key,translation in translations[projectKey] %}
  84.                         <tr>
  85.                             <th scope="row">
  86.                                 {{ key | replace({'.': ' > '}) }}
  87.                             </th>
  88.                             {% for language in languages[projectKey] %}
  89.                                 {% if translation[language] is defined %}
  90.                                     {% if project.quality[language] is defined %}
  91.                                         {% if project.quality[language].reviewed == false %}
  92.                                             {% set borderColor = "orange" %}
  93.                                         {% elseif project.quality[language].reviewed == true %}
  94.                                             {% set borderColor = "green" %}
  95.                                         {% else %}
  96.                                             {% set borderColor = "" %}
  97.                                         {% endif %}
  98.                                     {% else %}
  99.                                         {% set borderColor = "" %}
  100.                                     {% endif %}
  101.                                     <td class="{{ borderColor }}">
  102.                                         {{ translation[language] | raw }}
  103.                                     </td>
  104.                                 {% endif %}
  105.                             {% endfor %}
  106.                         </tr>
  107.                     {% endfor %}
  108.                     </tbody>
  109.                 </table>
  110.             </div>
  111.         {% endif %}
  112.     {% endfor %}
  113.     <script>
  114.         var searchInput = $('#terlaterie_search_searchString');
  115.         var emptyButton = $('#empty_search');
  116.         emptyButton.click(e => {
  117.             e.preventDefault();
  118.             searchInput.val('').focus();
  119.         })
  120.         var tl = $('#terlaterie_search_targetLanguages')
  121.         tl.children().each(function () {
  122.             $(this).addClass('form-check').addClass('form-check-inline');
  123.             $(this).children('input').addClass('btn-check');
  124.             $(this).children('label').addClass('btn text-light');
  125.         })
  126.         tl.prev().addClass('form-title');
  127.         $(document).on('keypress', function (e) {
  128.             if (!searchInput.is(':focus') && (e.key === '/' || e.key === 's')) {
  129.                 e.preventDefault();
  130.                 searchInput.focus().select();
  131.             }
  132.         });
  133.     </script>
  134. {% endblock body %}