77 * @link Live demo: https://c2c.mirotalk.com
88 * @license Open source: AGPLv3 | Commercial/closed source (official channel): https://docs.mirotalk.com/sites/c2c/
99 * @author Miroslav Pejic - miroslav.pejic.85@gmail.com
10- * @version 1.4.85
10+ * @version 1.4.86
1111 */
1212
1313const savedTheme = window . localStorage . getItem ( 'home-theme' ) ;
@@ -71,6 +71,7 @@ const maxVideoQualityDiv = document.getElementById('maxVideoQualityDiv');
7171const pushToTalkDiv = document . getElementById ( 'pushToTalkDiv' ) ;
7272const noiseSuppressionDiv = document . getElementById ( 'noiseSuppressionDiv' ) ;
7373const switchLightTheme = document . getElementById ( 'switchLightTheme' ) ;
74+ const switchConvertEmoticons = document . getElementById ( 'switchConvertEmoticons' ) ;
7475const switchNoiseSuppression = document . getElementById ( 'switchNoiseSuppression' ) ;
7576const switchMaxVideoQuality = document . getElementById ( 'switchMaxVideoQuality' ) ;
7677const switchKeepAspectRatio = document . getElementById ( 'switchKeepAspectRatio' ) ;
@@ -180,6 +181,7 @@ const chatInputEmoji = {
180181 ':N' : '🥶' ,
181182 ':J' : '🥴' ,
182183} ;
184+ const chatInputEmoticons = Object . keys ( chatInputEmoji ) . sort ( ( a , b ) => b . length - a . length ) ;
183185
184186const isVideoPIPSupported = document . pictureInPictureEnabled ;
185187const isWebRTCSupported = checkWebRTCSupported ( ) ;
@@ -206,7 +208,6 @@ let isSpaceDown = false;
206208let pushToTalkAudioContext = null ;
207209let isMyAudioActiveBefore = false ;
208210let isMyVideoActiveBefore = false ;
209- let isChatPasteTxt = false ;
210211let noiseProcessor = null ;
211212let noiseSuppressionRequest = 0 ;
212213let noiseSuppressionConstraints = Promise . resolve ( ) ;
@@ -1473,6 +1474,11 @@ function handleEvents() {
14731474 window . localStorage . setItem ( 'home-theme' , theme ) ;
14741475 playSound ( 'switch' ) ;
14751476 } ;
1477+ switchConvertEmoticons . onchange = ( e ) => {
1478+ localStorageConfig . chat . settings . convert_emoticons = e . currentTarget . checked ;
1479+ saveLocalStorageConfig ( ) ;
1480+ playSound ( 'switch' ) ;
1481+ } ;
14761482 //switchMaxVideoQuality.checked = localStorageConfig.video.settings.best_quality;
14771483 switchMaxVideoQuality . onchange = ( e ) => {
14781484 localStorageConfig . video . settings . best_quality = e . currentTarget . checked ;
@@ -1564,18 +1570,15 @@ function handleEvents() {
15641570 chatSendBtn . click ( ) ;
15651571 }
15661572 } ;
1567- chatInput . oninput = function ( ) {
1568- if ( isChatPasteTxt ) return ;
1569- for ( let i in chatInputEmoji ) {
1570- let regex = new RegExp ( i . replace ( / ( [ ( ) [ { * + . $ ^ \\ | ? ] ) / g, '\\$1' ) , 'gim' ) ;
1571- this . value = this . value . replace ( regex , chatInputEmoji [ i ] ) ;
1573+ chatInput . oninput = function ( event ) {
1574+ if ( localStorageConfig . chat . settings . convert_emoticons && event . inputType !== 'insertFromPaste' ) {
1575+ for ( const emoticon of chatInputEmoticons ) {
1576+ const regex = new RegExp ( emoticon . replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) , 'gi' ) ;
1577+ this . value = this . value . replace ( regex , chatInputEmoji [ emoticon ] ) ;
1578+ }
15721579 }
15731580 checkLineBreaks ( ) ;
15741581 } ;
1575- chatInput . onpaste = ( ) => {
1576- isChatPasteTxt = true ;
1577- checkLineBreaks ( ) ;
1578- } ;
15791582 leaveBtn . onclick = ( ) => {
15801583 endCall ( ) ;
15811584 } ;
@@ -2426,6 +2429,7 @@ function loadLocalStorageConfig() {
24262429 audioOutputSource . selectedIndex = localStorageConfig ?. speaker ?. devices ?. select ?. index ?? 0 ;
24272430 }
24282431 switchNoiseSuppression . checked = localStorageConfig ?. audio ?. settings ?. noise_suppression ?? false ;
2432+ switchConvertEmoticons . checked = localStorageConfig . chat . settings . convert_emoticons ;
24292433 switchMaxVideoQuality . checked = localStorageConfig . video . settings . best_quality ;
24302434 switchKeepAspectRatio . checked = localStorageConfig . video . settings . aspect_ratio ;
24312435 screenCameraSelect . value = getScreenCameraPosition ( ) ;
@@ -2943,7 +2947,6 @@ function sendMessage() {
29432947
29442948function emitDcMsg ( msg ) {
29452949 if ( msg ) {
2946- isChatPasteTxt = false ;
29472950 console . log ( 'Send msg: ' + msg ) ;
29482951 appendMessage ( peerName , msg ) ;
29492952 Object . keys ( dataChannels ) . map ( ( peerId ) =>
0 commit comments