Skip to content

Commit e45b6fd

Browse files
committed
Added a few missing comments and fixed Grammar.
1 parent 34b75be commit e45b6fd

File tree

5 files changed

+31
-9
lines changed

5 files changed

+31
-9
lines changed

CHANELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
This release will be more about helping developers with useful boiler plate functions. This will assist them
44
to create a new project from this one quickly.
55

6-
- Cleaned up the code acording to PSR1 and PSR2
6+
- Fixed some grammar issues
7+
- Cleaned up the code according to PSR1 and PSR2
78
- Added GitHub Actions
89
- Added checks for css via stylelint
910
- Added javascript checks via eslint

_config.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

includes/classes/Chat.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
<?php
1+
<?php /** @noinspection PhpUndefinedFieldInspection */
2+
23
/**
34
* Chat.php
45
*

public/index.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<meta http-equiv="X-UA-Compatible" content="IE=edge">
2020
<meta name="viewport" content="width=device-width, initial-scale=1">
2121

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

4546
/**
46-
* Also when your script is live make shure this user object
47+
* Also when your script is live make sure this user object
4748
* doest not show to much information. Like for example passwords
4849
* should be excluded. Add only the information you need on the server
4950
* for this user.

public/js/websockets.js

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
/* eslint-disable no-undef */
2+
/**
3+
* For more information about the protocol you can read to protocol information
4+
* document at our wiki.
5+
*
6+
* @see {@link https://github.com/johnnymast/mysql_websocket_chat/wiki/Protocol|GitHub}
7+
*/
8+
29
const RECONNECT_IN_SEC = 10
310
const ws = {
411
/**
@@ -12,7 +19,7 @@ const ws = {
1219
* Handle automatically reconnecting to a websocket server
1320
* if the connection was interrupted.
1421
*
15-
* @param {function} callback -
22+
* @param {function} callback - The callback called upon reconnection
1623
*/
1724
WebSocket.prototype.reconnect = (callback) => {
1825
if (this.readyState === WebSocket.OPEN || this.readyState !== WebSocket.CONNECTING) {
@@ -31,6 +38,9 @@ WebSocket.prototype.reconnect = (callback) => {
3138
}, 1000)
3239
}
3340

41+
/**
42+
* Connect to the websocket server.
43+
*/
3444
const connect = () => {
3545
if (ws.conn) {
3646
if (ws.conn.readyState === WebSocket.OPEN || ws.conn.readyState === WebSocket.CONNECTING) {
@@ -112,10 +122,6 @@ const connect = () => {
112122
}
113123
}
114124

115-
const userList = dom('.user_list').get()
116-
117-
document.addEventListener('DOMContentLoaded', connect)
118-
119125
/**
120126
* Remove all users from the users on the
121127
* side of the screen.
@@ -190,6 +196,11 @@ usersOutput = (users) => {
190196
}
191197
}
192198

199+
/**
200+
* Display a message on the screen indicating some is typing a message.
201+
*
202+
* @param {object} pkg - The received package from the server
203+
*/
193204
typingOutput = (pkg) => {
194205
if (typeof pkg === 'object') {
195206
const user = pkg.user
@@ -271,6 +282,11 @@ requestUserlist = () => {
271282
}, 2000)
272283
}
273284

285+
/**
286+
* Register user is typing yes or no.
287+
*
288+
* @param {boolean} currently - Is this user currently typing?
289+
*/
274290
registerTyping = (currently) => {
275291
/**
276292
* Create a package to send to the
@@ -375,4 +391,8 @@ sendMessage = () => {
375391
*/
376392
dom('.client_chat').val('')
377393
}
394+
395+
const userList = dom('.user_list').get()
396+
397+
document.addEventListener('DOMContentLoaded', connect)
378398
/* eslint-enable no-undef */

0 commit comments

Comments
 (0)