Skip to content

Commit

Permalink
[mirotalkc2c] - add chat emoji picker
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Oct 8, 2024
1 parent 67f9e3a commit 4a24452
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For private project or commercial purposes contact us at: [email protected] or purchase it directly via Code Canyon:
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
* @author Miroslav Pejic - [email protected]
* @version 1.1.31
* @version 1.1.32
*/

require('dotenv').config();
Expand Down
22 changes: 19 additions & 3 deletions frontend/css/chat.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,21 @@
.chat .footer textarea:focus {
border: 1px solid #439fff;
}
.chat .footer button {
position: absolute;

.chat .footer .buttons {
display: inline;
}

.chat .footer .buttons button {
position: relative;
bottom: 13px;
right: 5px;
border: none;
float: right;
background: transparent;
color: #439fff;
}
.chat .footer button:hover {
.chat .footer .buttons button:hover {
color: var(--text-color);
}

Expand All @@ -119,3 +124,14 @@
.chat .footer textarea::-webkit-scrollbar-thumb {
background: var(--primary-color);
}

.chatEmojiPicker {
position: absolute;
bottom: 0px;
background: var(--chat-bg);
border: var(--border);
border-radius: 5px;
--rgb-background: var(--chat-bg);
--color-border-over: var(--chat-bg);
--font-family: 'Montserrat';
}
7 changes: 6 additions & 1 deletion frontend/html/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/tippy.js/6.3.7/tippy-bundle.umd.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/UAParser.js/1.0.37/ua-parser.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.2.0/crypto-js.min.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/emoji-mart@latest/dist/browser.js"></script>
<script defer src="/socket.io/socket.io.js"></script>
<script defer src="../js/storage.js"></script>
<script defer src="../js/swal.js"></script>
Expand Down Expand Up @@ -154,8 +155,12 @@ <h1>Waiting</h1>
<div class="body" id="chatBody"></div>
<div class="footer">
<textarea id="chatInput" placeholder="Write a message..."></textarea>
<button id="chatSendBtn" class="fas fa-paper-plane"></button>
<div class="buttons">
<button id="chatSendBtn" class="fas fa-paper-plane"></button>
<button id="chatEmojiBtn" class="fas fa-smile"></button>
</div>
</div>
<div id="chatEmoji" class="chatEmojiPicker hidden"></div>
</div>
</body>
</html>
27 changes: 26 additions & 1 deletion frontend/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* @license For private project or commercial purposes contact us at: [email protected] or purchase it directly via Code Canyon:
* @license https://codecanyon.net/item/mirotalk-c2c-webrtc-real-time-cam-2-cam-video-conferences-and-screen-sharing/43383005
* @author Miroslav Pejic - [email protected]
* @version 1.1.31
* @version 1.1.32
*/

const roomId = new URLSearchParams(window.location.search).get('room');
Expand Down Expand Up @@ -50,7 +50,9 @@ const chatOpenBtn = document.getElementById('chatOpenBtn');
const chatBody = document.getElementById('chatBody');
const chatCloseBtn = document.getElementById('chatCloseBtn');
const chatInput = document.getElementById('chatInput');
const chatEmojiBtn = document.getElementById('chatEmojiBtn');
const chatSendBtn = document.getElementById('chatSendBtn');
const chatEmoji = document.getElementById('chatEmoji');

const roomURL = window.location.origin + '/?room=' + roomId;

Expand Down Expand Up @@ -215,6 +217,7 @@ function thereIsPeerConnections() {

document.addEventListener('DOMContentLoaded', function () {
initClient();
handleChatEmojiPicker();
});

function initClient() {
Expand Down Expand Up @@ -885,6 +888,9 @@ function handleEvents() {
chatCloseBtn.onclick = () => {
toggleChat();
};
chatEmojiBtn.onclick = () => {
toggleChatEmoji();
};
chatSendBtn.onclick = () => {
sendMessage();
};
Expand Down Expand Up @@ -1443,6 +1449,25 @@ function toggleChat() {
}
}

function toggleChatEmoji(){
chatEmoji.classList.toggle('show');
}

function handleChatEmojiPicker() {
const pickerOptions = {
theme: 'dark',
perLine: 8,
onEmojiSelect: addEmojiToMsg,
};
const emojiPicker = new EmojiMart.Picker(pickerOptions);
chatEmoji.appendChild(emojiPicker);

function addEmojiToMsg(data) {
chatInput.value += data.native;
toggleChatEmoji();
}
}

function sendMessage() {
console.log(typeof chatInput.value);
if (!chatInput.value) return;
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalkc2c",
"version": "1.1.31",
"version": "1.1.32",
"description": "A free WebRTC Cam-2-Cam browser-based video calls",
"main": "server.js",
"scripts": {
Expand Down Expand Up @@ -40,7 +40,7 @@
"compression": "^1.7.4",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.0",
"express": "^4.21.1",
"express-openid-connect": "^2.17.1",
"js-yaml": "^4.1.0",
"ngrok": "^5.0.0-beta.2",
Expand Down

0 comments on commit 4a24452

Please sign in to comment.