<script src="{{ domainnameport(':3000/socket.io/socket.io.js') }}"></script>
<script src="{{ url('assets/libs/bootstrap/js/bootstrap.bundle.min.js') }}"></script>
<script src="{{ url('assets/js/select2.min.js') }}"></script>
<script>
    $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
    });
</script>

<script>
    //ซ่อน Scroll bar ด้านข้าง
    document.addEventListener("wheel", function(event) {
        if (document.activeElement.type === "number" &&
            document.activeElement.classList.contains("noscroll")) {
            document.activeElement.blur();
        }
    });
</script>


<script>
    let cid = "{{ $cid }}";
    var start_time
    var elasped_time = 0
    var interval_id
    var size_interval_id
    var curr_timer_id
    var is_video1 = false
    var is_video2 = false
    let size1temp = "";
    let counttempsize = 0;
    var socket = io.connect("{{ domainnameport(':3000') }}");
    var old_vdosize = 0
    var new_vdosize = 0
    var time_alert = 0
    var vdo_file_interval = ''
    var all_serial = @json(@$scope_serial);
    var img_storage = localStorage.getItem('imgname')
</script>

<script>
    var audio_casetest = new Audio("{{ domainname('config/sound/capture/alert.mp3') }}");
    var sound_capture = new Audio("{{ domainname('config/sound/capture/shutter.mp3') }}");
    var audio_incorrect = new Audio("{{ domainname('config/sound/capture/incorrect.mp3') }}");
    @if ($type == 'test')
        setTimeout(function() {
            audio_casetest.play();
            setInterval(function() {
                audio_casetest.play();
            }, 13000);
            $('#modal_casetest').modal('show');
        }, 60000);
    @endif


    var operation_date = '{{ @$case->appointment }}'.split(' ')[0].replace(' ', '_')
    // !!! remove space bar from procedure name !!!
    socket.emit('chat message',
        `{"case":"true","cid":"{{ $cid }}","hn":"{{ $hn }}","procedure":"{{ @$case->procedurename . '' }}","operationdate":"${operation_date}","caseuniq":"{{ @$case->caseuniq . '' }}"}`
    );
    socket.emit('chat message', 'get_video_status');
    socket.emit('chat message', `to_page`)

    var url = "{{ $url }}"
    var server = url.replace('endoindex', '')
</script>

<script>
    //Auto start camera
</script>


<script>
    $(window).focus(function() {
        console.log('welcome (back)');
    });

    $(window).blur(function() {
        console.log('bye bye');
    });
</script>

<script language="JavaScript" type="text/javascript">
    window.onbeforeunload = confirmExit;

    function confirmExit() {
        if (check_null('time_end')) {
            let img_num = $("#img_num").html();
            if (img_num > 0) {
                $('#btn_time_4').click()
            }
        }
    }
</script>

<script>
    setTimeout(() => {
        if (check_null('time_start')) {
            $('#btn_time_start').click()
        }
    }, 1 * 1000);

    setTimeout(() => {
        if (check_null('time_patientin')) {
            $('#btn_time_patientin').click()
        }
    }, 1 * 1000);
</script>
