


        $(window).on('load', function() {
            if (feather) {
                feather.replace({
                    width: 14,
                    height: 14
                });
            }
        })
        document.addEventListener('DOMContentLoaded', function() {
          const skypeButton = document.getElementById('skypeButton');
        
          if (skypeButton) {
          const skypeAdd = document.getElementById('skypeButton').innerHTML;
            skypeButton.addEventListener('click', function() {
              const skypeURI = `skype:${skypeAdd}?chat`;
              window.location.href = skypeURI;
            });
          }
        });
        
        var timerID = setInterval(function() {
        now = new Date();
        timezone = now.getTimezoneOffset();
        day = now.getDay();
        hour = now.getUTCHours();
        min = now.getUTCMinutes();
        sec = now.getUTCSeconds();
        ms = now.getUTCMilliseconds();

        displayTime(hour, min, sec, day, "AM", -5, "time-atx", "day-atx");
        }, 1000);

        function displayTime(hour, min, sec, day, meridiem, offset, timeId, dayId) {

        hour = hour + offset;
        if (hour < 0) {
            hour = 24 + hour;
            day--;
        } else if (hour >= 24) {
            hour = hour - 24;
            day++;
        }


        if (hour > 12) {
            hour = hour - 12;
            meridiem = "PM";
        }
        if (hour === 0)
            hour = 12;

        if (hour < 10)
            hour = "0" + hour;
        if (min < 10)
            min = "0" + min;
        if (sec < 10)
            sec = "0" + sec;

        $('#dashHours').html(hour);
        $('#dashMin').html(min);
        $('#dashSec').html(sec);
    }
    


        $(document).ready(function() {
            "use strict"

            let search_btn = $("#search_btn");
            search_btn.click(function(e) {
                e.preventDefault();
                dataListView.draw();
            });
            // init table dom
            let Table = $("table");
            // init list view datatable
            let dataListView = $('.datatables-basic').DataTable({
                "processing": true,
                "serverSide": true,
                "ajax": {
                    "url": "https://trackergenius.runterminal.com/manager/offer/search",
                    "dataType": "json",
                    "type": "POST",
                    "data": {
                        _token: "xVg5vlGiMwfiDk04qzHQhHjes4QkM1yoxS7WeOHB",
                        name: function() {
                            return $("#name").val();
                        },
                        country_id: function() {
                            let country_id = [];
                            $('#country_id option:selected').each(function() {
                                country_id.push($(this).val());
                            });
                            return JSON.stringify(country_id);
                        },
                        device_id: function() {
                            let device_id = [];
                            $('#device_id option:selected').each(function() {
                                device_id.push($(this).val());
                            });
                            return JSON.stringify(device_id);
                        },
                        category_id: function() {
                            let category_id = [];
                            $('#category_id option:selected').each(function() {
                                category_id.push($(this).val());
                            });
                            return JSON.stringify(category_id);
                        },
                    }
                },
                "columns": [{
                        "data": 'id',
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "o_id"
                    },
                    {
                        "data": "o_id"
                    },
                    {
                        "data": "country",
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "avater",
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "name",
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "category",
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "device",
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "payout",
                        orderable: false,
                        searchable: false
                    },
                    {
                        "data": "action",
                        orderable: false,
                        searchable: false
                    }
                ],

                searchDelay: 1500,
                columnDefs: [{
                        // For Responsive
                        className: 'control',
                        orderable: false,
                        responsivePriority: 1,
                        targets: 0
                    },
                    {
                        // For Checkboxes
                        targets: 1,
                        orderable: false,
                        responsivePriority: 3,
                        render: function(data) {
                            return (
                                '<div style="display: none" class="form-check"> <input class="form-check-input dt-checkboxes" type="checkbox" value="" id="' +
                                data +
                                '" /><label class="form-check-label" for="' +
                                data +
                                '"></label></div>'
                            );
                        },
                        checkboxes: {
                            selectAllRender: '<div style="display: none" class="form-check"> <input class="form-check-input" type="checkbox" value="" id="checkboxSelectAll" /><label class="form-check-label" for="checkboxSelectAll"></label></div>',
                            selectRow: true
                        }
                    },
                    {
                        targets: 2,
                        visible: false
                    },
                    {
                        // Actions
                        targets:4 ,
                        title: 'Image',
                        orderable: false,
                        render: function(data, type, full) {
                            return (
                                '<img src="'+ full['avatar'] +'"  alt="" style="height: 50px;">'
                            );
                        }
                    },
                    // {
                    //     // Avatar image/badge, Name and post
                    //     targets: 3,
                    //     responsivePriority: 1,
                    //     render: function(data, type, full) {
                    //         var $user_img = full['avatar'],
                    //             $name = full['name'],
                    //             $id = full['o_id'],
                    //             $status = full['status'];
                    //         if ($user_img) {
                    //             // For Avatar image
                    //             var $output =
                    //                 '<img src="' + $user_img +
                    //                 '" alt="Avatar" width="32" height="32">';
                    //         } else {
                    //             // For Avatar badge
                    //             var stateNum = full['status'];
                    //             var states = ['success', 'danger', 'warning', 'info', 'dark',
                    //                 'primary', 'secondary'
                    //             ];
                    //             var $state = states[stateNum],
                    //                 $name = full['name'],
                    //                 $id = full['o_id'],
                    //                 $initials = $name.match(/\b\w/g) || [];
                    //             $initials = (($initials.shift() || '') + ($initials.pop() || ''))
                    //                 .toUpperCase();
                    //             $output = '<span class="avatar-content">' + $initials + '</span>';
                    //         }

                    //         var colorClass = $user_img === '' ? ' bg-light-' + $state + ' ' : '';
                    //         // Creates full output for row
                    //         return '<div class="d-flex justify-content-left align-items-center">' +
                    //             '<div class="avatar ' +
                    //             colorClass +
                    //             ' me-1">' +
                    //             $output +
                    //             '</div>' +
                    //             '<div class="d-flex flex-column">' +
                    //             '<span class="emp_name text-truncate fw-bold">' +
                    //             '(' + $id + ')' + $name +
                    //             '</span>' +
                    //             '<small class="emp_post text-truncate text-muted">' +
                    //             $status +
                    //             '</small>' +
                    //             '</div>' +
                    //             '</div>';
                    //     }
                    // },
                    {
                        // Actions
                        targets: -1,
                        title: 'Action',
                        orderable: false,
                        render: function(data, type, full) {
                            return (
                                '<span class="d-flex">' +
                                '<a href="' + full['show'] +
                                '" class="text-success" style="margin-left: 10px" data-bs-toggle="tooltip" data-bs-placement="top" title="' +
                                "Show" + '">' +
                                feather.icons['eye'].toSvg({
                                    class: 'font-medium-4'
                                }) +
                                '</a>' +
                                '</span>'
                            );
                        }
                    }
                ],
                dom: '<"d-flex justify-content-between align-items-center mx-0 row"<"col-sm-12 col-md-6"l><"col-sm-12 col-md-6"f>>t<"d-flex justify-content-between mx-0 row"<"col-sm-12 col-md-6 mb-2"i><"col-sm-12 col-md-6"p>>',
                aLengthMenu: [
                    [10, 20, 50, 100],
                    [10, 20, 50, 100]
                ],
                select: {
                    style: "multi"
                },
                order: [
                    [2, "desc"]
                ],
                displayLength: 10,
            });

            // Select2 basic
            $(".select2").each(function() {
                let $this = $(this);
                $this.wrap('<div class="position-relative"></div>');
                $this.select2({
                    // the following code is used to disable x-scrollbar when click in select input and
                    // take 100% width in responsive also
                    dropdownAutoWidth: true,
                    width: '100%',
                    dropdownParent: $this.parent(),
                    placeholder: 'Choose One'
                });
            });

            // Select2 multiple
            $(".select2-multiple").each(function() {
                let $this = $(this);
                $this.wrap('<div class="position-relative"></div>');
                $this.select2({
                    // the following code is used to disable x-scrollbar when click in select input and
                    // take 100% width in responsive also
                    dropdownAutoWidth: true,
                    width: '100%',
                    dropdownParent: $this.parent(),
                    placeholder: 'Select Manager'
                });
            });

            // filter
        });
    