diff --git a/public/js/client.js b/public/js/client.js index e42ab0b2..e5a86f1d 100644 --- a/public/js/client.js +++ b/public/js/client.js @@ -337,6 +337,7 @@ const msgerCP = getId('msgerCP'); const msgerCPHeader = getId('msgerCPHeader'); const msgerCPCloseBtn = getId('msgerCPCloseBtn'); const msgerCPList = getId('msgerCPList'); +const searchPeerBarName = getId('searchPeerBarName'); // Caption section const captionDraggable = getId('captionDraggable'); @@ -1079,6 +1080,13 @@ function countPeerConnections() { return Object.keys(peerConnections).length; } +/** + * Get Started... + */ +document.addEventListener('DOMContentLoaded', function () { + initClientPeer(); +}); + /** * On body load Get started */ @@ -1395,6 +1403,18 @@ async function whoAreYou() { playSound('newMessage'); + // init buttons click events + + initVideoBtn.onclick = async (e) => { + await handleVideo(e, true); + }; + initAudioBtn.onclick = (e) => { + handleAudio(e, true); + }; + initVideoMirrorBtn.onclick = (e) => { + toggleInitVideoMirror(); + }; + await loadLocalStorage(); if (!useVideo || !buttons.main.showVideoBtn) { @@ -4297,6 +4317,11 @@ function setChatRoomBtn() { // adapt chat room size for mobile setChatRoomAndCaptionForMobile(); + // Search peer by name + searchPeerBarName.addEventListener('keyup', () => { + searchPeer(); + }); + // open hide chat room chatRoomBtn.addEventListener('click', (e) => { if (!isChatRoomVisible) { diff --git a/public/js/common.js b/public/js/common.js index 082ce0b5..18b79292 100644 --- a/public/js/common.js +++ b/public/js/common.js @@ -130,14 +130,6 @@ noun = noun.charAt(0).toUpperCase() + noun.substring(1); adjective = adjective.charAt(0).toUpperCase() + adjective.substring(1); document.getElementById('roomName').value = ''; -// Typing Effect - -let i = 0; -let txt = num + adjective + noun; -let speed = 100; - -typeWriter(); - /** * Get random number * @param {integer} length of string @@ -153,6 +145,12 @@ function getRandomNumber(length) { return result; } +// Typing Effect + +let i = 0; +let txt = num + adjective + noun; +let speed = 100; + /** * Set room name with typewriter effect */ @@ -164,9 +162,10 @@ function typeWriter() { } } +typeWriter(); // #################################################################### -// LANDING | NEW CALL +// LANDING | NEW CALL // #################################################################### const lastRoomContainer = document.getElementById('lastRoomContainer'); @@ -183,15 +182,15 @@ const joinRoomButton = document.getElementById('joinRoomButton'); const adultCnt = document.getElementById('adultCnt'); genRoomButton.onclick = (e) => { - genRoom(); + genRoom(); }; joinRoomButton.onclick = (e) => { - joinRoom(); + joinRoom(); }; adultCnt.onclick = (e) => { - adultContent(); + adultContent(); }; document.getElementById('roomName').onkeyup = (e) => { @@ -240,7 +239,7 @@ const room_id = filterXSS(qs.get('room_id')); const message = filterXSS(qs.get('message')); const showMessage = document.getElementById('message'); console.log('Allow Camera or Audio', { - room_id: room_id, - message: message, + room_id: room_id, + message: message, }); -if (showMessage) showMessage.innerHTML = message; \ No newline at end of file +if (showMessage) showMessage.innerHTML = message; diff --git a/public/js/testStunTurn.js b/public/js/testStunTurn.js index 92749593..e7712fde 100644 --- a/public/js/testStunTurn.js +++ b/public/js/testStunTurn.js @@ -11,22 +11,22 @@ const qs = new URLSearchParams(window.location.search); let iceServers = filterXSS(qs.get('iceServers')); if (iceServers) { - iceServers = JSON.parse(iceServers); + iceServers = JSON.parse(iceServers); } else { - // http://localhost:3000/test - iceServers = [ - // Test some STUN server - { - urls: 'stun:stun.l.google.com:19302', - }, - // Test some TURN server - // https://www.metered.ca/tools/openrelay/ - { - urls: 'turn:a.relay.metered.ca:443', - username: 'e8dd65b92c62d3e36cafb807', - credential: 'uWdWNmkhvyqTEswO', - }, - ]; + // http://localhost:3000/test + iceServers = [ + // Test some STUN server + { + urls: 'stun:stun.l.google.com:19302', + }, + // Test some TURN server + // https://www.metered.ca/tools/openrelay/ + { + urls: 'turn:a.relay.metered.ca:443', + username: 'e8dd65b92c62d3e36cafb807', + credential: 'uWdWNmkhvyqTEswO', + }, + ]; } console.log('Check Ice Servers', iceServers); @@ -36,32 +36,32 @@ Ice.innerText = JSON.stringify(iceServers, null, 4); // Test the connections const pc = new RTCPeerConnection({ - iceServers, + iceServers, }); pc.onicecandidate = (e) => { - if (!e.candidate) return; + if (!e.candidate) return; - console.log(e.candidate.candidate); + console.log(e.candidate.candidate); - // If a srflx candidate was found, notify that the STUN server works! - if (e.candidate.type == 'srflx' || e.candidate.candidate.includes('srflx')) { - let ip = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/; - let address = e.candidate.address ? e.candidate.address : e.candidate.candidate.match(ip); - IP.innerText = '🟢 Your Public IP Address is ' + address; - Stun.innerText = '🟢 The STUN server is reachable!'; - } + // If a srflx candidate was found, notify that the STUN server works! + if (e.candidate.type == 'srflx' || e.candidate.candidate.includes('srflx')) { + let ip = /\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b/; + let address = e.candidate.address ? e.candidate.address : e.candidate.candidate.match(ip); + IP.innerText = '🟢 Your Public IP Address is ' + address; + Stun.innerText = '🟢 The STUN server is reachable!'; + } - // If a relay candidate was found, notify that the TURN server works! - if (e.candidate.type == 'relay' || e.candidate.candidate.includes('relay')) { - Turn.innerText = '🟢 The TURN server is reachable!'; - } + // If a relay candidate was found, notify that the TURN server works! + if (e.candidate.type == 'relay' || e.candidate.candidate.includes('relay')) { + Turn.innerText = '🟢 The TURN server is reachable!'; + } }; // handle error pc.onicecandidateerror = (e) => { - console.error(e); - Err.innerText = '⚠️ ' + e.errorText; + console.error(e); + Err.innerText = '⚠️ ' + e.errorText; }; pc.createDataChannel('test'); diff --git a/public/views/client.html b/public/views/client.html index da8b9016..eab4132d 100755 --- a/public/views/client.html +++ b/public/views/client.html @@ -66,7 +66,7 @@ - + @@ -101,14 +101,10 @@ access to use this app. >
- - + + - + @@ -233,7 +229,6 @@ access to use this app. placeholder=" 🔍 Search peer by name..." maxlength="32" name="search" - onkeyup="searchPeer()" />

diff --git a/public/views/landing.html b/public/views/landing.html index e214d3a4..2d319c25 100755 --- a/public/views/landing.html +++ b/public/views/landing.html @@ -134,10 +134,7 @@ id="genRoomButton" class="button button-primary br-6 mr-8 mb-8 fas fa-arrows-rotate" > - diff --git a/public/views/newcall.html b/public/views/newcall.html index 6ddf2a4c..2f18fb17 100755 --- a/public/views/newcall.html +++ b/public/views/newcall.html @@ -128,10 +128,7 @@ id="genRoomButton" class="button button-primary br-6 mr-8 mb-8 fas fa-arrows-rotate" > -