var webmasterid=13326;(function() { document.getElementsByTagName("head")[0].insertAdjacentHTML( 'beforeend', "" ); document.getElementsByTagName("head")[0].insertAdjacentHTML( 'beforeend', "" ); displayPerformers(webmasterid); })(); function displayPerformers(webmasterid) { console.log('webmasterid', webmasterid); var url = `https://www.html5-chat.com/ajax.php`; var fd = new FormData(); fd.append('a', 'getPerformers'); fd.append('webmasterid', webmasterid); var xhr = new XMLHttpRequest(); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { var performers = JSON.parse(xhr.response); var performersContainerDiv = document.createElement("div"); performersContainerDiv.className = "performerTileContainer"; var aBlock = document.body.appendChild(performersContainerDiv); performers.forEach(function(performer) { var el = `

${performer.country} ${performer.username} ${performer.years}

 ${performer.description}
`; performersContainerDiv.insertAdjacentHTML('beforeend', el); }); addClickEvents(); getOnlinePerformers(); window.onlineTimer = setInterval(function() { getOnlinePerformers(); }, 15000); } } xhr.open('POST', url); xhr.send(fd); } function getOnlinePerformers() { var url = `https://chat.html5-chat.com:8009/getOnlinePerformers/${webmasterid}/999`; fetch(url) .then(function (response) { response.json().then(function(performers) { console.log(performers); var selections = document.querySelectorAll("[data-performerid]"); for (let i = 0; i < selections.length; i++) { selections[i].classList.remove('offline'); selections[i].classList.remove('busy'); selections[i].classList.remove('online'); selections[i].classList.add('offline'); } performers.forEach(function (performer) { console.log(performer.username, performer.status); var temp = `[data-performerid='${performer.id}']`; document.querySelector(temp).classList.add(performer.status); }); }); }); } function addClickEvents() { var buttons = document.querySelectorAll('[data-performerid]'); for (const button of buttons) { button.addEventListener('click', function(event) { var performerid = this.getAttribute('data-performerid'); clearInterval(window.onlineTimer); document.body.innerHTML = ''; var iframe = document.createElement('iframe'); var startRoom = parseInt(webmasterid * 10000) + parseInt(performerid); var url = (typeof jwt!=='undefined')?`https://www.html5-chat.com/ppv_user/${webmasterid}/${jwt}/${performerid}`:`https://www.html5-chat.com/chat2/${webmasterid}/?startRoom=${startRoom}`; iframe.src = url; document.body.appendChild(iframe); }) } }