The design is based around dynamic chat urls: pastebin.com/raw/L1bCwezZ
<!DOCTYPE html>
<html>
<head>
<style>
.z {
background-color:grey;
color:green;
font-size:20px;
cursor:pointer;
}
</style>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>test server for tws</title>
</head>
<body>
<script>
//if users change name or change img url
//it will update latest changes
//if its blank, no changes
// cur : { ide : {'name':'','img':''},
// ide : {'name':'','img':''}
// }
var servername='tws1920';
var info={};
function parsethat() {
//do stuff with info
alert(info['newroom']); //comment this
var controls = document.getElementById('modcontrols');
if (controls.style.display == 'none' && info['ismod']) {
controls.style.display='block';
}
loadchat();
}
function loadchat() {
var frame = document.getElementById('jitsiConferenceFrame0');
var chatide='';
if (frame.src != null) {
chatide = frame.src.split('.com/')[1].split('?')[0];
}
if (chatide != info['newroom'] ) {
frame.src=frame.src.replace(chatide,info['newroom']);
}
if (Number(info['kicktime']) > 0 ) {
//remove chatframe
//show countdown until kick time over
//etc
//if user knows jitsi URL they can still
//technically get in, but it could change in 5-10 minutes
// or whenver mod wants
//ie: blocking spammers
}
}
function getinfo(forcenew=0,kick='',call='') {
var f = new FormData();
f.append("name", username);
f.append('img',userimg);
f.append('ide',userid);
f.append('kick',kick); //userid
// f.append('call',call); //userid
f.append('room',roomname);
//name of the room user is in
f.append('forcenew',forcenew); //1 for forcenew
//this forces everyone to load a new newname of chat
//possibly redistibute mod powers randomly
//if creator is not in room
//server auto determines who has authorization to dothis
// ie: whoever first is in room (creator) if they're still in it
//else whoever was there first
//you cant abuse this, server is too smart
xhr11 = new XMLHttpRequest();
xhr11.open('POST', 'https://'+servername+'.pythonanywhere.com/tws');
xhr11.onload = function() {
if (xhr11.status === 200) {
var zq = xhr11.responseText;
if (zq!='-1') {
alert(zq); //comment this
info = JSON.parse(zq);
// use this info somewhere else
parsethat();
return true;
}
}
else if (xhr11.status !== 200) {
// alert('Request failed. Returned status of ' + xhr11.status);
var dude = 'hi';
}
};
xhr11.send(f);
}
//point of this server is to automate a spam free environment
//also adding features like number of users online
// which rooms people are chatting in
//there are mod controls like kick and force new chat
//HOWEVER, it is not necessary to use them
//new_chats will load automatically as dictated by server
//every 5-10 minutes
//automatically blocking spammers and mod hogs
//this is automatic
//if a person is kicked, they will load a different room
//than the people who are not kicked
//they will not know whether they are kicked or not
//and have the opportunity to talk with other people
//while they their kicktime happens
//later i will emply different types of kicks available
//ie: kid kick, if a person is underage, then they all get pooled into an underage room
//spam kick, all spammers get sent to their own room where they cant spam anyone
//for custom control, mods can kick users &
//load new room by force
//at MINIMUM, all u have to do is change iframe.src behavior
//on parsing info json, user names, images, other things
//are there for later development
var username=''; //can be blank
var userimg = ''; //can be blank
var userid=''; //can supply or leave blank
//know what you're doing if u supply this
//that means YOU identify useride instead of server
//easier to let server manage it
//or not your choice
var roomname='the room name';
getinfo(); //on first load
// getinfo(1); //force new room ide
//ie: on a (load new room) button
//for moderator
//setInterval(getinfo,15000); //every 15 seconds
//integral that this is used
//to update info for all users
//
</script>
<div class="z" style="display:none;" id="modcontrols">
<b>mod controls</b><br>
<span onclick="getinfo(1)">force load new chat</span><br>
<div id="kickarea">loop through info['cur']<br>
show name/img, then onclick to getinfo(kick=ide)</div>
</div>
</body>
</html>