12345678910111213141516171819202122232425 |
- const socket = io("http://socketchat.fs.a-level.com.ua/")
- socket.on('msg', msg=>messenger(msg));
- send.onclick = function(){
- socket.emit('msg', {nick: nick.value, message: message.value});
- }
- function messenger(users){
- var chat = document.getElementById('chat');
- var dataInput = document.createElement('p');
- chat.appendChild(dataInput);
- dataInput.style.padding = '8px';
- dataInput.style.margin = '2px 20px';
- dataInput.style.color = 'white';
- dataInput.style.fontWeight = 'bold';
- dataInput.innerText = users.nick + ': ' + users.message;
- if(users.nick === 'Emmanuil'){
- dataInput.style.display = 'flex';
- dataInput.style.flexDirection = 'row-reverse';
- }
- }
|