From e45b6fd1b54730ed709712788978d967d2831278 Mon Sep 17 00:00:00 2001 From: Johnny Mast Date: Sat, 25 Apr 2020 21:03:47 +0200 Subject: [PATCH] Added a few missing comments and fixed Grammar. --- CHANELOG.md | 3 ++- _config.yml | 1 - includes/classes/Chat.php | 3 ++- public/index.php | 3 ++- public/js/websockets.js | 30 +++++++++++++++++++++++++----- 5 files changed, 31 insertions(+), 9 deletions(-) delete mode 100644 _config.yml diff --git a/CHANELOG.md b/CHANELOG.md index 6dbeed9..0f10ac0 100644 --- a/CHANELOG.md +++ b/CHANELOG.md @@ -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 diff --git a/_config.yml b/_config.yml deleted file mode 100644 index 2f7efbe..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-minimal \ No newline at end of file diff --git a/includes/classes/Chat.php b/includes/classes/Chat.php index 68981bb..f4a5c71 100644 --- a/includes/classes/Chat.php +++ b/includes/classes/Chat.php @@ -1,4 +1,5 @@ - + @@ -43,7 +44,7 @@ let socketPort = ''; /** - * 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. diff --git a/public/js/websockets.js b/public/js/websockets.js index 4ade67d..ddef6cc 100644 --- a/public/js/websockets.js +++ b/public/js/websockets.js @@ -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 = { /** @@ -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) { @@ -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) { @@ -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. @@ -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 @@ -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 @@ -375,4 +391,8 @@ sendMessage = () => { */ dom('.client_chat').val('') } + +const userList = dom('.user_list').get() + +document.addEventListener('DOMContentLoaded', connect) /* eslint-enable no-undef */