Skip to content

Instantly share code, notes, and snippets.

@reachkamrul
Created October 23, 2021 08:37
Show Gist options
  • Save reachkamrul/bd148d8fca0efdd6aefcde2257cb5958 to your computer and use it in GitHub Desktop.
Save reachkamrul/bd148d8fca0efdd6aefcde2257cb5958 to your computer and use it in GitHub Desktop.
var seperator = '.'; // Give the seperator
var classes = 'myclass'; // Give the class
function renderFoot(){
if(!$table.find('tfoot').length){
jQuery("<tfoot></tfoot>").appendTo($table);
}
var counts = $table.find(".footable-header th").length;
var num = parseInt(counts);
jQuery('.final_result').remove();
var container = $("<tr class='final_result' />");
var notThis = [];
jQuery('.footable-header th').each(function(){
if(jQuery(this).css('display') == 'none'){
var index = parseInt(jQuery(this).index(),10) + 1;
notThis.push(index);
}
})
for(var i = 1; i <= num; i++) {
if ($.inArray(i, notThis) != -1)
{
i;
}
else{
$('<td />', {
}).appendTo(container);}
}
$('tfoot').prepend(container);
}
function addTime(){
var hour=0;
var minute=0;
var second=0;
var totalMin = 0;
var totalSec = 0;
$table.find("tbody ."+classes+"").each(function(){
var time = jQuery(this).text()
var splitTime= time.split(seperator);
totalMin = parseInt(totalMin) + parseInt(splitTime[0]);
totalSec = parseInt(totalSec) + parseInt(splitTime[1]);
})
minute = parseInt(totalMin);
hour = parseInt(hour + minute/60);
minute = minute%60;
second = parseInt(totalSec);
minute = parseInt(minute + second/60);
second = second%60;
var addHere = $table.find("tbody ."+classes+"").index();
addHere +=1;
jQuery('.final_result td:nth-child('+addHere+')').html(hour+' hours '+minute+' minutes '+ second + ' seconds').css('text-align', 'center');
}
renderFoot();
addTime()
$table.on('after.ft.filtering', function() {
renderFoot();
addTime()
});
$table.on('after.ft.paging', function() {
renderFoot();
addTime()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment