text: 
  const socket = io.connect('', {
      'forceNew': true,
      'reconnection': false
  });
  socket.on('disconnect', () => {
      setTimeout(() => {
          alert("Потеряно соединение с сервером.");
          document.location.reload();
      }, 2000);
  });
  
  const userlog = window.location.href.split('/')[4];
  socket.emit('take_user', userlog);
  
  async function do_test()
  {
      window.open(`/apprentice_do_test/${userlog}`, "_self");
  }
  async function start_theory()
  {
      window.open(`/apprentice_theory/${userlog}`, "_self");
  }
  async function out_to_init() {
      if (confirm("Вы точно хотите выйти?"))
      {
          window.open("/init", "_self");
      }
  }
  
  socket.on('set_stat_from_data', (data) => {
      document.getElementById('howmany_tests').innerHTML += data['kol_n'];
      document.getElementById('howmany_esc_tests').innerHTML += data['kol_e'];
  });
  socket.on('set_balls_from_data', (data) => {
      document.getElementById('max_ball').innerHTML += (data['MAX']*100);
      document.getElementById('min_ball').innerHTML += (data['MIN']*100);
      document.getElementById('sred_ball').innerHTML += (data['SRED']*100);
  });
  
  // добавляем строку со статистикой
  socket.on('addTestRow', (data) => {
  	addTestRow(data['idтест'], data['лог_создатель'], data['отношение'], data['баллы']);
  });
  
  async function addTestRow(id, creator_log, attitude, balls)
  {
  	let tbody = document.getElementById("table_of_stat_of_tests").getElementsByTagName("TBODY")[0];
      let row = document.createElement("TR");
  
      let td_id = document.createElement("TD");
      row.appendChild(td_id);
  
      let td_creator_log = document.createElement("TD");
      row.appendChild(td_creator_log);
  
      let td_attitude = document.createElement("TD");
      row.appendChild(td_attitude);
  
      let td_balls = document.createElement("TD");
      row.appendChild(td_balls);
  
      tbody.appendChild(row);
  
      td_id.innerHTML = id;
      td_creator_log.innerHTML = creator_log;
      td_attitude.innerHTML = attitude;
      td_balls.innerHTML = balls;
  }
  
  async function get_main_stat()
  {
      socket.emit('get_stat', userlog);
  }
  async function get_balls()
  {
      socket.emit('get_balls', userlog);
  }
  
  // как только документ прогрузится вызвать эти функции
  document.addEventListener("DOMContentLoaded", function (event)
  {
  	get_main_stat();
  	get_balls();
      document.getElementById('do_test').addEventListener('click', () => do_test());
      document.getElementById('start_theory').addEventListener('click', () => start_theory());
      document.getElementById('out_to_init').addEventListener('click', () => out_to_init());
  });