Skip to content

Commit

Permalink
Added a few missing comments and fixed Grammar.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnymast committed Apr 25, 2020
1 parent 34b75be commit e45b6fd
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CHANELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
This release will be more about helping developers with useful boiler plate functions. This will assist them
to create a new project from this one quickly.

- Cleaned up the code acording to PSR1 and PSR2
- Fixed some grammar issues
- Cleaned up the code according to PSR1 and PSR2
- Added GitHub Actions
- Added checks for css via stylelint
- Added javascript checks via eslint
Expand Down
1 change: 0 additions & 1 deletion _config.yml

This file was deleted.

3 changes: 2 additions & 1 deletion includes/classes/Chat.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
<?php /** @noinspection PhpUndefinedFieldInspection */

/**
* Chat.php
*
Expand Down
3 changes: 2 additions & 1 deletion public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">


<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Websocket chat example using jquery + php + mysql">
<meta name="author" content="Johnny Mast">
Expand All @@ -43,7 +44,7 @@
let socketPort = '<?php print WEBSOCKET_SERVER_PORT ?>';

/**
* Also when your script is live make shure this user object
* Also when your script is live make sure this user object
* doest not show to much information. Like for example passwords
* should be excluded. Add only the information you need on the server
* for this user.
Expand Down
30 changes: 25 additions & 5 deletions public/js/websockets.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
/* eslint-disable no-undef */
/**
* For more information about the protocol you can read to protocol information
* document at our wiki.
*
* @see {@link https://github.com/johnnymast/mysql_websocket_chat/wiki/Protocol|GitHub}
*/

const RECONNECT_IN_SEC = 10
const ws = {
/**
Expand All @@ -12,7 +19,7 @@ const ws = {
* Handle automatically reconnecting to a websocket server
* if the connection was interrupted.
*
* @param {function} callback -
* @param {function} callback - The callback called upon reconnection
*/
WebSocket.prototype.reconnect = (callback) => {
if (this.readyState === WebSocket.OPEN || this.readyState !== WebSocket.CONNECTING) {
Expand All @@ -31,6 +38,9 @@ WebSocket.prototype.reconnect = (callback) => {
}, 1000)
}

/**
* Connect to the websocket server.
*/
const connect = () => {
if (ws.conn) {
if (ws.conn.readyState === WebSocket.OPEN || ws.conn.readyState === WebSocket.CONNECTING) {
Expand Down Expand Up @@ -112,10 +122,6 @@ const connect = () => {
}
}

const userList = dom('.user_list').get()

document.addEventListener('DOMContentLoaded', connect)

/**
* Remove all users from the users on the
* side of the screen.
Expand Down Expand Up @@ -190,6 +196,11 @@ usersOutput = (users) => {
}
}

/**
* Display a message on the screen indicating some is typing a message.
*
* @param {object} pkg - The received package from the server
*/
typingOutput = (pkg) => {
if (typeof pkg === 'object') {
const user = pkg.user
Expand Down Expand Up @@ -271,6 +282,11 @@ requestUserlist = () => {
}, 2000)
}

/**
* Register user is typing yes or no.
*
* @param {boolean} currently - Is this user currently typing?
*/
registerTyping = (currently) => {
/**
* Create a package to send to the
Expand Down Expand Up @@ -375,4 +391,8 @@ sendMessage = () => {
*/
dom('.client_chat').val('')
}

const userList = dom('.user_list').get()

document.addEventListener('DOMContentLoaded', connect)
/* eslint-enable no-undef */

0 comments on commit e45b6fd

Please sign in to comment.