const img = '//img.new-combats.com/i'; const gett = async () => { let response = await fetch('/api/onlinelist.php'); if (response.ok) { document.getElementById('onlinelist').innerHTML = ''; const list = await response.json(); list.forEach((user) => { console.log(user); document.getElementById('onlinelist').insertAdjacentHTML('beforeend', `${ol.makelogin(user)}
`); }); } else { document.getElementById('onlinelist').insertAdjacentHTML('beforeend', `Все ушли.
`); } }; window.addEventListener('load', () => { const fetchInterval = 10000; // 10 секунд. gett; //(get)(); // почему get; или get(); - неправильно?? 🤬😭 setInterval(gett, fetchInterval); }); ol = { tochat (login) { const input = document.getElementById('tochat'); if (input.value === `private [${login}]`) { return; } if (input.value === `to [${login}]`) { input.value = `private [${login}]`; return; } input.value = `to [${login}]`; }, makelogin ({id, login, level, align, clan, inbattle, isadmin}) { let style = ''; if (isadmin) { //align = 2.9; style = `color: crimson;`; } if (!level || level < 0 || level > 21 && !isadmin || typeof level !== 'number') { level = '??'; } let inficon = `Информация про ${login}`; let html = `${login}[${level}]` + inficon; if (clan) { html = `Клан ` + html; } if (align) { html = `Склонность ` + html; } let battleyes = '', battlealt = ''; if (inbattle) { battleyes = 1; battlealt = ' (персонаж в поединке)' } html = `Приват${battlealt}` + html; return html; } };