text: window.addEventListener('load', function () {
      let selectedDeviceId;
      const codeReader = new ZXing.BrowserMultiFormatReader()
      console.log('ZXing code reader initialized')
      codeReader.listVideoInputDevices()
        .then((videoInputDevices) => {
          const sourceSelect = document.getElementById('sourceSelect')
          selectedDeviceId = videoInputDevices[0].deviceId
          if (videoInputDevices.length >= 1) {
            videoInputDevices.forEach((element) => {
              const sourceOption = document.createElement('option')
              sourceOption.text = element.label
              sourceOption.value = element.deviceId
              sourceSelect.appendChild(sourceOption)
            })
    
            sourceSelect.onchange = () => {
              selectedDeviceId = sourceSelect.value;
            };
    
            const sourceSelectPanel = document.getElementById('sourceSelectPanel')
            sourceSelectPanel.style.display = 'block'
          }
    
          document.getElementById('startButton').addEventListener('click', () => {
            codeReader.decodeFromVideoDevice(selectedDeviceId, 'video', (result, err) => {
              if (result) {
              $('.modal').modal('hide');
              codeReader.reset()
                console.log(result)
                document.getElementById('result').textContent = result.text
    
            //menambhakan Nama Toko        
              var id_toko = document.getElementById('result').innerHTML;
              console.log(id_toko);
              var token = $('meta[name="csrf-token"]').attr('content');
              $.ajax({
                type: 'POST',
                headers: {
                    'X-CSRF-TOKEN': token
                },
                url: '/Toko/req-nama-toko',
                data: {id : id_toko},
                dataType: 'json',
                success: function(data){
                  // console.log(data.NAMA_TOKO);
                  // console.log(data.LATITUDE);
                  // console.log(data.LONGITUDE);
                  // console.log(data.ACURACY);
                  // document.getElementById('nama').val(data.data[0].NAMA_BARANG);
                  $('#nama').html(data.data[0].NAMA_TOKO);
                  $('#lat').html(data.data[0].LATITUDE);
                  $('#long').html(data.data[0].LONGITUDE);
                  $('#acc').html(data.data[0].ACURACY);
  
                }
              });
            // selesai
    
              }
              if (err && !(err instanceof ZXing.NotFoundException)) {
                console.error(err)
                document.getElementById('result').textContent = err
              }
            })
            console.log(`Started continous decode from camera with id ${selectedDeviceId}`)
          })
    
          document.getElementById('resetButton').addEventListener('click', () => {
            codeReader.reset()
            document.getElementById('nama').textContent = '';
            document.getElementById('lat').textContent = '';
            document.getElementById('long').textContent = '';
            document.getElementById('acc').textContent = '';
            document.getElementById('result').textContent = '';
            console.log('Reset.')
          })
    
        })
        .catch((err) => {
          console.error(err)
        })
    })
    