[mirotalk] - add genRoom UUID4 btn

This commit is contained in:
Miroslav Pejic
2023-04-13 09:04:48 +02:00
parent 968b7c7c7e
commit 748e431ab6
2 changed files with 45 additions and 1 deletions
+20
View File
@@ -47,6 +47,10 @@
<script src="https://rawgit.com/leizongmin/js-xss/master/dist/xss.js"></script>
<!-- https://cdnjs.com/libraries/font-awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<!-- StyleSheet -->
<link rel="stylesheet" href="../css/landing.css" />
@@ -115,6 +119,11 @@
value="mirotalk"
style="border-radius: 6px"
/>
<button
id="genRoomButton"
class="button button-primary br-6 mr-8 mb-8 fas fa-arrows-rotate"
onclick="genRoom()"
></button>
<button
id="joinRoomButton"
class="button button-primary br-6 pulse"
@@ -129,6 +138,17 @@
joinRoom();
}
};
function genRoom() {
document.getElementById('roomName').value = getUUID4();
}
function getUUID4() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
(
c ^
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
).toString(16),
);
}
function joinRoom() {
let roomName = filterXSS(document.getElementById('roomName').value);
window.location.href = '/join/' + roomName;
+25 -1
View File
@@ -47,6 +47,14 @@
<link rel="stylesheet" href="../css/landing.css" />
<link rel="stylesheet" href="../css/newcall.css" />
<!-- https://cdnjs.com/libraries/font-awesome -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" />
<!-- xss -->
<script src="https://rawgit.com/leizongmin/js-xss/master/dist/xss.js"></script>
</head>
<body class="has-animations">
<div class="body-wrap">
@@ -111,6 +119,11 @@
value="mirotalk"
style="border-radius: 6px"
/>
<button
id="genRoomButton"
class="button button-primary br-6 mr-8 mb-8 fas fa-arrows-rotate"
onclick="genRoom()"
></button>
<button
id="joinRoomButton"
class="button button-primary br-6 pulse"
@@ -125,8 +138,19 @@
joinRoom();
}
};
function genRoom() {
document.getElementById('roomName').value = getUUID4();
}
function getUUID4() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
(
c ^
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
).toString(16),
);
}
function joinRoom() {
let roomName = document.getElementById('roomName').value;
let roomName = filterXSS(document.getElementById('roomName').value);
window.location.href = '/join/' + roomName;
}
</script>