Skip to content

Commit

Permalink
[mirotalkbro] - refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
miroslavpejic85 committed Jan 8, 2025
1 parent 1cd0aa5 commit 169e660
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @license For open source under AGPL-3.0
* @license For private project or commercial purposes contact us at: [email protected]
* @author Miroslav Pejic - [email protected]
* @version 1.0.69
* @version 1.0.70
*/

require('dotenv').config();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mirotalkbro",
"version": "1.0.69",
"version": "1.0.70",
"description": "P2P WebRTC audio, video and screen live broadcast",
"main": "app/server.js",
"scripts": {
Expand All @@ -23,7 +23,7 @@
"author": "Miroslav Pejic",
"license": "AGPLv3",
"dependencies": {
"@sentry/node": "^8.47.0",
"@sentry/node": "^8.48.0",
"compression": "^1.7.5",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
Expand Down
13 changes: 8 additions & 5 deletions public/js/broadcast.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ const videoQualitySelect = document.getElementById('videoQualitySelect');
const videoFpsSelect = document.getElementById('videoFpsSelect');
const audioSelect = document.getElementById('audioSelect');

const userAgent = navigator.userAgent.toLowerCase();
const isMobileDevice = isMobile();
const isTabletDevice = isTablet();
const isIPadDevice = isIpad();
const isDesktopDevice = isDesktop();
const userAgent = navigator.userAgent;
const parser = new UAParser(userAgent);
const result = parser.getResult();
const deviceType = result.device.type || 'desktop';
const isMobileDevice = deviceType === 'mobile';
const isTabletDevice = deviceType === 'tablet';
const isIPadDevice = result.device.model?.toLowerCase() === 'ipad';
const isDesktopDevice = deviceType === 'desktop';

const isSpeechSynthesisSupported = 'speechSynthesis' in window;

Expand Down
20 changes: 1 addition & 19 deletions public/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,7 @@ function getRandomInt(max) {
}

function isPIPSupported() {
return !isMobile() && document.pictureInPictureEnabled;
}

function isMobile() {
return !!/Android|webOS|iPhone|iPad|iPod|BB10|BlackBerry|IEMobile|Opera Mini|Mobile|mobile/i.test(userAgent || '');
}

function isTablet() {
return /(ipad|tablet|(android(?!.*mobile))|(windows(?!.*phone)(.*touch))|kindle|playbook|silk|(puffin(?!.*(IP|AP|WP))))/.test(
userAgent,
);
}

function isIpad() {
return /macintosh/.test(userAgent) && 'ontouchend' in document;
}

function isDesktop() {
return !isMobileDevice && !isTabletDevice && !isIPadDevice;
return !isMobileDevice && document.pictureInPictureEnabled;
}

function setTippy(elem, content, placement) {
Expand Down
7 changes: 5 additions & 2 deletions public/js/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,11 @@ const messagesForm = document.getElementById('messagesForm');
const messageInput = document.getElementById('messageInput');
const messageSend = document.getElementById('messageSend');

const userAgent = navigator.userAgent.toLowerCase();
const isMobileDevice = isMobile();
const userAgent = navigator.userAgent;
const parser = new UAParser(userAgent);
const result = parser.getResult();
const deviceType = result.device.type || 'desktop';
const isMobileDevice = deviceType === 'mobile';

// =====================================================
// Handle ToolTips
Expand Down
17 changes: 9 additions & 8 deletions public/views/broadcast.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,18 @@
</table>
</div>
</div>
<script src="/socket.io/socket.io.js"></script>
<script src="../js/swal.js"></script>
<script src="../js/utils.js"></script>
<script src="../js/utils.js"></script>
<script src="../js/config.js"></script>
<script src="../js/broadcast.js"></script>
<script src="../js/recording.js"></script>
<script async src="../js/umami.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]/dist/qrious.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.8/umd/popper.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/tippy.js/6.3.7/tippy-bundle.umd.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/UAParser.js/1.0.37/ua-parser.min.js"></script>
<script defer src="/socket.io/socket.io.js"></script>
<script defer src="../js/swal.js"></script>
<script defer src="../js/utils.js"></script>
<script defer src="../js/utils.js"></script>
<script defer src="../js/config.js"></script>
<script defer src="../js/broadcast.js"></script>
<script defer src="../js/recording.js"></script>
<script async src="../js/umami.js"></script>
</body>
</html>
15 changes: 8 additions & 7 deletions public/views/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,16 @@
<button id="messageSend"><i class="fas fa-paper-plane"></i> Send message</button>
</div>
</div>
<script src="/socket.io/socket.io.js"></script>
<script src="../js/swal.js"></script>
<script src="../js/utils.js"></script>
<script src="../js/config.js"></script>
<script src="../js/viewer.js"></script>
<script src="../js/recording.js"></script>
<script async src="../js/umami.js"></script>
<script defer src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.8/umd/popper.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/tippy.js/6.3.7/tippy-bundle.umd.min.js"></script>
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/UAParser.js/1.0.37/ua-parser.min.js"></script>
<script defer src="/socket.io/socket.io.js"></script>
<script defer src="../js/swal.js"></script>
<script defer src="../js/utils.js"></script>
<script defer src="../js/config.js"></script>
<script defer src="../js/viewer.js"></script>
<script defer src="../js/recording.js"></script>
<script async src="../js/umami.js"></script>
</body>
</html>

0 comments on commit 169e660

Please sign in to comment.