|
15 | 15 | * @license For commercial use or closed source, contact us at license.mirotalk@gmail.com or purchase directly from CodeCanyon |
16 | 16 | * @license CodeCanyon: https://codecanyon.net/item/mirotalk-p2p-webrtc-realtime-video-conferences/38376661 |
17 | 17 | * @author Miroslav Pejic - miroslav.pejic.85@gmail.com |
18 | | - * @version 1.8.53 |
| 18 | + * @version 1.8.54 |
19 | 19 | * |
20 | 20 | */ |
21 | 21 |
|
@@ -222,6 +222,11 @@ const settingsExtraToggle = getId('settingsExtraToggle'); |
222 | 222 | const settingsExtraMenu = getId('settingsExtraMenu'); |
223 | 223 | const leaveRoomBtn = getId('leaveRoomBtn'); |
224 | 224 |
|
| 225 | +const exitDropdown = getId('exitDropdown'); |
| 226 | +const exitMenu = getId('exitMenu'); |
| 227 | +const exitLeaveBtn = getId('exitLeaveBtn'); |
| 228 | +const exitLeaveAllBtn = getId('exitLeaveAllBtn'); |
| 229 | + |
225 | 230 | // Room Emoji Picker |
226 | 231 | const closeEmojiPickerContainer = getId('closeEmojiPickerContainer'); |
227 | 232 | const emojiPickerContainer = getId('emojiPickerContainer'); |
@@ -7520,8 +7525,64 @@ function setAboutBtn() { |
7520 | 7525 | */ |
7521 | 7526 | function setLeaveRoomBtn() { |
7522 | 7527 | leaveRoomBtn.addEventListener('click', (e) => { |
7523 | | - leaveRoom(); |
| 7528 | + if (e && e.shiftKey) return leaveRoom(); |
| 7529 | + toggleExitMenu(); |
7524 | 7530 | }); |
| 7531 | + if (exitLeaveBtn) exitLeaveBtn.onclick = handleExitLeave; |
| 7532 | + if (exitLeaveAllBtn) exitLeaveAllBtn.onclick = handleExitLeaveForAll; |
| 7533 | + document.addEventListener('click', handleExitMenuOutsideClick); |
| 7534 | +} |
| 7535 | + |
| 7536 | +/** |
| 7537 | + * Toggle the exit dropdown menu. The "End room for all" entry is |
| 7538 | + * only available to the presenter. |
| 7539 | + */ |
| 7540 | +function toggleExitMenu() { |
| 7541 | + if (!exitMenu) return leaveRoom(); |
| 7542 | + if (exitLeaveAllBtn) { |
| 7543 | + isPresenter ? exitLeaveAllBtn.classList.remove('hidden') : exitLeaveAllBtn.classList.add('hidden'); |
| 7544 | + } |
| 7545 | + exitMenu.classList.toggle('hidden'); |
| 7546 | +} |
| 7547 | + |
| 7548 | +function handleExitLeave() { |
| 7549 | + if (exitMenu) exitMenu.classList.add('hidden'); |
| 7550 | + leaveRoom(); |
| 7551 | +} |
| 7552 | + |
| 7553 | +function handleExitLeaveForAll() { |
| 7554 | + if (exitMenu) exitMenu.classList.add('hidden'); |
| 7555 | + leaveRoomForAll(); |
| 7556 | +} |
| 7557 | + |
| 7558 | +function handleExitMenuOutsideClick(e) { |
| 7559 | + if (!exitDropdown || !exitMenu) return; |
| 7560 | + if (exitMenu.classList.contains('hidden')) return; |
| 7561 | + if (!exitDropdown.contains(e.target)) exitMenu.classList.add('hidden'); |
| 7562 | +} |
| 7563 | + |
| 7564 | +/** |
| 7565 | + * Presenter: kick out all other peers, then leave the room. |
| 7566 | + */ |
| 7567 | +function leaveRoomForAll() { |
| 7568 | + if (!isPresenter) return leaveRoom(); |
| 7569 | + try { |
| 7570 | + if (allPeers && typeof allPeers === 'object') { |
| 7571 | + for (const peer_id in allPeers) { |
| 7572 | + if (!allPeers[peer_id]) continue; |
| 7573 | + if (peer_id === myPeerId) continue; |
| 7574 | + sendToServer('kickOut', { |
| 7575 | + room_id: roomId, |
| 7576 | + peer_id: peer_id, |
| 7577 | + peer_uuid: myPeerUUID, |
| 7578 | + peer_name: myPeerName, |
| 7579 | + }); |
| 7580 | + } |
| 7581 | + } |
| 7582 | + } catch (err) { |
| 7583 | + console.warn('[leaveRoomForAll] failed to kick all peers', err); |
| 7584 | + } |
| 7585 | + leaveRoom(); |
7525 | 7586 | } |
7526 | 7587 |
|
7527 | 7588 | /** |
@@ -15894,7 +15955,7 @@ function showAbout() { |
15894 | 15955 | Swal.fire({ |
15895 | 15956 | background: swBg, |
15896 | 15957 | position: 'center', |
15897 | | - title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.8.53', |
| 15958 | + title: brand.about?.title && brand.about.title.trim() !== '' ? brand.about.title : 'WebRTC P2P v1.8.54', |
15898 | 15959 | imageUrl: brand.about?.imageUrl && brand.about.imageUrl.trim() !== '' ? brand.about.imageUrl : images.about, |
15899 | 15960 | customClass: { image: 'img-about' }, |
15900 | 15961 | html: renderRoomTemplate('tpl-about-modal', { |
|
0 commit comments