PHP Classes
elePHPant
Icontem

File: js/interface.js

Recommend this page to a friend!
  Classes of Johnny Mast  >  PHP MySQL Websocket Chat  >  js/interface.js  >  Download  
File: 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: I think i fixed the dependenty on jquery still have to test it...
Started working on removing jquery
Date: 1 year ago
Size: 676 bytes
 

 

Contents

Class file image Download
document.addEventListener("DOMContentLoaded", function(event) {

  /***
   * 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()

  /**
   * Just to make it feel like a real chat.
   * Send the message if enter has been pressed.
   */
  dom('.client_chat').on('keypress', function (evt) {
    if (evt.keyCode === 13) {
      send_message()
    }
  })

  /**
   * Submit has been pressed execute sending
   * to server.
   */
  dom('.btn-send.chat_btn').on('click', function () {
    send_message()
  })
});