Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html><head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width">
  5. <style>
  6.  
  7.  
  8. p{
  9.    
  10.     font-family: Arial,"Helvetica Neue",Helvetica,sans-serif;
  11. }
  12.  
  13. a{
  14.     text-decoration:none;
  15.     font-family: Tahoma, "DejaVu Sans Condensed", Arial, Helvetica, sans-serif;
  16.     font-weight:700;
  17.     color:#006bdf;
  18. }
  19.  
  20. a:hover{
  21.     color:#f79726;
  22. }
  23.  
  24. a:focus{
  25.   outline: none;
  26. }
  27.  
  28. #myInput {
  29.  
  30.     height:35px;
  31.     font-size:1.35em;
  32.     margin:auto;
  33.     display:block;
  34.     border-radius:25px;
  35.     padding:5px 15px;
  36.     margin-bottom:10px;
  37.     text-align:center;
  38. }
  39.  
  40. #myInput:hover, #myInput:focus{
  41.     background-color:skyblue;
  42. }
  43.  
  44. #myTable {
  45.   width:55%;
  46.   margin:auto;
  47.   border: 1px solid #ddd;
  48.   font-size: 20px;
  49. }
  50.  
  51. #myTable th, #myTable td {
  52.   padding: 12px;
  53. }
  54.  
  55. #myTable tr {
  56.   border-bottom: 1px solid #ddd;
  57. }
  58.  
  59. #myTable tr.header{
  60.   background-color: #e0e0e0;
  61. }
  62.  
  63. td{
  64.     text-align:center;
  65.     border-spacing: 0 0.125rem;
  66. }
  67.  
  68. td:hover{
  69.     background-color:#f7f7e6;
  70. }
  71.  
  72. tr:nth-child(even){
  73.     background-color:#eef5fc;
  74. }
  75. </style>
  76. </head>
  77. <body>
  78.  
  79. <script>
  80. function fu() {
  81.   var input, filter, table, tr, td, i;
  82.   var count = 0;
  83.   input = document.getElementById("myInput");
  84.   filter = input.value.toUpperCase();
  85.  
  86.   table = document.getElementById("myTable");
  87.   tr = table.getElementsByTagName("tr");
  88.  
  89.   for (i = 0; i < tr.length; i++) {
  90.    td = tr[i].getElementsByTagName("td")[0];
  91.    if (td) {
  92.     var result = td.innerHTML;
  93.     result = result.toUpperCase();
  94.      if ((result.indexOf(filter) > -1) || (i==0)) {
  95.         tr[i].style.display = "";
  96.         count++;
  97.       }else{
  98.         tr[i].style.display = "none";
  99.       }
  100.     }      
  101.   }
  102.  
  103.   show_status(count-1);
  104.  
  105. }
  106.  
  107. function show_status(count){
  108.  
  109.     if(count==-1){
  110.         var links;
  111.         links = document.getElementsByTagName('a');
  112.         count = links.lenght+5;
  113.     }
  114.  
  115.     var text;
  116.     if(!count){
  117.         text = 'Aucun topic :c';
  118.     }else if(count==1){
  119.         text = '1 topic';
  120.     }else{
  121.         text = count + ' topics';
  122.     }
  123.     document.getElementById("status").innerHTML = text;
  124.    
  125. }
  126.  
  127. document.addEventListener('keyup', (event) => {
  128.   const keyName = event.key;
  129.   var setInput = document.getElementById("myInput");
  130.   if (keyName === 'Enter') {
  131.     setInput.value ="";
  132.     window.scrollTo(0, 0);
  133.     setInput.focus();
  134.     fu();
  135.   }
  136. }, false);
  137.  
  138. </script>
  139.  
  140. <table id="myTable">
  141. <tr><td>
  142. <p>JVFav</p>
  143. <input type="text" id="myInput" onkeyup="fu()" placeholder="Search item" title="Type in a name">
  144.  
  145. </td></tr>
  146.  
  147.   <tbody><tr class="header">
  148.     <th style="width:50%;" id="status" >-</th>
  149.   </tr>
  150.   </tbody>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement