383 lines
12 KiB
HTML
383 lines
12 KiB
HTML
<style>
|
|
.politictalk-room-logo {
|
|
align-items: center;
|
|
display: flex;
|
|
height: 64px;
|
|
justify-content: center;
|
|
left: max(20px, env(safe-area-inset-left));
|
|
opacity: 0.96;
|
|
position: fixed;
|
|
top: max(20px, env(safe-area-inset-top));
|
|
width: 64px;
|
|
z-index: 2147483000;
|
|
}
|
|
|
|
.politictalk-room-logo img {
|
|
display: block;
|
|
height: 100%;
|
|
object-fit: contain;
|
|
width: 100%;
|
|
}
|
|
|
|
html.politictalk-direct-access-blocked,
|
|
html.politictalk-direct-access-blocked body {
|
|
background: #202424 !important;
|
|
min-height: 100%;
|
|
}
|
|
|
|
html.politictalk-direct-access-blocked #react {
|
|
display: none !important;
|
|
}
|
|
|
|
.politictalk-direct-access {
|
|
align-items: center;
|
|
background: rgba(13, 15, 16, 0.48);
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
inset: 0;
|
|
justify-content: center;
|
|
padding: 24px;
|
|
position: fixed;
|
|
z-index: 2147482999;
|
|
}
|
|
|
|
.politictalk-direct-access__dialog {
|
|
background: #111111;
|
|
border: 1px solid rgba(255, 255, 255, 0.16);
|
|
border-radius: 8px;
|
|
box-shadow: 0 22px 64px rgba(0, 0, 0, 0.32);
|
|
box-sizing: border-box;
|
|
color: #f5f5f5;
|
|
max-width: 520px;
|
|
padding: 32px;
|
|
width: min(100%, 520px);
|
|
}
|
|
|
|
.politictalk-direct-access__title {
|
|
font-family: inherit;
|
|
font-size: 26px;
|
|
font-weight: 700;
|
|
line-height: 1.2;
|
|
margin: 0 0 16px;
|
|
}
|
|
|
|
.politictalk-direct-access__message {
|
|
color: rgba(255, 255, 255, 0.78);
|
|
font-size: 17px;
|
|
line-height: 1.5;
|
|
margin: 0;
|
|
}
|
|
|
|
.politictalk-direct-access__actions {
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
margin-top: 28px;
|
|
}
|
|
|
|
.politictalk-direct-access__button {
|
|
background: #ffffff;
|
|
border: 0;
|
|
border-radius: 6px;
|
|
color: #151515;
|
|
cursor: pointer;
|
|
font-size: 16px;
|
|
font-weight: 700;
|
|
min-width: 96px;
|
|
padding: 13px 22px;
|
|
}
|
|
|
|
.politictalk-direct-access__button:focus {
|
|
outline: 3px solid rgba(255, 255, 255, 0.42);
|
|
outline-offset: 3px;
|
|
}
|
|
|
|
html.politictalk-host-user button[aria-label*="Leave meeting" i],
|
|
html.politictalk-host-user button[aria-label*="Leave conference" i],
|
|
html.politictalk-host-user [role="button"][aria-label*="Leave meeting" i],
|
|
html.politictalk-host-user [role="button"][aria-label*="Leave conference" i] {
|
|
display: none !important;
|
|
}
|
|
|
|
@media (max-width: 640px) {
|
|
.politictalk-room-logo {
|
|
height: 52px;
|
|
left: max(12px, env(safe-area-inset-left));
|
|
top: max(12px, env(safe-area-inset-top));
|
|
width: 52px;
|
|
}
|
|
|
|
.politictalk-direct-access {
|
|
align-items: flex-start;
|
|
padding: 132px 18px 18px;
|
|
}
|
|
|
|
.politictalk-direct-access__dialog {
|
|
padding: 24px;
|
|
}
|
|
|
|
.politictalk-direct-access__title {
|
|
font-size: 24px;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
(function() {
|
|
var PARALLEL_GLOBE_URL = 'https://parallelglobe.io';
|
|
var directAccessBlocked = isDirectRoomAccess();
|
|
|
|
if (directAccessBlocked) {
|
|
document.documentElement.classList.add('politictalk-direct-access-blocked');
|
|
document.title = 'Access required - PoliticTalk';
|
|
}
|
|
|
|
function hasMeetingToken() {
|
|
var params = new URLSearchParams(window.location.search);
|
|
|
|
return Boolean(params.get('jwt') || params.get('token'));
|
|
}
|
|
|
|
function isDirectRoomAccess() {
|
|
var path = window.location.pathname.replace(/\/+$/, '');
|
|
|
|
if (!path || path === '/') {
|
|
return false;
|
|
}
|
|
|
|
if (/^\/(?:static|images|libs|css|sounds|fonts|transcripts)\//.test(path)) {
|
|
return false;
|
|
}
|
|
|
|
return !hasMeetingToken();
|
|
}
|
|
|
|
function decodeBase64Url(value) {
|
|
var base64 = value.replace(/-/g, '+').replace(/_/g, '/');
|
|
|
|
while (base64.length % 4) {
|
|
base64 += '=';
|
|
}
|
|
|
|
var binary = window.atob(base64);
|
|
var bytes = new Uint8Array(binary.length);
|
|
|
|
for (var index = 0; index < binary.length; index += 1) {
|
|
bytes[index] = binary.charCodeAt(index);
|
|
}
|
|
|
|
return new TextDecoder().decode(bytes);
|
|
}
|
|
|
|
function getMeetingToken() {
|
|
return new URLSearchParams(window.location.search).get('jwt') || '';
|
|
}
|
|
|
|
function getPoliticTalkJwtPayload() {
|
|
try {
|
|
var token = getMeetingToken();
|
|
|
|
if (!token) {
|
|
return null;
|
|
}
|
|
|
|
return JSON.parse(decodeBase64Url(token.split('.')[1] || ''));
|
|
} catch (error) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
function getPoliticTalkMeetingTitle() {
|
|
var payload = getPoliticTalkJwtPayload();
|
|
|
|
if (!payload) {
|
|
return '';
|
|
}
|
|
|
|
var context = payload.context || {};
|
|
var room = context.room || {};
|
|
var title = (context.politictalk && context.politictalk.title)
|
|
|| room.subject
|
|
|| room.name
|
|
|| '';
|
|
|
|
title = String(title);
|
|
return title.trim() ? title : '';
|
|
}
|
|
|
|
function isPoliticTalkHost() {
|
|
var payload = getPoliticTalkJwtPayload();
|
|
var user = payload && payload.context && payload.context.user;
|
|
|
|
return Boolean(user && user.moderator);
|
|
}
|
|
|
|
function applyPoliticTalkMeetingTitle() {
|
|
var meetingTitle = getPoliticTalkMeetingTitle();
|
|
|
|
if (!meetingTitle) {
|
|
return;
|
|
}
|
|
|
|
window.config = window.config || {};
|
|
window.config.subject = meetingTitle;
|
|
window.config.localSubject = meetingTitle;
|
|
}
|
|
|
|
function preventHostLeaveButtonExecution() {
|
|
if (!isPoliticTalkHost()) {
|
|
return;
|
|
}
|
|
|
|
var buttons = window.config && window.config.buttonsWithNotifyClick;
|
|
|
|
if (!Array.isArray(buttons)) {
|
|
buttons = [];
|
|
}
|
|
|
|
buttons = buttons.filter(function(button) {
|
|
var key = typeof button === 'string' ? button : button && button.key;
|
|
|
|
return key !== 'hangup';
|
|
});
|
|
buttons.push('hangup');
|
|
|
|
window.config = window.config || {};
|
|
window.config.buttonsWithNotifyClick = buttons;
|
|
}
|
|
|
|
function isLeaveMeetingControl(element) {
|
|
var label = [
|
|
element.getAttribute('aria-label'),
|
|
element.getAttribute('title'),
|
|
element.textContent
|
|
].join(' ').replace(/\s+/g, ' ').trim().toLowerCase();
|
|
|
|
return label.indexOf('leave meeting') !== -1
|
|
|| label.indexOf('leave conference') !== -1;
|
|
}
|
|
|
|
function hideHostLeaveMeetingControls() {
|
|
if (!isPoliticTalkHost() || !document.body) {
|
|
return;
|
|
}
|
|
|
|
var controls = document.querySelectorAll('button, [role="button"]');
|
|
|
|
controls.forEach(function(control) {
|
|
if (!isLeaveMeetingControl(control)) {
|
|
return;
|
|
}
|
|
|
|
control.classList.add('politictalk-host-hidden-leave');
|
|
control.setAttribute('aria-hidden', 'true');
|
|
control.setAttribute('tabindex', '-1');
|
|
control.style.display = 'none';
|
|
});
|
|
}
|
|
|
|
function mountHostHangupPolicy() {
|
|
if (!isPoliticTalkHost() || !document.body) {
|
|
return;
|
|
}
|
|
|
|
document.documentElement.classList.add('politictalk-host-user');
|
|
preventHostLeaveButtonExecution();
|
|
hideHostLeaveMeetingControls();
|
|
|
|
if (window.politicTalkHostHangupObserver) {
|
|
return;
|
|
}
|
|
|
|
window.politicTalkHostHangupObserver = new MutationObserver(function() {
|
|
window.requestAnimationFrame(hideHostLeaveMeetingControls);
|
|
});
|
|
window.politicTalkHostHangupObserver.observe(document.body, {
|
|
attributes: true,
|
|
attributeFilter: [ 'aria-label', 'title', 'class' ],
|
|
childList: true,
|
|
characterData: true,
|
|
subtree: true
|
|
});
|
|
}
|
|
|
|
function mountPoliticTalkLogo() {
|
|
if (!document.body || document.getElementById('politictalk-room-logo')) {
|
|
return;
|
|
}
|
|
|
|
var link = document.createElement('a');
|
|
link.className = 'politictalk-room-logo';
|
|
link.href = 'https://parallelglobe.io/politictalk';
|
|
link.id = 'politictalk-room-logo';
|
|
link.rel = 'noopener noreferrer';
|
|
link.target = '_blank';
|
|
|
|
var image = document.createElement('img');
|
|
image.alt = 'ParallelGlobe';
|
|
image.src = '/images/politictalk/pg_globe.png';
|
|
|
|
link.appendChild(image);
|
|
document.body.appendChild(link);
|
|
}
|
|
|
|
function mountDirectAccessMessage() {
|
|
if (!directAccessBlocked || !document.body || document.getElementById('politictalk-direct-access')) {
|
|
return;
|
|
}
|
|
|
|
var wrapper = document.createElement('div');
|
|
wrapper.className = 'politictalk-direct-access';
|
|
wrapper.id = 'politictalk-direct-access';
|
|
|
|
var dialog = document.createElement('div');
|
|
dialog.className = 'politictalk-direct-access__dialog';
|
|
dialog.setAttribute('aria-labelledby', 'politictalk-direct-access-title');
|
|
dialog.setAttribute('aria-modal', 'true');
|
|
dialog.setAttribute('role', 'dialog');
|
|
|
|
var title = document.createElement('h1');
|
|
title.className = 'politictalk-direct-access__title';
|
|
title.id = 'politictalk-direct-access-title';
|
|
title.textContent = 'Parallel Globe account required';
|
|
|
|
var message = document.createElement('p');
|
|
message.className = 'politictalk-direct-access__message';
|
|
message.textContent = 'This PoliticTalk room cannot be opened directly. Please create an account or sign in at Parallel Globe to join PoliticTalk sessions.';
|
|
|
|
var actions = document.createElement('div');
|
|
actions.className = 'politictalk-direct-access__actions';
|
|
|
|
var button = document.createElement('button');
|
|
button.className = 'politictalk-direct-access__button';
|
|
button.textContent = 'OK';
|
|
button.type = 'button';
|
|
button.addEventListener('click', function() {
|
|
window.location.href = PARALLEL_GLOBE_URL;
|
|
});
|
|
|
|
actions.appendChild(button);
|
|
dialog.appendChild(title);
|
|
dialog.appendChild(message);
|
|
dialog.appendChild(actions);
|
|
wrapper.appendChild(dialog);
|
|
document.body.appendChild(wrapper);
|
|
button.focus();
|
|
}
|
|
|
|
applyPoliticTalkMeetingTitle();
|
|
preventHostLeaveButtonExecution();
|
|
|
|
if (document.readyState === 'loading') {
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
mountPoliticTalkLogo();
|
|
mountDirectAccessMessage();
|
|
mountHostHangupPolicy();
|
|
});
|
|
} else {
|
|
mountPoliticTalkLogo();
|
|
mountDirectAccessMessage();
|
|
mountHostHangupPolicy();
|
|
}
|
|
}());
|
|
</script>
|