|
|
Linha 18: |
Linha 18: |
| | | |
| /** to create a filter table with JavaScript **/ | | /** to create a filter table with JavaScript **/ |
− | $(document).ready(function myFunction() { | + | $(document).ready(function() { |
− | // Declare variables | + | $(".search").keyup(function () { |
− | var input, filter, table, tr, td, i;
| + | var searchTerm = $(".search").val(); |
− | input = document.getElementById("myInput");
| + | var listItem = $('.results tbody').children('tr'); |
− | filter = input.value.toUpperCase();
| + | var searchSplit = searchTerm.replace(/ /g, "'):containsi('") |
− | table = document.getElementById("myTable");
| + | |
− | tr = table.getElementsByTagName("tr");
| + | $.extend($.expr[':'], {'containsi': function(elem, i, match, array){ |
− | | + | return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0; |
− | // Loop through all table rows, and hide those who don't match the search query
| + | |
− | for (i = 0; i < tr.length; i++) {
| + | |
− | td = tr[i].getElementsByTagName("td")[0]; | + | |
− | if (td) {
| + | |
− | if (td.innerHTML.toUpperCase().indexOf(filter) > -1) {
| + | |
− | tr[i].style.display = "";
| + | |
− | } else {
| + | |
− | tr[i].style.display = "none";
| + | |
− | }
| + | |
| } | | } |
− | } | + | }); |
| + | |
| + | $(".results tbody tr").not(":containsi('" + searchSplit + "')").each(function(e){ |
| + | $(this).attr('visible','false'); |
| + | }); |
| + | |
| + | $(".results tbody tr:containsi('" + searchSplit + "')").each(function(e){ |
| + | $(this).attr('visible','true'); |
| + | }); |
| + | |
| + | var jobCount = $('.results tbody tr[visible="true"]').length; |
| + | $('.counter').text(jobCount + ' item'); |
| + | |
| + | if(jobCount == '0') {$('.no-result').show();} |
| + | else {$('.no-result').hide();} |
| + | }); |
| }); | | }); |
Revisão das 01h15min de 10 de outubro de 2016
/** Códigos Javascript aqui colocados serão carregados por todos aqueles que acederem à WikiSporting.com **/
/** Tynt Tracking **/
if(document.location.protocol=='http:'){
var Tynt=Tynt||[];Tynt.push('czzJj69Myr4ly6acwqm_6l');Tynt.i={"ap":"Ler mais:"};
(function(){var s=document.createElement('script');s.async="async";s.type="text/javascript";s.src='http://tcr.tynt.com/ti.js';var h=document.getElementsByTagName('script')[0];h.parentNode.insertBefore(s,h);})();
}
/** Solution for sticking footer at bottom in short pages **/
$(document).ready(function() {
var docHeight = $(window).height();
var footerHeight = $('#main-footer').height();
var footerTop = $('#main-footer').position().top + footerHeight;
if (footerTop < docHeight) {
$('#main-footer').css('margin-top', 10+ (docHeight - footerTop) + 'px');
}
});
/** to create a filter table with JavaScript **/
$(document).ready(function() {
$(".search").keyup(function () {
var searchTerm = $(".search").val();
var listItem = $('.results tbody').children('tr');
var searchSplit = searchTerm.replace(/ /g, "'):containsi('")
$.extend($.expr[':'], {'containsi': function(elem, i, match, array){
return (elem.textContent || elem.innerText || '').toLowerCase().indexOf((match[3] || "").toLowerCase()) >= 0;
}
});
$(".results tbody tr").not(":containsi('" + searchSplit + "')").each(function(e){
$(this).attr('visible','false');
});
$(".results tbody tr:containsi('" + searchSplit + "')").each(function(e){
$(this).attr('visible','true');
});
var jobCount = $('.results tbody tr[visible="true"]').length;
$('.counter').text(jobCount + ' item');
if(jobCount == '0') {$('.no-result').show();}
else {$('.no-result').hide();}
});
});