[mirotalksfu] - improve widget

هذا الالتزام موجود في:
Miroslav Pejic
2025-08-10 22:27:22 +02:00
الأصل 0894d86fb6
التزام 998ae4e91c
11 ملفات معدلة مع 260 إضافات و63 حذوفات

عرض الملف

@@ -45,6 +45,13 @@ let BRAND = {
expertImages: [
'https://photo.cloudron.pocketsolution.net/uploads/original/95/7d/a5f7f7a2c89a5fee7affda5f013c.jpeg',
],
buttons: {
audio: true,
video: true,
screen: true,
chat: true,
join: true,
},
checkOnlineStatus: false,
isOnline: true,
customMessages: {
@@ -55,6 +62,10 @@ let BRAND = {
offlineText: 'We are offline',
poweredBy: 'Powered by MiroTalk SFU',
},
alert: {
enabled: false,
type: 'email',
},
},
},
app: {
@@ -99,7 +110,7 @@ let BRAND = {
},
about: {
imageUrl: '../images/mirotalk-logo.gif',
title: '<strong>WebRTC SFU v1.9.28</strong>',
title: '<strong>WebRTC SFU v1.9.29</strong>',
html: `
<button
id="support-button"

عرض الملف

@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.9.28
* @version 1.9.29
*
*/
@@ -5545,7 +5545,7 @@ function showAbout() {
position: 'center',
imageUrl: BRAND.about?.imageUrl && BRAND.about.imageUrl.trim() !== '' ? BRAND.about.imageUrl : image.about,
customClass: { image: 'img-about' },
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.9.28',
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.9.29',
html: `
<br />
<div id="about">

عرض الملف

@@ -9,7 +9,7 @@
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
* @version 1.9.28
* @version 1.9.29
*
*/

عرض الملف

@@ -16,6 +16,13 @@ class MiroTalkWidget {
'https://i.pravatar.cc/40?img=2',
'https://i.pravatar.cc/40?img=3',
],
buttons: {
audio: true,
video: true,
screen: true,
chat: true,
join: true,
},
checkOnlineStatus: false,
isOnline: true,
customMessages: {
@@ -223,21 +230,28 @@ class MiroTalkWidget {
}
createActionButtons() {
const buttons = [
{ action: 'startAudioCall', icon: this.getAudioIcon(), text: 'Start Audio Call' },
{ action: 'startVideoCall', icon: this.getVideoIcon(), text: 'Start Video Call' },
];
const flags = this.options.supportWidget.buttons || {};
const buttons = [];
// Only show "Start Screen Share" if displayMedia is supported
if (navigator.mediaDevices && typeof navigator.mediaDevices.getDisplayMedia === 'function') {
if (flags.audio) {
buttons.push({ action: 'startAudioCall', icon: this.getAudioIcon(), text: 'Start Audio Call' });
}
if (flags.video) {
buttons.push({ action: 'startVideoCall', icon: this.getVideoIcon(), text: 'Start Video Call' });
}
if (flags.screen && navigator.mediaDevices && typeof navigator.mediaDevices.getDisplayMedia === 'function') {
buttons.push({ action: 'startScreenShare', icon: this.getScreenIcon(), text: 'Start Screen Share' });
}
if (flags.chat) {
buttons.push({ action: 'startChat', icon: this.getChatIcon(), text: 'Start Chat' });
}
if (flags.join) {
buttons.push({ action: 'joinRoom', icon: this.getJoinIcon(), text: 'Join Room' });
}
// Add chat button
buttons.push({ action: 'startChat', icon: this.getChatIcon(), text: 'Start Chat' });
// Insert "Start Screen Share" before "Join Room" if present
buttons.push({ action: 'joinRoom', icon: this.getJoinIcon(), text: 'Join Room' });
if (!buttons.length) {
return `<div class="no-actions">No actions available</div>`;
}
return buttons
.map(
@@ -245,8 +259,7 @@ class MiroTalkWidget {
<button class="btn" onclick="miroTalkWidgetAction('${btn.action}', this)">
<div class="btn-icon">${btn.icon}</div>
<span class="btn-text">${btn.text}</span>
</button>
`
</button>`
)
.join('');
}
@@ -709,6 +722,21 @@ document.addEventListener('DOMContentLoaded', function () {
if (!autoInit) return;
try {
const buttonsAttr = autoInit.getAttribute('data-buttons');
let buttonsConfig = { ...MiroTalkWidget.DEFAULT_OPTIONS.supportWidget.buttons };
if (buttonsAttr) {
// Normalize and map
const requested = buttonsAttr
.split(',')
.map((b) => b.trim().toLowerCase())
.filter(Boolean);
// Start all false then enable requested valid keys
buttonsConfig = { audio: false, video: false, screen: false, chat: false, join: false };
requested.forEach((key) => {
if (key in buttonsConfig) buttonsConfig[key] = true;
});
}
const config = {
domain: autoInit.getAttribute('data-domain') || window.location.host,
roomId: autoInit.getAttribute('data-room') || 'support-room',
@@ -756,6 +784,7 @@ document.addEventListener('DOMContentLoaded', function () {
expertImages: config.expertImages,
checkOnlineStatus: config.checkOnline,
customMessages: config.customMessages,
buttons: buttonsConfig,
},
});
}