");
/* Pop the first elements, they are empty strings */
x_array.shift();
y_array.shift();
x_array = jQuery.map( x_array, function( a ) {
return parse_callnumber( a );
});
y_array = jQuery.map( y_array, function( a ) {
return parse_callnumber( a );
});
x_array.sort();
y_array.sort();
x = x_array.shift();
y = y_array.shift();
if ( !x ) { x = ""; }
if ( !y ) { y = ""; }
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
};
jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) {
var x_array = x.split("
");
var y_array = y.split("
");
/* Pop the first elements, they are empty strings */
x_array.shift();
y_array.shift();
x_array = jQuery.map( x_array, function( a ) {
return parse_callnumber( a );
});
y_array = jQuery.map( y_array, function( a ) {
return parse_callnumber( a );
});
x_array.sort();
y_array.sort();
x = x_array.pop();
y = y_array.pop();
if ( !x ) { x = ""; }
if ( !y ) { y = ""; }
return ((x < y) ? 1 : ((x > y) ? -1 : 0));
};
function parse_callnumber ( html ) {
var array = html.split('');
if ( array[1] ) {
array = array[1].split('');
return array[0];
} else {
return "";
}
}
// see http://www.datatables.net/examples/advanced_init/footer_callback.html
function footer_column_sum( api, column_numbers ) {
// Remove the formatting to get integer data for summation
var intVal = function ( i ) {
if ( typeof i === 'number' ) {
if ( isNaN(i) ) return 0;
return i;
} else if ( typeof i === 'string' ) {
var value = i.replace(/[a-zA-Z ,.]/g, '')*1;
if ( isNaN(value) ) return 0;
return value;
}
return 0;
};
for ( var indice = 0 ; indice < column_numbers.length ; indice++ ) {
var column_number = column_numbers[indice];
var total = 0;
var cells = api.column( column_number, { page: 'current' } ).nodes().to$().find("span.total_amount");
$(cells).each(function(){
total += intVal( $(this).html() );
});
total /= 100; // Hard-coded decimal precision
// Update footer
$( api.column( column_number ).footer() ).html(total.format_price());
};
}
function filterDataTable( table, column, term ){
if( column ){
table.column( column ).search( term ).draw("page");
} else {
table.search( term ).draw("page");
}
}