Nguyen Trieu

3 bundles
1 file20 days ago
1

Untitled

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869initDatatable(
      'getTrafficDestinationAds',
      {
        ajax: {
          url: `https://localapi.trazk.com/webdata/websiteapi.php?task=getTrafficDestinationAds&domain=${domain}`,
          dataSrc: json => {
            console.log(json);
            
              if(!json.data || !json.data.data)
              {
                return [];
              }

              else{
                return json.data.data;
              }
             
          }
        },
        drawCallback: function (settings) {
          $('.getTrafficDestinationAds-container').removeClass('is-loading').unblock();
          $('.getTrafficDestinationAds-container').find('.fa-spin').removeClass('fa-spin');
        },
        columns: [
          { 
            title: 'Website', 
            data: data => `<div>
                    <img src="${data.Favicon}" class="mr-1"/>
                    <a  data-type="website" class="changeURL" data-input="${data.Domain}" href="?view=traffic-website&action=result&domain=${data.Domain}">${data.Domain}</a>
                  </div>`
            },
           
          {
            title: '(%)',
            data: data => {
              const share = numeral(data.Share).format('0.00%');
              return `<div class="row">
                        <div class="col-4">
                          ${share}
                        </div>
                        <div class="col-8">
                          <div class="progress border">
                            <div class="progress-bar bg-primary" style="width: ${share}; height:14px;" role="progressbar"></div>
                          </div>
                        </div>
                      </div>`;
            }
          },
          {
            title: 'Tỉ lệ',
          }
        ],"order": [[ 1, 'desc' ]],
        language,
        info: false,
        autoWidth: false,
        searching: false,
        scrollY: '250px',
        scrollCollapse: true,
        paging: false,
        initComplete: function (settings, json) {
          $(`#getTrafficDestinationAds_wrapper .dataTables_scrollBody`).perfectScrollbar();
          $(`#getTrafficDestinationAds_wrapper .dataTables_scrollHead table.dataTable`).attr('style', 'margin-top:0!important')
            // .find('thead').addClass('bg-secondary')
            .find('th').each(function (i) { $(this).addClass('border-top-0 border-bottom') });
          $('.getTrafficDestinationAds-container').removeClass('is-loading');
          $('#getTrafficDestinationAds .dataTables_empty').text('').addClass('empty-state');
        }
      }
    )