/******/ (() => { // webpackBootstrap /******/ var __webpack_modules__ = ({ /***/ "./src/chat/chat.js": /*!**************************!*\ !*** ./src/chat/chat.js ***! \**************************/ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { /* Licensed under the Apache License, Version 2.0 (the "License") http://www.apache.org/licenses/LICENSE-2.0 */ const OmUtil = __webpack_require__(/*! ../main/omutils */ "../main/omutils"); const Settings = __webpack_require__(/*! ../main/settings */ "../main/settings"); const CSSEmoticon = __webpack_require__(/*! ./cssemoticons */ "./src/chat/cssemoticons.js"); const msgIdPrefix = 'chat-msg-id-' , closedSize = 20 , closedSizePx = closedSize + "px" , doneTypingInterval = 5000 //time in ms, 5 second for example , SEND_ENTER = 'enter', SEND_CTRL = 'ctrl' , audio = new Audio('./public/chat_message.mp3') ; let chatPanel, ctrlBlk, tabs, openedHeight = "345px", openedWidth = "300px", allPrefix = "All" , roomPrefix = "Room ", typingTimer, roomMode = false , editor = $('#chatMessage .wysiwyg-editor'), muted = false, sendOn, DEF_SEND , userId, inited = false, newMsgNotification ; function __setCssVar(key, _val) { const val = ('' + _val).endsWith('px') ? _val : _val + 'px'; if (roomMode) { if (typeof(Room) == 'object' && typeof(Room.setCssVar) === 'function') { Room.setCssVar(key, val); } } else { OmUtil.setCssVar(key, val); } } function __setCssWidth(val) { __setCssVar('--chat-width', val) } function __setCssHeight(val) { __setCssVar('--chat-height', val) } function _load() { const s = Settings.load(); if (typeof(s.chat) === 'undefined') { s.chat = { muted: false , sendOn: DEF_SEND }; Settings.save(s) } muted = s.chat.muted === true; sendOn = s.chat.sendOn === SEND_ENTER ? SEND_ENTER : SEND_CTRL; return s; } function _updateAudioBtn() { const btn = $('#chat .audio'); btn.removeClass('sound' + (muted ? '' : '-mute')).addClass('sound' + (muted ? '-mute' : '')) .attr('title', btn.data(muted ? 'sound-enabled' : 'sound-muted')); } function _updateSendBtn() { const btn = $('#chat .send-btn') , ctrl = sendOn === SEND_CTRL; if (ctrl) { btn.addClass('send-ctrl'); editor.off('keydown', _sendOnEnter).keydown('Ctrl+return', _sendOnEnter); } else { btn.removeClass('send-ctrl'); editor.off('keydown', _sendOnEnter).keydown('return', _sendOnEnter); } btn.attr('title', btn.data(ctrl ? 'send-ctrl' : 'send-enter')); } function _sendOnEnter() { $('#chat .send').trigger('click'); } function doneTyping () { typingTimer = null; chatActivity('typing_stop', $('.room-block .room-container').data('room-id')); } function _emtClick() { _editorAppend($(this).data('emt')); } function initToolbar() { const emots = CSSEmoticon.emoticons; const rowSize = 20, emotMenuList = $('#emotMenuList'); emotMenuList.html(''); let row; for (let i = 0; i < emots.length; ++i) { if (i % rowSize === 0) { row = $(''); emotMenuList.append(row); } row.append($('').append( $('
').addClass('emt').html(CSSEmoticon.emoticonize(emots[i])) .data('emt', emots[i]).click(_emtClick) )); } const emtBtn = $('#emoticons'); emtBtn.html(''); emtBtn.append(' ' + CSSEmoticon.emoticonize(':)')); const a = $('#chat .audio'); const sbtn = $('#chat .send-btn'); { //scope _load(); _updateAudioBtn(); _updateSendBtn() } a.off().click(function() { const s = _load(); muted = s.chat.muted = !s.chat.muted; _updateAudioBtn(); Settings.save(s); }); sbtn.off().click(function() { const s = _load(); sendOn = s.chat.sendOn = s.chat.sendOn !== SEND_CTRL ? SEND_CTRL : SEND_ENTER; _updateSendBtn(); Settings.save(s); }); $('#chat #hyperlink').parent().find('button').off().click(function() { _insertLink(); }); CSSEmoticon.animate(); } function isClosed() { return chatPanel.hasClass('closed'); } function activateTab(id) { if (isClosed()) { tabs.find('.nav.nav-tabs .nav-link').each(function() { const self = $(this) , tabId = self.attr('aria-controls') , tab = $('#' + tabId); if (tabId === id) { self.addClass('active'); tab.addClass('active'); self.attr('aria-selected', true); } else { self.removeClass('active'); tab.removeClass('active'); self.attr('aria-selected', false); } }); } else { $('#chatTabs li a[aria-controls="' + id + '"]').tab('show'); } $('#activeChatTab').val(id).trigger('change'); } function _reinit(opts) { userId = opts.userId; allPrefix = opts.all; roomPrefix = opts.room; DEF_SEND = opts.sendOnEnter === true ? SEND_ENTER : SEND_CTRL; sendOn = DEF_SEND; chatPanel = $('#chatPanel'); clearTimeout(chatPanel.data('timeout')); ctrlBlk = $('#chatPopup .control.block'); newMsgNotification = ctrlBlk.data('new-msg'); editor = $('#chatMessage .wysiwyg-editor'); initToolbar(); tabs = $("#chatTabs"); tabs.off().on('shown.bs.tab', function (e) { const ct = $(e.target).attr('aria-controls'); _scrollDown($('#' + ct)); $('#activeChatTab').val(ct).trigger('change'); }); tabs.delegate(".btn.close-chat", "click", function() { const panelId = $(this).closest("a").attr("aria-controls"); _removeTab(panelId); $('#chatTabs li:last-child a').tab('show'); }); if (roomMode) { _removeResize(); } else { ctrlBlk.attr('title', ''); chatPanel.removeClass('room opened').addClass('closed') .off('mouseenter mouseleave').resizable({ handles: 'n, ' + (Settings.isRtl ? 'e' : 'w') , disabled: isClosed() , minHeight: 195 , minWidth: 260 , stop: function(_, ui) { chatPanel.css({'top': '', 'left': ''}); openedHeight = ui.size.height + 'px'; __setCssHeight(openedHeight); __setCssWidth(ui.size.width); } }); __setCssHeight(closedSize); } ctrlBlk.off().click(_toggle); $('#chatMessage').off().on('input propertychange paste', function () { const room = $('.room-block .room-container'); if (room.length) { if (!!typingTimer) { clearTimeout(typingTimer); } else { chatActivity('typing_start', room.data('room-id')); } typingTimer = setTimeout(doneTyping, doneTypingInterval); } }); $('#chat .chat-toolbar .link-field').off().on('keypress', function(evt) { if (evt.keyCode === 13) { $(this).parent().find('button').trigger('click'); } return evt.keyCode !== 13; }); inited = true; } function _removeTab(id) { $('#chatTabs li a[aria-controls="' + id + '"]').parent().remove(); $('#' + id).remove(); } function _addTab(id, label) { if (!inited) { _reinit({}); } if ($('#chat').length < 1 || $('#' + id).length) { return; } if (!label) { label = id === "chatTab-all" ? allPrefix : roomPrefix + id.substr(9); } const link = $('') .attr('aria-controls', id) .attr('href', '#' + id).text(label) , li = $('