bigbluebutton-Github/bigbluebutton-html5/private/static/guest-wait/guest-wait.html

394 lines
12 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
2021-05-21 19:23:47 +08:00
<head>
<title>BigBlueButton - Guest Lobby</title>
<meta charset="UTF-8">
<style>
/* vietnamese */
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 300;
src: local('Source Sans Pro Light'), local('SourceSansPro-Light'),
url('fonts/SourceSansPro/SourceSansPro-Light.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 300;
src: local('Source Sans Pro Light'), local('SourceSansPro-Light'),
url('fonts/SourceSansPro/SourceSansPro-Light.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 300;
src: local('Source Sans Pro Light'), local('SourceSansPro-Light'),
url('fonts/SourceSansPro/SourceSansPro-Light.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
2021-05-21 19:23:47 +08:00
:root {
--enableAnimation: 1;
}
body {
display: flex;
justify-content: center;
align-items: center;
background: #06172A;
height: 100vh;
margin: 0;
}
#content {
text-align: center;
color: white;
font-weight: bold;
font-size: 24px;
font-family: 'Source Sans Pro', arial, sans-serif;
2021-05-21 19:23:47 +08:00
}
#content h1 {
font-size: 2rem;
}
2021-05-21 19:23:47 +08:00
.spinner {
margin: 20px auto;
font-size: 0px;
2021-05-21 19:23:47 +08:00
}
.spinner .bounce1 {
animation-delay: -0.32s;
}
.spinner .bounce2 {
animation-delay: -0.16s;
}
.spinner>div {
width: 18px;
height: 18px;
margin: 0 5px;
2021-05-21 19:23:47 +08:00
background-color: rgb(255, 255, 255);
display: inline-block;
border-radius: 100%;
animation: sk-bouncedelay calc(var(--enableAnimation) * 1.4s) infinite ease-in-out both;
}
#positionInWaitingQueue {
align-items: center;
text-align: center;
}
2021-05-21 19:23:47 +08:00
@-webkit-keyframes sk-bouncedelay {
0%,
80%,
100% {
-webkit-transform: scale(0)
}
2021-05-21 19:23:47 +08:00
40% {
2021-05-21 19:23:47 +08:00
-webkit-transform: scale(1.0)
}
2021-05-21 19:23:47 +08:00
}
@keyframes sk-bouncedelay {
2021-05-21 19:23:47 +08:00
0%,
80%,
100% {
-webkit-transform: scale(0);
transform: scale(0);
}
2021-05-21 19:23:47 +08:00
40% {
2021-05-21 19:23:47 +08:00
-webkit-transform: scale(1.0);
transform: scale(1.0);
}
2021-05-21 19:23:47 +08:00
}
</style>
2021-05-21 02:03:15 +08:00
<script type="text/javascript">
let messages = {};
2021-05-21 02:03:15 +08:00
function _(message) {
return messages[message];
}
const REDIRECT_TIMEOUT = 15000;
const MESSAGE_TIMEOUT = 3000;
function updateMessage(message) {
2020-07-07 04:07:55 +08:00
document.querySelector('#content > p').innerHTML = message;
}
let lobbyMessage = '';
function updateLobbyMessage(message) {
if (message !== lobbyMessage) {
lobbyMessage = message;
if (lobbyMessage.length !== 0) {
updateMessage(lobbyMessage);
} else {
2021-05-21 02:03:15 +08:00
updateMessage(_('app.guest.guestWait'));
}
}
}
function updatePositionOnPage(message, currentPosition) {
document.querySelector('#positionInWaitingQueue > p').innerHTML = message + currentPosition;
}
function stopUpdatingWaitingPosition() {
document.querySelector('#positionInWaitingQueue > p').innerHTML = '';
}
let positionInWaitingQueue = '';
function updatePositionInWaitingQueue(newPositionInWaitingQueue) {
if (positionInWaitingQueue !== newPositionInWaitingQueue) {
positionInWaitingQueue = newPositionInWaitingQueue.toString();
if (positionInWaitingQueue === '1') {
updatePositionOnPage(_('app.guest.firstPositionInWaitingQueue'), '');
} else {
updatePositionOnPage(_('app.guest.positionInWaitingQueue'), positionInWaitingQueue);
}
}
}
function getSearchParam(name) {
const params = new URLSearchParams(window.location.search);
2021-08-03 04:08:32 +08:00
if (params && params.has(name)) {
const param = params.get(name);
2021-08-03 04:08:32 +08:00
return param;
2021-08-03 04:08:32 +08:00
}
return null;
2021-08-03 04:08:32 +08:00
}
function getClientJoinUrl() {
const joinEndpoint = '/html5client/join';
const sessionToken = getSearchParam('sessionToken');
const url = new URL(`${window.location.origin}${joinEndpoint}`);
url.search = `sessionToken=${sessionToken}`;
return url;
}
2021-08-03 04:08:32 +08:00
async function fetchLocalizedMessages() {
2021-05-21 02:03:15 +08:00
const DEFAULT_LANGUAGE = 'en';
const LOCALES_ENDPOINT = '/html5client/locale';
const url = new URL(`${window.location.origin}${LOCALES_ENDPOINT}`);
const overrideLocale = getSearchParam('locale');
2021-08-03 04:08:32 +08:00
url.search = overrideLocale
? `locale=${overrideLocale}`
: `locale=${navigator.language}&init=true`;
document.getElementsByTagName('html')[0].lang = overrideLocale || navigator.language;
2021-05-21 02:03:15 +08:00
const localesPath = 'locales';
fetch(url)
.then((response) => {
if (!response.ok) {
return false;
}
return response.json();
})
.then(({ normalizedLocale, regionDefaultLocale }) => {
const fetchFallbackMessages = new Promise((resolve, reject) => {
fetch(`${localesPath}/${DEFAULT_LANGUAGE}.json`)
.then((response) => {
if (!response.ok) {
return reject();
}
return resolve(response.json());
});
});
const fetchRegionMessages = new Promise((resolve) => {
if (!regionDefaultLocale) {
return resolve(false);
}
fetch(`${localesPath}/${regionDefaultLocale}.json`)
.then((response) => {
if (!response.ok) {
return resolve(false);
}
return response.json()
.then((jsonResponse) => resolve(jsonResponse))
.catch(() => {
resolve(false);
});
2021-05-21 02:03:15 +08:00
});
});
const fetchSpecificMessages = new Promise((resolve) => {
if (!normalizedLocale || normalizedLocale === DEFAULT_LANGUAGE || normalizedLocale === regionDefaultLocale) {
return resolve(false);
}
fetch(`${localesPath}/${normalizedLocale}.json`)
.then((response) => {
if (!response.ok) {
return resolve(false);
}
return response.json()
.then((jsonResponse) => resolve(jsonResponse))
.catch(() => {
resolve(false);
});
2021-05-21 02:03:15 +08:00
});
});
Promise.all([fetchFallbackMessages, fetchRegionMessages, fetchSpecificMessages])
.then((values) => {
let mergedMessages = Object.assign({}, values[0]);
if (!values[1] && !values[2]) {
normalizedLocale = DEFAULT_LANGUAGE;
} else {
if (values[1]) {
mergedMessages = Object.assign(mergedMessages, values[1]);
}
if (values[2]) {
mergedMessages = Object.assign(mergedMessages, values[2]);
}
}
messages = mergedMessages;
window.document.title = _('app.guest.windowTitle');
2021-10-09 16:46:10 +08:00
document.querySelector('#heading').innerHTML = _('app.guest.windowTitle');
2021-05-21 02:03:15 +08:00
updateMessage(_('app.guest.guestWait'));
enableAnimation();
try {
const sessionToken = getSearchParam('sessionToken');
2021-05-21 02:03:15 +08:00
if (!sessionToken) {
disableAnimation();
2021-05-21 02:03:15 +08:00
updateMessage(_('app.guest.noSessionToken'));
return;
}
pollGuestStatus(sessionToken, 0);
2021-05-21 02:03:15 +08:00
} catch (e) {
disableAnimation();
console.error(e);
updateMessage(_('app.guest.errorSeeConsole'));
}
})
.catch((e) => {
console.error(e);
});
});
2021-05-21 19:23:47 +08:00
}
2021-05-21 02:03:15 +08:00
function fetchUserCurrent(sessionToken) {
const GUEST_WAIT_ENDPOINT = '/api/rest/usercurrent/';
const url = new URL(`${window.location.origin}${GUEST_WAIT_ENDPOINT}`);
const headers = new Headers({
'X-Session-Token': sessionToken,
'Content-Type': 'application/json',
});
return fetch(url, { method: 'get', headers: headers });
};
function redirect(message, url) {
disableAnimation();
stopUpdatingWaitingPosition();
updateMessage(message);
setTimeout(() => {
window.location = url;
}, REDIRECT_TIMEOUT);
};
function pollGuestStatus(token, everyMs) {
2021-05-21 19:23:47 +08:00
setTimeout(function () {
fetchUserCurrent(token)
.then(async (resp) => await resp.json())
.then((data) => {
if(data.hasOwnProperty('error') || !data.hasOwnProperty('user_current')) {
disableAnimation();
stopUpdatingWaitingPosition();
updateMessage(_('app.guest.guestInvalid'));
return;
}
const userData = data.user_current[0];
if (userData.guestStatus === 'ALLOW') {
updateLobbyMessage(_('app.guest.allow'));
stopUpdatingWaitingPosition();
// Timeout is required by accessibility to allow viewing of the message for a minimum of 3 seconds
// before redirecting.
setTimeout(() => {
disableAnimation();
window.location = getClientJoinUrl();
}, MESSAGE_TIMEOUT);
return;
}
if (userData.guestStatus === 'DENY') {
stopUpdatingWaitingPosition();
2023-12-13 20:30:47 +08:00
return redirect(_('app.guest.guestDeny'), userData.meeting.logoutUrl);
}
if (userData.guestStatus === 'WAIT') {
//Wait message will be set by `updateLobbyMessage`
//updateMessage(updateMessage(_('app.guest.guestWait')));
}
if(userData.guestStatusDetails !== null) {
updatePositionInWaitingQueue(userData.guestStatusDetails.positionInWaitingQueue);
updateLobbyMessage(userData.guestStatusDetails.guestLobbyMessage || '');
}
const ATTEMPT_EVERY_MS = 10 * 1000; // 10 seconds
return pollGuestStatus(token, ATTEMPT_EVERY_MS);
});
}, everyMs);
};
2021-05-21 19:23:47 +08:00
function enableAnimation() {
document.documentElement.style.setProperty('--enableAnimation', 1);
}
function disableAnimation() {
document.documentElement.style.setProperty('--enableAnimation', 0);
}
2021-05-21 19:23:47 +08:00
window.onload = function () {
2021-05-21 02:03:15 +08:00
fetchLocalizedMessages();
};
</script>
</head>
<body>
<div id="content">
<h1 id="heading">BigBlueButton - Guest Lobby</h1>
<div class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
2022-10-11 01:47:44 +08:00
<p aria-live="polite" data-test="guestMessage">Please wait for a moderator to approve you joining the meeting.</p>
<div id="positionInWaitingQueue">
<p aria-live="polite">Calculating position in waiting queue</p>
</div>
</div>
</body>
2021-05-21 19:26:44 +08:00
</html>