!function(t){t.fn.tableHeadFixer=function(n){return this.each(function(){(function(){function o(n){n.each(function(n,o){var o=t(o),i=t(o).parent(),r=o.css("background-color");r="transparent"==r||"rgba(0, 0, 0, 0)"==r?null:r;var e=i.css("background-color"),a=(e="transparent"==e||"rgba(0, 0, 0, 0)"==e?null:e)||"white";a=r||a,o.css("background-color",a)})}function i(n,o){for(var i=r.left,e=1,a=1;a<=i;a+=e){var l=e>1?a-1:a,f=t(n).find("> *:nth-child("+l+")"),c=f.prop("colspan");void 0!==f.cellPos()&&f.cellPos().left thead > tr > *").css("top",e),r.foot&&this.find("> tfoot > tr > *").css("bottom",o-i-e),r.left>0&&r.leftColumns.css("left",a),r.right>0&&r.rightColumns.css("right",t-n-a)}.bind(f)),1==r.head&&((e=t(r.table).find("> thead")).find("> tr"),o(a=e.find("> tr > *")),a.css({position:"relative"}));var e,a;var l,f;1==r.foot&&((c=t(r.table).find("> tfoot")).find("> tr"),o(s=c.find("> tr > *")),s.css({position:"relative"}));var c,s;r.left>0&&(d=t(r.table),r.leftColumns=t(),d.find("> thead > tr, > tbody > tr, > tfoot > tr").each(function(t,n){i(n,function(t){r.leftColumns=r.leftColumns.add(t)})}),r.leftColumns.each(function(n,o){var o=t(o);o.css({position:"relative","z-index":"11"})}));var d;r.right>0&&function(){var n=t(r.table);r.right;r.rightColumns=t();var o=n.find("> thead").find("> tr"),i=n.find("> tbody").find("> tr"),e=null;o.each(function(n,o){!function(n,o){for(var i=r.right,e=1,a=1;a<=i;a+=e){var l=e>1?a-1:a,f=t(n).find("> *:nth-last-child("+l+")"),c=f.prop("colspan");o(f),e=c}}(o,function(t){0===n&&(e=t),r.rightColumns=r.rightColumns.add(e)})}),i.each(function(n,o){!function(n,o){for(var i=r.right,e=1,a=1;a<=i;a+=e){var l=e>1?a-1:a,f=t(n).find("> *:nth-last-child("+l+")"),c=f.prop("colspan");o(f),e=c}}(o,function(t){r.rightColumns=r.rightColumns.add(t)})}),r.rightColumns.each(function(n,o){var o=t(o);o.css({position:"relative","z-index":"9999"})})}();(function(){var n=t(r.table);if(r.head){if(r.left>0){var o=n.find("> thead > tr");o.each(function(n,o){i(o,function(n){t(n).css("z-index",r["z-index"]+1)})})}if(r.right>0){var o=n.find("> thead > tr");o.each(function(n,o){solveRightColspan(o,function(n){t(n).css("z-index",r["z-index"]+1)})})}}if(r.foot){if(r.left>0){var o=n.find("> tfoot > tr");o.each(function(n,o){i(o,function(n){t(n).css("z-index",r["z-index"])})})}if(r.right>0){var o=n.find("> tfoot > tr");o.each(function(n,o){solveRightColspan(o,function(n){t(n).css("z-index",r["z-index"])})})}}})(),t(r.parent).trigger("scroll"),t(window).resize(function(){t(r.parent).trigger("scroll")})}).call(this)})}}(jQuery),function(t){t.fn.cellPos=function(n){var o,i=this.first(),r=i.data("cellPos");if(!r||n){var e=i.closest("table, thead, tbody, tfoot");o=[],e.children("tr").each(function(n,i){t(i).children("td, th").each(function(i,r){var e,a,l=t(r),f=0|l.attr("colspan"),c=0|l.attr("rowspan");for(f=f||1,c=c||1;o[n]&&o[n][i];++i);for(e=i;e0)if(a.tHead&&a.tHead.rows.length>0){for(e=0;e0&&l.push(k),m++;if(!l)return}for(m=0;m ('+row.symbol+')
'+data+'
'; return html; case 'price': if (typeof data !== 'undefined' && data !=null){ if (data >= 25) { var formatedVal = numeral(data).format('0,0.00'); } else if (data >= 0.50 && data < 25) { var formatedVal = numeral(data).format('0,0.000'); } else if (data >= 0.01 && data < 0.50) { var formatedVal = numeral(data).format('0,0.0000'); } else if (data >= 0.0001 && data < 0.01) { var formatedVal = numeral(data).format('0,0.00000'); } else { var formatedVal = numeral(data).format('0,0.00000000'); } return html = '
'+fiatSymbol + formatedVal+'
'; }else{ return html = '
'+fiatSymbol + formatedVal+'
'; }else{ return html = '
?
'; break; case 'percent_change_24h': if (typeof data !== 'undefined' && data != null) { var changesCls = "up"; var wrpchangesCls = "cmc-up"; if (typeof Math.sign === 'undefined') { Math.sign = function (x) { return x > 0 ? 1 : x < 0 ? -1 : x; } } if (Math.sign(data) == -1) { var changesCls = "down"; var wrpchangesCls = "cmc-down"; } var html = '
'+data+'%
'; return html; }else{ return html='
?
'; } break; case 'market_cap': var formatedVal = data; if( typeof is_milbil_enable != 'undefined' && is_milbil_enable == '1' ){ formatedVal = numeral(data).format('(0.00 a)'); }else{ formatedVal = formatedVal.toString(); } if (typeof data !== 'undefined' && data != null) { return html = '
'+fiatSymbol + formatedVal.toUpperCase()+'
'; }else{ return html = '
?
'; } break; case 'volume': var formatedVal = data; if( typeof is_milbil_enable != 'undefined' && is_milbil_enable == '1' ){ formatedVal = numeral(data).format('(0.00 a)'); }else{ formatedVal = formatedVal.toString(); } if (typeof data !== 'undefined' && data != null) { return html = '
'+fiatSymbol + formatedVal.toUpperCase()+'
'; } else { return html = '
?
'; } break; case 'supply': if (typeof data !== 'undefined' && data != null) { var formatedVal = numeral(data).format('(0.00 a)'); return html ='
'+formatedVal.toUpperCase() + ' ' + row.symbol+'
'; } else { return html = '
?
'; } break; case 'weekly_chart': var chart_data=''; var gChart=''; //green var dynamic_color = "data-bg-color='#90EE90' data-color='#006400'"; var chart_cls='weekly_up'; if (row.weekly_chart =="false"){ chart_data ="undefined"; var gChart ='false'; }else{ chart_data= row.weekly_chart; var data_array= JSON.parse(chart_data); var first_ele=data_array[0]; var last_ele=data_array[data_array.length-1]; var gChart = 'true'; if (parseFloat(last_ele)>parseFloat(first_ele)) { //green var dynamic_color = "data-bg-color='#90EE90' data-color='#006400'"; var chart_cls='weekly_up'; }else{ //red var dynamic_color = "data-bg-color='#ff9999' data-color='#ff0000'"; var chart_cls = 'weekly_down'; } } return html = '
'; break; } }, "createdCell": function (td, cellData, rowData, row, col) { if(col!=8){ $(td).attr('data-sort', cellData); } } }); }); $cmc_table.DataTable({ "deferRender": true, "serverSide": true, "ajax": { "url": ajax_object.ajax_url, "type": "POST", "dataType": "JSON", "data": function (d) { d.action = "dt_get_coins_list", d.currency =fiatCurrency, d.currencyRate = fiatCurrencyRate // etc }, "error": function (xhr, error, thrown) { // alert('Something wrong with Server'); } }, "ordering": false, "searching": false, "pageLength":pagination, "columns": columns, "lengthChange": false, "dom": '<"top"iflp<"clear">>rt<"bottom"iflp<"clear">>', "pagingType": "simple", "processing": true, "language": { "processing":loadingLbl, "loadingRecords":loadingLbl, "paginate": { "next": nexttext, "previous":prevtext }, }, "zeroRecords":zeroRecords, "emptyTable":zeroRecords, "renderer": { "header": "bootstrap", }, "drawCallback": function (settings) { $cmc_table.find(".cmc-sparkline-charts").each(function (index) { $(this).generateSmallChart(); }); $cmc_table.tableHeadFixer({ // fix table header head: true, // fix table footer foot: false, left:2, right:false, 'z-index':1 }); }, "createdRow": function (row, data, dataIndex) { $(row).attr('data-coin-symbol',data.symbol); $(row).attr('data-coin-id',data.coin_id); $(row).attr('data-coin-price', data.price); }, }); } $("#cmc_coinslist").cmcDatatable(); new Tablesort(document.getElementById('cmc_coinslist'), { descending: true }); var content = $("#cmc_search_html").html(); var search_data = JSON.parse(content); var source = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'), queryTokenizer: Bloodhound.tokenizers.whitespace, local: search_data }); source.initialize(); var noresult = $("#custom-templates").data('no-result'); $('#custom-templates .typeahead').typeahead(null, { name: 'matched-links', displayKey: 'name', source: source.ttAdapter(), templates: { empty: [ '
', noresult, '
' ].join('\n'), suggestion: Handlebars.compile(document.getElementById("search_temp").innerHTML) } }); $(".cmc_conversions").on("change", function () { var selected_curr = $('option:selected',this).val(); var currencySymbol = $('option:selected', this).data('currency-symbol'); var currencyRate = $('option:selected', this).data('currency-rate'); var all_per =$("#cmc_coinslist thead tr").find('th.cmc-future-price-head').data('percentage'); $("#cmc_coinslist").find('tbody tr').each(function (index) { var priceTD = $(this).find('.cmc-price'); var volTD = $(this).find('.cmc-vol'); var capTD = $(this).find('.cmc-market-cap'); var is_milbil_enable = $(this).parents("#cmc_coinslist").data('number-formating'); var coinPrice = priceTD.data('val'); var cmcVol = volTD.data('val'); var cmcMarketCap = capTD.data('val'); var coinId=$(this).data('coin-id'); var coin_per=''; if(all_per[coinId]){ coin_per=all_per[coinId]; }else{ coin_per=all_per['all']; } if (selected_curr=="BTC"){ var convertedPrice = coinPrice / currencyRate; var convertedVol = cmcVol / currencyRate; var convertedCap = cmcMarketCap / currencyRate; var formatedPrice = numeral(convertedPrice).format('0,0.0000000'); var formatedVol = numeral(convertedVol).format('0,0'); var formatedCap = numeral(convertedCap).format('0,0'); }else{ var convertedPrice = coinPrice * currencyRate; var futurePrice=convertedPrice+(convertedPrice*coin_per/100); var convertedVol = cmcVol * currencyRate; var convertedCap = cmcMarketCap * currencyRate; if (convertedPrice < 0.50) { var formatedPrice = numeral(convertedPrice).format('0,0.000000'); } else { var formatedPrice = numeral(convertedPrice).format('0,0.00'); } if (futurePrice < 0.50) { var formatedFuturePrice = numeral(futurePrice).format('0,0.000000'); } else { var formatedFuturePrice = numeral(futurePrice).format('0,0.00'); } if( typeof is_milbil_enable != 'undefined' && is_milbil_enable == '1' ){ var formatedVol = numeral(convertedVol).format('(0.00 a)').toUpperCase(); var formatedCap = numeral(convertedCap).format('(0.00 a)').toUpperCase(); }else{ var formatedVol = convertedVol; var formatedCap = convertedCap; } } priceTD.html(currencySymbol+'' + formatedPrice + ''); capTD.html(currencySymbol+formatedCap); volTD.html(currencySymbol+formatedVol); $(this).find('.cmc-future-price').html(currencySymbol+formatedFuturePrice); }); }); })(jQuery);;