Skip to content
This repository has been archived by the owner on Jun 26, 2022. It is now read-only.

Commit

Permalink
fixed overrides mechanism to allow custom videochat url as well as
Browse files Browse the repository at this point in the history
custom jitsi room name
  • Loading branch information
soichih committed Jun 26, 2020
1 parent 3852768 commit 6abdae9
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 43 deletions.
87 changes: 54 additions & 33 deletions assets/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function getNodeType(jQuery, md5, url) {
* @param {object} md5 md5 library object
* @return {object} returns the rendered DataTable object
*/
function directory(jQuery) {
async function directory(jQuery) {

// Embed the table placeholder
jQuery('#content').prepend('<table id="directory" class="display"></table>');
Expand Down Expand Up @@ -217,11 +217,22 @@ function directory(jQuery) {
{
targets: 4,//video
render(data, type, row) {
return `
<a href="#" onclick="openJit('https://meet.jit.si/ohbm2020-${row.number}', ${row.number})">
jitsi:ohbm2020-${row.number}
</a>
`
let name = "ohbm2020-"+row.number; //default
if(row.videochat) name = row.videochat; //user can override it to another jitsi name
if(row.videochat && row.videochat.startsWith("http")) {
//or use custom url
return `
<a href="${row.videochat}" targer="ohbm2020_${row.number}">
custom url
</a>
`;
} else {
return `
<a href="#" onclick="openJit('${row.number}', '${name}')">
jitsi://${name}
</a>
`;
}
},
},
{
Expand All @@ -245,42 +256,52 @@ function directory(jQuery) {
}); //end of DataTable

//load posters
fetch("posters.json").then(res=>res.json()).then(data=>{
data.posters.forEach(p=>{
p.id = 'p'+p.number; //cannot be number (or string of number)
p.people = 0;
});
table.rows.add(data.posters).draw();
let res = await fetch("posters.json");
let data = await res.json();
data.posters.forEach(p=>{
p.id = 'p'+p.number; //cannot be number (or string of number)
p.people = 0;
p.videochat = null; //let's ignore this now (override only)
});

wss = new ReconnectingWebSocket("wss://dev1.soichi.us/ohbm2020/");
//load override and apply
res = await fetch("posters-overrides.json");
let override = await res.json();
override.posters.forEach(o=>{
let p = data.posters.find(p=>p.number == o.number);
Object.assign(p, o);
});

//connect to backend
wss.onopen = () => {
wss.send(JSON.stringify({action: "dump"}));
}
wss.onmessage = e => {
let msg = JSON.parse(e.data);
if(msg.dump) {
for(let key in msg.dump) {
let row = table.row("#p"+key);
if(row.length == 1) {
table.cell(row, 5).data(msg.dump[key]);
}
table.rows.add(data.posters).draw();

wss = new ReconnectingWebSocket("wss://dev1.soichi.us/ohbm2020/");

//connect to backend
wss.onopen = () => {
wss.send(JSON.stringify({action: "dump"}));
}
wss.onmessage = e => {
let msg = JSON.parse(e.data);
if(msg.dump) {
for(let key in msg.dump) {
let row = table.row("#p"+key);
if(row.length == 1) {
table.cell(row, 5).data(msg.dump[key]);
}
table.draw();
}
if(msg.update) {
let row = table.row("#p"+msg.update.id);
table.cell(row, 5).data(msg.update.count).draw();
}
table.draw();
}
});
if(msg.update) {
let row = table.row("#p"+msg.update.id);
table.cell(row, 5).data(msg.update.count).draw();
}
}

localStorage['ntCache'] = JSON.stringify(ntCache);
return table;
}

function openJit(url, number) {
window.open("room.html#"+number);
function openJit(id, name) {
window.open("room.html#"+id+"."+name);
}

12 changes: 6 additions & 6 deletions posters-overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -3082,7 +3082,7 @@
},
{
"number": 1098,
"videochat": "<a href=\"https://meet.jit.si/cobidas_checklist\" target=\"_cobidas_checklist\">jitsi:cobidas_checklist</a>",
"videochat": "cobidas_checklist",
"pdf": "https://drive.google.com/file/d/1CirkGPplmrbqilPOq7OdKQJYZzwc0AKc/view?usp=sharing"
},
{
Expand Down Expand Up @@ -3674,7 +3674,7 @@
},
{
"number": 1302,
"videochat": "<a href=\"https://meet.jit.si/ohbm2020-412\" target=\"_ohbm2020-412\">jitsi:ohbm2020-412</a>",
"videochat": "ohbm2020-412",
"pdf": "https://cdn-akamai.6connex.com//645/1827//TaskCCA_poster_1__15922324225571065.pdf"
},
{
Expand Down Expand Up @@ -4583,7 +4583,7 @@
},
{
"number": 1621,
"videochat": "<a href=\"https://zoom.us/j/9545579483?pwd=QUM3Um55MWV2RmFuWTJkb3ZKV2xQdz09\" target=\"_ohbm2020-1621\">zoom:9545579483</a> (password: \"visualqc\")",
"videochat": "https://zoom.us/j/9545579483?pwd=QUM3Um55MWV2RmFuWTJkb3ZKV2xQdz09",
"pdf": "https://crossinvalidation.com/2020/06/22/evaluating-visual-qc-protocols-for-freesurfer-parcellations-error-detection-rate-inter-rater-reliability-and-site-differences/"
},
{
Expand Down Expand Up @@ -5290,7 +5290,7 @@
},
{
"number": 1860,
"videochat": "<a href=\"https://meet.jit.si/DeepPrimateBrainShapes\" target=\"_DeepPrimateBrainShapes\">jitsi:DeepPrimateBrainShapes</a>",
"videochat": "DeepPrimateBrainShapes",
"pdf": "https://github.com/katjaq/brainscapes/blob/master/img/Heuer-Toro_BrainScapes_OHBM_2020.pdf"
},
{
Expand Down Expand Up @@ -5395,7 +5395,7 @@
},
{
"number": 1895,
"videochat": "<a href=\"https://meet.jit.si/bids-derivatives\" target=\"_bids-derivatives\">jitsi:bids-derivatives</a>",
"videochat": "bids-derivatives",
"pdf": "https://cdn-akamai.6connex.com/645/1827/poster_15922429379118925.pdf"
},
{
Expand Down Expand Up @@ -5503,7 +5503,7 @@
},
{
"number": 1929,
"videochat": "<a href=\"https://meet.jit.si/rsHRF_toolbox\" target=\"_rsHRF_toolbox\">jitsi:rsHRF_toolbox</a>",
"videochat": "rsHRF_toolbox",
"pdf": "https://github.com/sofievdbos/OHBM2020/blob/master/OHBM20_SVDB_interactive.pdf"
},
{
Expand Down
9 changes: 5 additions & 4 deletions room.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
<body>
<div id="meet"/>
<script>
let id = location.hash.substring(1); //poster id
let hash = location.hash.substring(1); //jitsi room name
let id = hash.split(".")[0];
let roomName = hash.split(".")[1];
let cid = Math.random().toString(); //client id

if(!id) alert("no number set in hash");
if(!roomName) alert("no room name set in hash");

let roomName = "ohbm2020-"+id;
console.log("opening room", roomName);
console.log(roomName);
const api = new JitsiMeetExternalAPI("meet.jit.si", {
roomName,
parentNode: document.querySelector('#meet')
Expand Down

0 comments on commit 6abdae9

Please sign in to comment.