templates/v_card/_search.html.twig line 1

Open in your IDE?
  1.  <div class="col-md-3">
  2.     </div>
  3.         <div class="col-md-9">
  4.                 <div class="tab-pane" id="cv-form">
  5.                     <div class="card shadow mb-4">
  6.                         <!-- div class="card-header bg-primary text-white text-center">
  7.                             <h3 class="mb-0">Formulaire de carte de visite</h3>
  8.                         </div -->
  9.                         <div class="card-body card-preview">
  10.                 <div class="logo-etab"></div>
  11.                 <div class="search_spacer"></div>
  12.                             <form id="search_form" name="v_card" action="#">
  13.                 <div class="form-group row align-items-center autocomplete">
  14.                     <label id="search_label" for="email" class="col-sm-4 col-form-label">Rechercher une carte:</label>
  15.                     <div class="col-sm-8 d-flex">
  16.                         <input type="text" class="form-control" id="search_field" name="email" placeholder="Entrez un email" title="Veuillez saisir une adresse email valide"/>
  17.                     </div>
  18.                     <ul id="searchResult">
  19.                     </ul>
  20.             <div id="search_error" class="msg-error">Aucun résultat....</div>
  21.                 </div>
  22.                 <!-- div><input type=search name="email"/></div-->
  23.                     <hr/>
  24.                                             <button type="submit" id="search_btn" class="btn btn-primary">Rechercher</button>
  25. <script>
  26.     function addSuggestions(target, datas) {
  27.         let idx, len;
  28.         if (target !== null) {
  29.             for (let item in datas) {
  30.                 if (item != undefined
  31.                     && document.getElementById(datas[item]['EMAIL_PRO']) === null
  32.                 ) {
  33.                     let new_li = document.createElement('li');
  34.                     new_li.setAttribute('value', datas[item]['EMAIL_PRO']);
  35.                     new_li.innerText = datas[item]['EMAIL_PRO'];
  36.                     new_li.id = datas[item]['EMAIL_PRO'];
  37.     
  38.                     target.appendChild(new_li);
  39.                 }
  40.             }
  41.         }
  42.     }
  43.     
  44.     function connectSearchResult() {
  45.     let search_res = document.getElementById("searchResult").onclick = function(evt) {
  46.         let text_value = evt.target.getAttribute('value');
  47.         
  48.         console.log('click:' + text_value);
  49.         document.getElementById("search_field").value = text_value;
  50.         
  51.         document.getElementById("searchResult").innerHTML = '';
  52.     
  53.     };
  54.     }
  55.     // addSuggestions(document.getElementById('searchResult'), ["un", "deuz", "trois", "quatre"]);
  56.     connectSearchResult();
  57. </script>
  58.                 <div class="social-media-block">
  59. <div class="inner-block">
  60. <ul class="social-media-links--platforms platforms">
  61.       <li>
  62.       <a class="social-media-link-icon--facebook_" href="https://www.facebook.com//AMParisTech" target="_blank">
  63.         <span class="fab fa-facebook fa-2x"></span>
  64.       </a>
  65.           </li>
  66.       <li>
  67.       <a class="social-media-link-icon--tiktok" href="https://www.tiktok.com/@artsetmetiers" target="_blank">
  68.         <span class="fab fa-tiktok fa-2x"></span>
  69.       </a>
  70.           </li>
  71.       <li>
  72.       <a class="social-media-link-icon--twitter" href="https://www.twitter.com/ArtsetMetiers_" target="_blank">
  73.         <span class="fab fa-twitter fa-2x"></span>
  74.       </a>
  75.           </li>
  76.       <li>
  77.       <a class="social-media-link-icon--youtube" href="https://www.youtube.com/ARTSETMETIERSCOM" target="_blank">
  78.         <span class="fab fa-youtube fa-2x"></span>
  79.       </a>
  80.           </li>
  81.       <li>
  82.       <a class="social-media-link-icon--linkedin" href="https://www.linkedin.com/school/arts-et-m-tiers-paristech/" target="_blank">
  83.         <span class="fab fa-linkedin fa-2x"></span>
  84.       </a>
  85.           </li>
  86.       <li>
  87.       <a class="social-media-link-icon--instagram" href="https://www.instagram.com/artsetmetiers_ensam" target="_blank">
  88.         <span class="fab fa-instagram fa-2x"></span>
  89.       </a>
  90.           </li>
  91.       <li>
  92.       <a class="social-media-link-icon--rss" href="/fr/actualites.xml" target="_blank">
  93.         <span class="fa fa-rss fa-2x"></span>
  94.       </a>
  95.           </li>
  96.   </ul>
  97. <div class="root-site-url">artsetmetiers.fr</div>
  98.           </div>
  99. </div>
  100.                             </form>
  101.                         </div>
  102.                     </div>
  103.                 </div>
  104.     </div><!-- class="col-md-3" //-->
  105. <script>
  106.     var vcard_tab = document.getElementById('cv-tab');
  107.     if (vcard_tab !== null) {
  108.         vcard_tab.onclick = function(evt) {
  109.                 evt.preventDefault();
  110.                 window.location = '/v/card/';
  111.             };
  112.     }
  113.     var
  114.         search_form = document.getElementById('search_form'),
  115.         search_btn = document.getElementById('search_btn'),
  116.         search_field = document.getElementById('search_field'),
  117.         error_div = document.getElementById('search_error')
  118.     ;
  119.     if (search_field !== null
  120.        ) {
  121.         search_field.onkeyup = function(evt) {
  122.             if (search_field.value != ''
  123.                    && search_field.value.length > 2
  124.            ) {
  125.                 let search_res = document.getElementById('searchResult');
  126.                 if (search_res !== null) {
  127.                     search_res.innerHTML = '';
  128.             $.ajax({
  129.                       type: "POST",
  130.                     dataType: 'json',
  131.                       url: 'search',
  132.                       data: '&email=' + search_field.value,
  133.                       success: function(ans) {
  134.                         if (ans !== null
  135.                         ) {
  136.                             let len = ans.len;
  137.                             console.log('search: ' + ans[0]['EMAIL_PRO']);
  138.                             addSuggestions(document.getElementById('searchResult'), ans);
  139.                         }
  140.                     },
  141.                 });
  142.                 } // END if search_res
  143.             }
  144.         };
  145.     }
  146.     if (search_form !== null
  147.         // && search_btn !== null
  148.         // && search_field !== null
  149.     ) {
  150.         search_form.onsubmit = function(evt) {
  151.                 evt.preventDefault();
  152.                 let email = search_field.value;
  153.             window.location = '/v/card/last/?email=' + email {%if needs_auth is not defined%} + '&back=search'{%endif%};
  154. /*
  155.             if (error_div !== null) {
  156.                 error_div.style.display = 'none';
  157.             }
  158.                 $.ajax({
  159.                       type: "POST",
  160.                       url: 'search',
  161.                       data: '&email=' + email,
  162.                       success: function(ans) {
  163.                         if (ans !== null
  164.                             && ans['EMAIL_PRO']
  165.                         ) {
  166.                             window.location = '/v/card/last/?email=' + email {%if needs_auth is defined%} + '&back=search'{%endif%};
  167.                         } else {
  168.                             if (error_div !== null) {
  169.                                 error_div.style.display = 'block';
  170.                             }
  171.                         }
  172.                     },
  173.   
  174. });
  175. */
  176.             };
  177.     }
  178. </script>