Skip to content
Snippets Groups Projects
Commit 20719b93 authored by Emrah Eryilmaz's avatar Emrah Eryilmaz Committed by Thorsten Roßner
Browse files

feat(sovereign-workplace-jitsi): Custom Jitsi UI for Element Jitsi Widget

parent 4535e893
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,40 @@ SPDX-License-Identifier: Apache-2.0
<script>
let failedAttempt = 0;
function base32decode(s) {
const a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
const pad = "=";
const len = s.length;
const apad = a + pad;
let v, x, r=0, bits=0, c, o="";
s = s.toUpperCase();
for(i=0; i<len; i+=1) {
v = apad.indexOf(s.charAt(i));
if (v>=0 && v<32) {
x = (x << 5) | v;
bits += 5;
if (bits >= 8) {
c = (x >> (bits - 8)) & 0xff;
o = o + String.fromCharCode(c);
bits -= 8;
}
}
}
// remaining bits are < 8
if (bits>0) {
c = ((x << (8 - bits)) & 0xff) >> (8 - bits);
// Dont append a null terminator.
if (c!==0) {
o = o + String.fromCharCode(c);
}
}
return o;
}
function oidcRedirect() {
const qs = new URLSearchParams(window.location.search.substring(1));
qs.delete('oidc');
......@@ -55,5 +89,62 @@ function interceptLoginRequest() {
}
}
// This function customizes Jitsi UI if the room is created by Element Jitsi
// Widget. It senses the room created by Element by checking its name. The room
// created by Element has a special name format:
//
// base32decode(room_name) should match RegExp("^(!.*:.*[.][a-z]*)$")
// or
// room_name should match RegExp("^(Jitsi[A-Z][a-z]{23})$")
function updateUIforElement() {
try {
if (!APP.conference.isJoined()) throw new Error("not joined yet");
try {
const roomName = APP.store.getState()["features/base/conference"].room;
const decoded = base32decode(roomName);
const reg1 = new RegExp("^(!.*:.*[.][a-z]*)$");
const reg2 = new RegExp("^(Jitsi[A-Z][a-z]{23})$");
if (!reg1.test(decoded) && !reg2.test(roomName)) {
throw new Error("not a Matrix room");
}
APP.store.getState()["features/base/config"].toolbarButtons = [
"camera",
"closedcaptions",
"desktop",
"download",
"feedback",
"filmstrip",
"fullscreen",
"hangup",
"help",
"livestreaming",
"microphone",
"mute-everyone",
"mute-video-everyone",
"participants-pane",
"profile",
"raisehand",
"security",
"select-background",
"settings",
"shareaudio",
"shortcuts",
"stats",
"tileview",
"toggle-camera",
"videoquality",
];
} catch {
// do nothing
}
} catch {
setTimeout(updateUIforElement, 1000);
}
}
interceptLoginRequest();
updateUIforElement();
</script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment

Consent

On this website, we use the web analytics service Matomo to analyze and review the use of our website. Through the collected statistics, we can improve our offerings and make them more appealing for you. Here, you can decide whether to allow us to process your data and set corresponding cookies for these purposes, in addition to technically necessary cookies. Further information on data protection—especially regarding "cookies" and "Matomo"—can be found in our privacy policy. You can withdraw your consent at any time.