PHP Classes

File: public/js/interface.js

Recommend this page to a friend!
  Classes of Johnny Mast   PHP MySQL WebSocket Chat   public/js/interface.js   Download  
File: public/js/interface.js
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: PHP MySQL WebSocket Chat
Websocket chat that stores messages in MySQL
Author: By
Last change: Update of public/js/interface.js
Date: 1 year ago
Size: 1,261 bytes
 

Contents

Class file image Download
/* eslint-disable no-undef */ document.addEventListener('DOMContentLoaded', () => { const setChatTarget = (target) => { if (!target) { target = 'Channel' } dom('.chat_target').text(target) } /*** * This is more like a confidence setup * for the interface. It does not really help * with the chat functionality. */ /** * Before we start hide the error * message. */ dom('.connection_alert').hide() dom('.client_chat').on('keyup', (evt) => { if (evt.target.value.length > 0) { registerTyping(true) } else { registerTyping(false) } }) /** * Just to make it feel like a real chat. * Send the message if enter has been pressed. */ dom('.client_chat').on('keypress', (evt) => { if (evt.key === 'Enter') { sendMessage() } }) dom('.user_list').on('change', (evt) => { const list = evt.target let to = null if (list.selectedIndex >= 0) { to = list.options[list.selectedIndex].text } setChatTarget(to) }) /** * Submit has been pressed execute sending * to server. */ dom('.btn-send.chat_btn').on('click', () => { sendMessage() registerTyping(false) }) setChatTarget() }) /* eslint-enable no-undef */