From b569880cb45c626cdf98be566988df3dd714330b Mon Sep 17 00:00:00 2001 From: Miroslav Pejic Date: Thu, 18 Jul 2024 15:06:21 +0200 Subject: [PATCH] [mirotalksfu] - add poll save results btn --- app/src/Server.js | 2 +- package.json | 2 +- public/css/Polls.css | 10 +++++++--- public/js/Room.js | 10 +++++++--- public/js/RoomClient.js | 37 ++++++++++++++++++++++++++++++++++++- public/views/Room.html | 5 ++++- 6 files changed, 56 insertions(+), 10 deletions(-) diff --git a/app/src/Server.js b/app/src/Server.js index 3d90feb2..630e6c88 100644 --- a/app/src/Server.js +++ b/app/src/Server.js @@ -44,7 +44,7 @@ dependencies: { * @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.5.12 + * @version 1.5.13 * */ diff --git a/package.json b/package.json index 4b578aa3..31127109 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mirotalksfu", - "version": "1.5.12", + "version": "1.5.13", "description": "WebRTC SFU browser-based video calls", "main": "Server.js", "scripts": { diff --git a/public/css/Polls.css b/public/css/Polls.css index 8483df3d..6780cb6d 100644 --- a/public/css/Polls.css +++ b/public/css/Polls.css @@ -9,7 +9,7 @@ width: 100%; height: 100%; max-width: 600px; - max-height: 600px; + max-height: 700px; overflow-x: hidden; } @@ -160,9 +160,13 @@ color: #fff; } -#pollCloseBtn { +.poll-header-btns { + display: flex; + gap: 10px; + margin-top: 15px; + margin-bottom: 15px; position: absolute; float: right; right: 20px; - font-size: 1.6rem; + font-size: 1.3rem; } diff --git a/public/js/Room.js b/public/js/Room.js index 076c08ca..90c225e8 100644 --- a/public/js/Room.js +++ b/public/js/Room.js @@ -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.5.12 + * @version 1.5.13 * */ @@ -185,6 +185,7 @@ const pollsContainer = getId('pollsContainer'); const addOptionButton = getId('addOptionButton'); const delOptionButton = getId('delOptionButton'); const optionsContainer = getId('optionsContainer'); +const pollSaveResultsButton = getId('pollSaveResultsButton'); const selectedOptions = {}; let pollOpen = false; @@ -345,6 +346,7 @@ function initClient() { setTippy('chatShowParticipantsList', 'Toggle participants list', 'bottom'); setTippy('chatMaxButton', 'Maximize', 'bottom'); setTippy('chatMinButton', 'Minimize', 'bottom'); + setTippy('pollSaveResultsButton', 'Save results', 'left'); setTippy('pollCloseBtn', 'Close', 'bottom'); setTippy('addOptionButton', 'Add option', 'top'); setTippy('delOptionButton', 'Delete option', 'top'); @@ -1581,6 +1583,9 @@ function handleButtons() { pollCloseBtn.onclick = () => { rc.togglePoll(); }; + pollSaveResultsButton.onclick = () => { + rc.pollSaveResults(); + }; addOptionButton.onclick = () => { rc.pollAddOptions(); }; @@ -2956,7 +2961,6 @@ function saveObjToJsonFile(dataObj, name) { a.click(); setTimeout(() => { document.body.removeChild(a); - window.URL.revokeObjectURL(url); }, 100); sound('download'); } @@ -4275,7 +4279,7 @@ function showAbout() { imageUrl: image.about, customClass: { image: 'img-about' }, position: 'center', - title: 'WebRTC SFU v1.5.12', + title: 'WebRTC SFU v1.5.13', html: `
diff --git a/public/js/RoomClient.js b/public/js/RoomClient.js index b705d34d..d76fb50d 100644 --- a/public/js/RoomClient.js +++ b/public/js/RoomClient.js @@ -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.5.12 + * @version 1.5.13 * */ @@ -7955,6 +7955,41 @@ class RoomClient { return options; } + pollSaveResults() { + const polls = document.querySelectorAll('.poll'); + const results = []; + + polls.forEach((poll, index) => { + const question = poll.querySelector('.poll-h3').textContent; + const options = poll.querySelectorAll('.options div label'); + const optionsText = Array.from(options) + .map((option) => option.textContent) + .join(', '); + + const votersList = poll.querySelector('ul'); + const voters = Array.from(votersList.querySelectorAll('li')) + .map((li) => li.textContent) + .join('\n'); + + results.push({ + Poll: `${index + 1}`, + question: question, + options: optionsText, + voters: voters, + }); + }); + + results.lengh > 0 + ? saveObjToJsonFile(results, 'Poll') + : this.userLog('info', 'No polling data available to save', 'top-end'); + } + + getPollFileName() { + const dateTime = getDataTimeStringFormat(); + const roomName = this.room_id.trim(); + return `Poll_${roomName}_${dateTime}.txt`; + } + sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)); } diff --git a/public/views/Room.html b/public/views/Room.html index b8c752a0..101d305b 100644 --- a/public/views/Room.html +++ b/public/views/Room.html @@ -1441,7 +1441,10 @@ access to use this app.