/** * @licstart The following is the entire license notice for the * JavaScript code in this page. * * Copyright (C) 2015 Alicia ( https://ion.nu/ ) * * The JavaScript code in this page is free software: you can * redistribute it and/or modify it under the terms of the GNU * Affero General Public License (GNU AGPL) as published by the Free Software * Foundation, version 3 of the License. * The code is distributed WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU AGPL for more details. * * As additional permission under GNU AGPL version 3 section 7, you * may distribute non-source (e.g., minimized or compacted) forms of * that code without the copy of the GNU AGPL normally required by * section 4, provided you include this license notice and a URL * through which recipients can access the Corresponding Source. * * @licend The above is the entire license notice * for the JavaScript code in this page. */ var userlist=new Array(); var nickname=''; // Will be set with 'startnick:' var me; function User(name) { this.nickname=name; this.listlabel=document.createElement("span"); this.listlabel.textContent=this.nickname; this.listlabel.style.display='block'; var user=this; this.listlabel.oncontextmenu=function(e) // this.listlabel.onclick=function(e) { usermenu(user, e.pageX, e.pageY); return false; }; this.color='000000'; this.modprivileges=0; this.broadcasting=false; document.getElementById('userlist').appendChild(this.listlabel); } function finduser(name) { var i=0; while(idocument.body.clientWidth/2) { document.getElementById('usermenu').style.right=(document.body.clientWidth-x)+'px'; document.getElementById('usermenu').style.left='auto'; }else{ document.getElementById('usermenu').style.left=x+'px'; document.getElementById('usermenu').style.right='auto'; } document.getElementById('usermenu').style.top=y+'px'; document.getElementById('usermenu').style.display='block'; // Send private message document.getElementById('usermenu').children.pm.onclick=function() { var tab=findtab(user.nickname); if(!tab){tabs.push(tab=new Tab(user.nickname));} tab.focus(); document.getElementById('usermenu').style.display='none'; }; // Account/profile document.getElementById('usermenu').children.whois.onclick=function() { connection.send('whois:'+user.nickname); document.getElementById('usermenu').style.display='none'; } // Show/hide media streams if(user.broadcasting) { if(user.cam) { document.getElementById('usermenu').children.showmedia.style.display='none'; document.getElementById('usermenu').children.hidemedia.style.display='block'; document.getElementById('usermenu').children.hidemedia.onclick=function() { closecam(user); document.getElementById('usermenu').style.display='none'; } }else{ document.getElementById('usermenu').children.hidemedia.style.display='none'; document.getElementById('usermenu').children.showmedia.style.display='block'; document.getElementById('usermenu').children.showmedia.onclick=function() { opencam(user); document.getElementById('usermenu').style.display='none'; } } }else{ document.getElementById('usermenu').children.showmedia.style.display='none'; document.getElementById('usermenu').children.hidemedia.style.display='none'; } // Close media stream if(me.modprivileges&PRIV_CLOSECAM && user.broadcasting) { document.getElementById('usermenu').children.closemedia.style.display='block'; document.getElementById('usermenu').children.closemedia.onclick=function() { connection.send('closemedia:'+user.nickname); document.getElementById('usermenu').style.display='none'; } }else{ document.getElementById('usermenu').children.closemedia.style.display='none'; } // Ban if(me.modprivileges&PRIV_KICK) { document.getElementById('usermenu').children.ban.style.display='block'; document.getElementById('usermenu').children.ban.onclick=function() { connection.send('ban:'+user.nickname); document.getElementById('usermenu').style.display='none'; } }else{ document.getElementById('usermenu').children.ban.style.display='none'; } } function login(form) { document.getElementById('login').style.display='none'; connection.send('login:'+form.user.value+':'+form.pass.value); form.pass.value=''; } function createaccount(form) { // TODO: Check username availability upon onchange if(form.user.value.indexOf(':')>-1) { alert('Error: Usernames may not contain :'); } if(form.pass.value!=form.pass2.value) { alert('Error: Passwords don\'t match!'); return; } connection.send('createaccount:'+form.user.value+':'+form.pass.value); form.pass.value=''; form.pass2.value=''; document.getElementById('createaccount').style.display='none'; } function showfullscreen(name, focus) { document.getElementById(name).style.display='block'; if(focus) { document.getElementById(focus).focus(); document.getElementById(focus).select(); } } function setupmodmanager() { var list=document.getElementById('modmanagerlist'); while(list.children.length>0) { list.removeChild(list.children[0]); } connection.send('listmods'); } function addmoderator() { connection.send('addmod:'+document.getElementById('addmod_account').value+':'+PRIV_NONOWNER); document.getElementById('addmod_account').value=''; } function setupbanlist() { document.getElementById('banlist_placeholder').style.display='inline-block'; var list=document.getElementById('banlist_list'); while(list.children.length>0) { list.removeChild(list.children[0]); } connection.send('listbans'); }