1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-12-23 07:45:46 +01:00

Merge branch 'design' into master

This commit is contained in:
Juliusz Chroboczek 2020-09-11 19:03:23 +02:00
commit e698e187e6
17 changed files with 4090 additions and 210 deletions

69
static/404.css Normal file
View file

@ -0,0 +1,69 @@
body {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
height: 100vh;
padding: 0px 30px;
background: #ddd;
}
.wrapper {
max-width: 960px;
width: 100%;
margin: 30px auto;
transform: scale(0.8);
}
.landing-page {
max-width: 960px;
height: 475px;
margin: 0;
box-shadow: 0px 0px 8px 1px #ccc;
background: #fafafa;
border-radius: 8px;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.logo {
color: #7e7e7e;
font-size: 8em;
text-align: center;
line-height: 1.1;
}
.logo .fa {
color: #c39999;
}
h1 {
font-size: 48px;
margin: 0;
color: #7e7e7e;
}
p {
font-size: 18px;
width: 35%;
margin: 16px auto 24px;
text-align: center;
}
.home-link {
text-decoration: none;
border-radius: 8px;
padding: 12px 24px;
font-size: 18px;
cursor: pointer;
background: #610a86;
color: #fff;
border: none;
box-shadow: 0 4px 4px 0 #ccc;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}

29
static/404.html Normal file
View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Page not Found</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/common.css">
<link rel="stylesheet" type="text/css" href="/404.css"/>
<link rel="author" href="https://www.irif.fr/~jch/"/>
<!-- Font Awesome File -->
<link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css">
</head>
<body>
<div class="wrapper">
<div class="landing-page">
<div class="logo">
<i class="fa fa-frown-o" aria-hidden="true"></i>
</div>
<h1> Page not found!</h1>
<p> We can't find the page you're looking for.</p>
<a href="/" class="home-link">Back to home</a>
</div>
</div>
</body>
</html>

View file

@ -1,7 +1,3 @@
body {
font: 14px "Lato", Arial, sans-serif;
}
h1 {
font-size: 160%;
}
@ -12,8 +8,37 @@ h1 {
.signature {
border-top: solid;
margin-top: 2em;
padding-top: 0em;
padding-top: 0;
border-width: thin;
clear: both;
height: 3.125rem;
text-align: center;
}
body {
overflow-x: hidden;
}
body, html {
height: 100%;
}
body {
margin: 0;
font-family: Metropolis,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #687281;
text-align: left;
background-color: #eff3f9;
}
*, :after, :before {
box-sizing: border-box;
}
textarea {
font-family: Metropolis,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
}

4
static/css/font-awesome.min.css vendored Normal file

File diff suppressed because one or more lines are too long

15
static/css/toastify.min.css vendored Normal file
View file

@ -0,0 +1,15 @@
/**
* Minified by jsDelivr using clean-css v4.2.3.
* Original file: /npm/toastify-js@1.9.1/src/toastify.css
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
/*!
* Toastify js 1.9.1
* https://github.com/apvarun/toastify-js
* @license MIT licensed
*
* Copyright (C) 2018 Varun A P
*/
.toastify{padding:12px 20px;color:#fff;display:inline-block;box-shadow:0 3px 6px -1px rgba(0,0,0,.12),0 10px 36px -4px rgba(77,96,232,.3);background:-webkit-linear-gradient(315deg,#73a5ff,#5477f5);background:linear-gradient(135deg,#73a5ff,#5477f5);position:fixed;opacity:0;transition:all .4s cubic-bezier(.215,.61,.355,1);border-radius:2px;cursor:pointer;text-decoration:none;max-width:calc(50% - 20px);z-index:2147483647}.toastify.on{opacity:1}.toast-close{opacity:.4;padding:0 5px}.toastify-right{right:15px}.toastify-left{left:15px}.toastify-top{top:-150px}.toastify-bottom{bottom:-150px}.toastify-rounded{border-radius:25px}.toastify-avatar{width:1.5em;height:1.5em;margin:-7px 5px;border-radius:2px}.toastify-center{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}@media only screen and (max-width:360px){.toastify-left,.toastify-right{margin-left:auto;margin-right:auto;left:0;right:0;max-width:fit-content}}
/*# sourceMappingURL=/sm/9c0bbf2acc17f6468f9dd75307f4d772b55e466d0ddceef6dc95ee31ca309918.map */

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load diff

After

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -2,28 +2,37 @@
<html lang="en">
<head>
<title>SFU</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/common.css">
<link rel="stylesheet" href="/mainpage.css">
<link rel="stylesheet" type="text/css" href="/sfu.css"/>
<link rel="author" href="https://www.irif.fr/~jch/"/>
<!-- Font Awesome File -->
<link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css">
</head>
<body>
<h1>SFU</h1>
<div class="home">
<h1 id="title" class="navbar-brand">SFU</h1>
<form id="groupform">
<label for="group">Group:</label>
<input id="group" type="text" name="group"/>
<input type="submit" value="Join"/><br/>
</form>
<div id="public-groups" class="groups">
<h2>Public groups</h2>
<table id="public-groups-table"></table>
<form id="groupform">
<label for="group">Group:</label>
<input id="group" type="text" name="group" class="form-control form-control-inline"/>
<input type="submit" value="Join" class="btn btn-default btn-large"/><br/>
</form>
<div id="public-groups" class="groups">
<h2>Public groups</h2>
<table id="public-groups-table"></table>
</div>
</div>
<footer class="signature"><p><a href="https://www.irif.fr/~jch/software/sfu/">Unnamed SFU</a> by <a href="https://www.irif.fr/~jch/" rel="author">Juliusz Chroboczek</a></footer>
<footer class="signature">
<p><a href="https://www.irif.fr/~jch/software/sfu/">Unnamed SFU</a> by <a href="https://www.irif.fr/~jch/" rel="author">Juliusz Chroboczek</a>
</footer>
<script src="/mainpage.js" defer></script>
</body>

View file

@ -5,4 +5,36 @@
display: none;
}
.navbar-brand {
margin-bottom: 5rem;
}
.home {
height: calc(100vh - 50px);
padding: 1.875rem;
}
#public-groups-table tr a{
margin-left: 0.9375rem;
font-weight: 700;
}
a {
text-decoration: none;
color: #0058e4;
}
a:hover {
color: #0a429c;
}
label {
display: block;
}
@media only screen and (max-device-width: 768px) {
.home {
padding: 0.625rem;
}
}

View file

@ -0,0 +1,8 @@
/**
* Minified by jsDelivr using Terser v3.14.1.
* Original file: /npm/toastify-js@1.9.1/src/toastify.js
*
* Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
*/
!function(t,o){"object"==typeof module&&module.exports?module.exports=o():t.Toastify=o()}(this,function(t){var o=function(t){return new o.lib.init(t)};function i(t,o){return o.offset[t]?isNaN(o.offset[t])?o.offset[t]:o.offset[t]+"px":"0px"}function s(t,o){return!(!t||"string"!=typeof o)&&!!(t.className&&t.className.trim().split(/\s+/gi).indexOf(o)>-1)}return o.lib=o.prototype={toastify:"1.9.1",constructor:o,init:function(t){t||(t={}),this.options={},this.toastElement=null,this.options.text=t.text||"Hi there!",this.options.node=t.node,this.options.duration=0===t.duration?0:t.duration||3e3,this.options.selector=t.selector,this.options.callback=t.callback||function(){},this.options.destination=t.destination,this.options.newWindow=t.newWindow||!1,this.options.close=t.close||!1,this.options.gravity="bottom"===t.gravity?"toastify-bottom":"toastify-top",this.options.positionLeft=t.positionLeft||!1,this.options.position=t.position||"",this.options.backgroundColor=t.backgroundColor,this.options.avatar=t.avatar||"",this.options.className=t.className||"",this.options.stopOnFocus=void 0===t.stopOnFocus||t.stopOnFocus,this.options.onClick=t.onClick;return this.options.offset=t.offset||{x:0,y:0},this},buildToast:function(){if(!this.options)throw"Toastify is not initialized";var t=document.createElement("div");if(t.className="toastify on "+this.options.className,this.options.position?t.className+=" toastify-"+this.options.position:!0===this.options.positionLeft?(t.className+=" toastify-left",console.warn("Property `positionLeft` will be depreciated in further versions. Please use `position` instead.")):t.className+=" toastify-right",t.className+=" "+this.options.gravity,this.options.backgroundColor&&(t.style.background=this.options.backgroundColor),this.options.node&&this.options.node.nodeType===Node.ELEMENT_NODE)t.appendChild(this.options.node);else if(t.innerHTML=this.options.text,""!==this.options.avatar){var o=document.createElement("img");o.src=this.options.avatar,o.className="toastify-avatar","left"==this.options.position||!0===this.options.positionLeft?t.appendChild(o):t.insertAdjacentElement("afterbegin",o)}if(!0===this.options.close){var s=document.createElement("span");s.innerHTML="&#10006;",s.className="toast-close",s.addEventListener("click",function(t){t.stopPropagation(),this.removeElement(this.toastElement),window.clearTimeout(this.toastElement.timeOutValue)}.bind(this));var n=window.innerWidth>0?window.innerWidth:screen.width;("left"==this.options.position||!0===this.options.positionLeft)&&n>360?t.insertAdjacentElement("afterbegin",s):t.appendChild(s)}if(this.options.stopOnFocus&&this.options.duration>0){const o=this;t.addEventListener("mouseover",function(o){window.clearTimeout(t.timeOutValue)}),t.addEventListener("mouseleave",function(){t.timeOutValue=window.setTimeout(function(){o.removeElement(t)},o.options.duration)})}if(void 0!==this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),!0===this.options.newWindow?window.open(this.options.destination,"_blank"):window.location=this.options.destination}.bind(this)),"function"==typeof this.options.onClick&&void 0===this.options.destination&&t.addEventListener("click",function(t){t.stopPropagation(),this.options.onClick()}.bind(this)),"object"==typeof this.options.offset){var e=i("x",this.options),a=i("y",this.options);const o="left"==this.options.position?e:`-${e}`,s="toastify-top"==this.options.gravity?a:`-${a}`;t.style.transform=`translate(${o}, ${s})`}return t},showToast:function(){var t;if(this.toastElement=this.buildToast(),!(t=void 0===this.options.selector?document.body:document.getElementById(this.options.selector)))throw"Root element is not defined";return t.insertBefore(this.toastElement,t.firstChild),o.reposition(),this.options.duration>0&&(this.toastElement.timeOutValue=window.setTimeout(function(){this.removeElement(this.toastElement)}.bind(this),this.options.duration)),this},hideToast:function(){this.toastElement.timeOutValue&&clearTimeout(this.toastElement.timeOutValue),this.removeElement(this.toastElement)},removeElement:function(t){t.className=t.className.replace(" on",""),window.setTimeout(function(){this.options.node&&this.options.node.parentNode&&this.options.node.parentNode.removeChild(this.options.node),t.parentNode&&t.parentNode.removeChild(t),this.options.callback.call(t),o.reposition()}.bind(this),400)}},o.reposition=function(){for(var t,o={top:15,bottom:15},i={top:15,bottom:15},n={top:15,bottom:15},e=document.getElementsByClassName("toastify"),a=0;a<e.length;a++){t=!0===s(e[a],"toastify-top")?"toastify-top":"toastify-bottom";var p=e[a].offsetHeight;t=t.substr(9,t.length-1);(window.innerWidth>0?window.innerWidth:screen.width)<=360?(e[a].style[t]=n[t]+"px",n[t]+=p+15):!0===s(e[a],"toastify-left")?(e[a].style[t]=o[t]+"px",o[t]+=p+15):(e[a].style[t]=i[t]+"px",i[t]+=p+15)}return this},o.lib.init.prototype=o.lib,o});
//# sourceMappingURL=/sm/1df7b098cd6209fd67b5cc8f6f6518b79e5214ec3802d91f56f825883253df69.map

File diff suppressed because it is too large Load diff

View file

@ -2,56 +2,164 @@
<html lang="en">
<head>
<title>SFU</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="ScreenOrientation" content="autoRotate:disabled">
<link rel="stylesheet" type="text/css" href="/common.css"/>
<link rel="stylesheet" type="text/css" href="/sfu.css"/>
<link rel="author" href="https://www.irif.fr/~jch/"/>
<!-- Font Awesome File -->
<link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/css/toastify.min.css">
</head>
<body>
<h1 id="title">SFU</h1>
<div id="main" class="app">
<div class="row full-height">
<nav id="left-sidebar">
<div class="users-header">
<div class="sfu-header">SFU</div>
</div>
<div class="header-sep"></div>
<div id="users"></div>
</nav>
<div class="container">
<header>
<nav class="topnav navbar navbar-expand navbar-light fixed-top">
<div id="header">
<div class="collapse" title="Collapse left panel" id="sidebarCollapse">
<svg class="svg-inline--fa" aria-hidden="true" data-icon="align-left" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">
<path fill="currentColor" d="M288 44v40c0 8.837-7.163 16-16 16H16c-8.837 0-16-7.163-16-16V44c0-8.837 7.163-16 16-16h256c8.837 0 16 7.163 16 16zM0 172v40c0 8.837 7.163 16 16 16h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16zm16 312h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm256-200H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16h256c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16z"></path>
</svg>
</div>
<h1 id="title" class="header-title"></h1>
</div>
<div id="header">
<div id="statdiv">
<span id="statspan"></span>
<span id="userspan"></span>
<form id="userform" class="userform">
<label for="username">Username:</label>
<input id="username" type="text" name="username"
autocomplete="username"/>
<label for="password">Password:</label>
<input id="password" type="password" name="password"
autocomplete="current-password"/>
<input id="connectbutton" type="submit" value="Connect" disabled/>
</form>
<input id="disconnectbutton" class="invisible"
type="submit" value="Disconnect"/>
<span id="errspan"></span>
<ul class="nav-menu">
<li>
<button id="presentbutton" class="invisible btn btn-success">
<i class="fa fa-video-camera" aria-hidden="true"></i><span class="nav-text"> Present</span>
</button>
</li>
<li>
<button id="unpresentbutton" class="invisible btn btn-cancel">
<i class="fa fa-stop" aria-hidden="true"></i><span class="nav-text"> Stop presenting</span>
</button>
</li>
<li>
<div id="mutebutton" class="nav-link nav-button">
<span><i class="fa fa-microphone-slash" aria-hidden="true"></i></span>
<label>Mute</label>
</div>
</li>
<li>
<div id="sharebutton" class="invisible nav-link nav-button">
<span><i class="fa fa-share-square-o" aria-hidden="true"></i></span>
<label>Share Screen</label>
</div>
</li>
<li>
<div id="unsharebutton" class="invisible nav-link nav-button nav-cancel">
<span><i class="fa fa-window-close-o" aria-hidden="true"></i></span>
<label>Unshare Screen</label>
</div>
</li>
<li>
<div class="nav-button nav-link invisible" id="user">
<span><i class="fa fa-user dropbtn" aria-hidden="true"></i></span>
<label>User</label>
</div>
<div id="userDropdown" class="dropdown-content">
<div id="statdiv">
<span id="statspan"></span>
<span id="userspan"></span>
<div class="clear"></div>
<input id="disconnectbutton" class="btn btn-warn"
type="submit" value="Disconnect"/>
<span id="errspan"></span>
</div>
</div>
</li>
<li>
<div class="nav-button nav-link" id="openside">
<span><i class="fa fa-cog" aria-hidden="true"></i></span>
<label>Settings</label>
</div>
</li>
</ul>
</nav>
</header>
<div class="row full-width" id="mainrow">
<div class="coln-left" id="left">
<div id="chat">
<div id="chatbox">
<div id="box"></div>
<div class="reply">
<form id="inputform">
<textarea id="input" class="form-reply"></textarea>
<input id="inputbutton" type="submit" value="&#10148;" class="btn btn-default"/>
</form>
</div>
</div>
</div>
</div>
<div id="resizer"></div>
<div class="coln-right" id="right">
<span class="show-video blink" id="switch-video"><i class="fa fa-exchange" aria-hidden="true"></i></span>
<div class="collapse-video" id="collapse-video">
<svg viewBox="-21 -47 682.66669 682" xmlns="http://www.w3.org/2000/svg" class="open-chat">
<path d="m552.011719-1.332031h-464.023438c-48.515625 0-87.988281 39.464843-87.988281 87.988281v283.972656c0 48.414063 39.300781 87.816406 87.675781 87.988282v128.863281l185.191407-128.863281h279.144531c48.515625 0 87.988281-39.472657 87.988281-87.988282v-283.972656c0-48.523438-39.472656-87.988281-87.988281-87.988281zm50.488281 371.960937c0 27.835938-22.648438 50.488282-50.488281 50.488282h-290.910157l-135.925781 94.585937v-94.585937h-37.1875c-27.839843 0-50.488281-22.652344-50.488281-50.488282v-283.972656c0-27.84375 22.648438-50.488281 50.488281-50.488281h464.023438c27.839843 0 50.488281 22.644531 50.488281 50.488281zm0 0"/>
<path d="m171.292969 131.171875h297.414062v37.5h-297.414062zm0 0"/>
<path d="m171.292969 211.171875h297.414062v37.5h-297.414062zm0 0"/>
<path d="m171.292969 291.171875h297.414062v37.5h-297.414062zm0 0"/>
</svg>
</div>
<div class="video-container no-video" id="video-container">
<div id="peers"></div>
</div>
<div class="login-container invisible" id="login-container">
<div class="login-box">
<form id="userform" class="userform">
<label for="username">Username:</label>
<input id="username" type="text" name="username"
autocomplete="username" class="form-control"/>
<label for="password">Password:</label>
<input id="password" type="password" name="password"
autocomplete="current-password" class="form-control"/>
<div class="clear"></div>
<input id="connectbutton" type="submit" class="btn btn-blue" value="Connect"/>
</form>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="optionsdiv">
<button id="presentbutton" class="invisible">Present</button>
<button id="unpresentbutton" class="invisible">Stop presenting</button>
<span id="mediaoptions">
<div id="sidebarnav" class="sidenav">
<div class="sidenav-header">
<h2>Settings</h2>
<a class="closebtn" id="clodeside"><i class="fa fa-times" aria-hidden="true"></i></a>
</div>
<div class="sidenav-content" id="optionsdiv">
<div id="mediaoptions">
<label for="videoselect">Camera:</label>
<select id="videoselect">
<select id="videoselect" class="select select-inline">
<option>default</option>
<option>off</option>
</select>
<label for="audioselect">Microphone:</label>
<select id="audioselect">
<select id="audioselect" class="select select-inline">
<option>default</option>
<option>off</option>
</select>
<button id="mutebutton">Mute</button>
</span>
<button id="sharebutton" class="invisible">Share screen</button>
<button id="unsharebutton" class="invisible">Stop sharing</button>
</div>
<label for="sendselect">Send:</label>
<select id="sendselect">
<select id="sendselect" class="select select-inline">
<option value="lowest">lowest</option>
<option value="low">low</option>
<option value="normal" selected>normal</option>
@ -59,7 +167,7 @@
</select>
<label for="requestselect">Receive:</label>
<select id="requestselect">
<select id="requestselect" class="select select-inline">
<option value="audio">audio only</option>
<option value="screenshare">screen share</option>
<option value="everything" selected>everything</option>
@ -67,24 +175,8 @@
</div>
</div>
<div id="main">
<div id="users"></div>
<div id="chat">
<div id="chatbox">
<div id="box"></div>
<form id="inputform">
<textarea id="input"></textarea>
<input id="inputbutton" type="submit" value="&#10148;"/>
</form>
</div>
<div id="resizer">
</div>
</div>
<div id="peers"></div>
</div>
<script src="/protocol.js" defer></script>
<script src="/sfu.js" defer></script>
<script src="/scripts/toastify.js" defer></script>
</body>
</html>

View file

@ -45,23 +45,47 @@ function getUsername() {
return userpass.username;
}
function showVideo() {
let width = window.innerWidth;
let video_container = document.getElementById('video-container');
video_container.classList.remove('no-video');
if (width <= 768)
document.getElementById('collapse-video').style.display = "block";
}
function hideVideo(force) {
let mediadiv = document.getElementById('peers');
if (force === undefined) {
force = false;
}
if (mediadiv.childElementCount > 0 && !force) {
return;
}
let video_container = document.getElementById('video-container');
video_container.classList.add('no-video');
}
function closeVideoControls() {
// hide all video buttons used to switch video on mobile layout
document.getElementById('switch-video').style.display = "";
document.getElementById('collapse-video').style.display = "";
}
/**
* @param{boolean} connected
*/
function setConnected(connected) {
let statspan = document.getElementById('statspan');
let userform = document.getElementById('userform');
let disconnectbutton = document.getElementById('disconnectbutton');
let userbox = document.getElementById('user');
let connectionbox = document.getElementById('login-container');
if(connected) {
clearError();
resetUsers();
clearChat();
statspan.textContent = 'Connected';
statspan.classList.remove('disconnected');
statspan.classList.add('connected');
userform.classList.add('invisible');
userform.classList.remove('userform');
disconnectbutton.classList.remove('invisible');
userbox.classList.remove('invisible');
connectionbox.classList.add('invisible');
displayUsername();
} else {
resetUsers();
@ -73,10 +97,12 @@ function setConnected(connected) {
statspan.textContent = 'Disconnected';
statspan.classList.remove('connected');
statspan.classList.add('disconnected');
userform.classList.add('userform');
userform.classList.remove('invisible');
disconnectbutton.classList.add('invisible');
userbox.classList.add('invisible');
connectionbox.classList.remove('invisible');
clearUsername();
displayError("Disconnected!", "error");
hideVideo();
closeVideoControls();
}
}
@ -91,8 +117,9 @@ function gotConnected() {
function gotClose(code, reason) {
delUpMediaKind(null);
setConnected(false);
if(code != 1000)
if(code != 1000) {
console.warn('Socket close', code, reason);
}
}
/**
@ -117,6 +144,16 @@ function gotDownStream(c) {
}
}
// Store current browser viewport height in css variable
function setViewportHeight() {
document.documentElement.style.setProperty('--vh', `${window.innerHeight/100}px`);
};
setViewportHeight();
// On resize and orientation change, we update viewport height
addEventListener('resize', setViewportHeight);
addEventListener('orientationchange', setViewportHeight);
document.getElementById('presentbutton').onclick = function(e) {
e.preventDefault();
addLocalMedia();
@ -125,6 +162,7 @@ document.getElementById('presentbutton').onclick = function(e) {
document.getElementById('unpresentbutton').onclick = function(e) {
e.preventDefault();
delUpMediaKind('local');
resizePeers();
};
function changePresentation() {
@ -171,11 +209,16 @@ function setLocalMute(mute) {
localMute = mute;
muteLocalTracks(localMute);
let button = document.getElementById('mutebutton');
button.textContent = localMute ? 'Unmute' : 'Mute';
if(localMute)
let icon = button.querySelector("span .fa");
if(localMute){
icon.classList.add('fa-microphone-slash');
icon.classList.remove('fa-microphone');
button.classList.add('muted');
else
} else {
icon.classList.remove('fa-microphone-slash');
icon.classList.add('fa-microphone');
button.classList.remove('muted');
}
}
document.getElementById('videoselect').onchange = function(e) {
@ -417,7 +460,7 @@ async function addLocalMedia(id) {
c.onstats = displayStats;
c.setStatsInterval(2000);
await setMedia(c, true);
setButtonsVisibility()
setButtonsVisibility();
}
async function addShareMedia(setup) {
@ -493,7 +536,8 @@ function delUpMediaKind(kind) {
delete(serverConnection.up[id]);
}
setButtonsVisibility()
setButtonsVisibility();
hideVideo();
}
function findUpMedia(kind) {
@ -560,6 +604,7 @@ function setMedia(c, isUp) {
setLabel(c);
setMediaStatus(c);
showVideo();
resizePeers();
}
@ -574,6 +619,7 @@ function delMedia(id) {
mediadiv.removeChild(peer);
resizePeers();
hideVideo();
}
/**
@ -620,9 +666,26 @@ function resizePeers() {
let count =
Object.keys(serverConnection.up).length +
Object.keys(serverConnection.down).length;
let peers = document.getElementById('peers');
let columns = Math.ceil(Math.sqrt(count));
document.getElementById('peers').style['grid-template-columns'] =
`repeat(${columns}, 1fr)`;
if (!count)
// No video, nothing to resize.
return;
let size = 100 / columns;
let container = document.getElementById("video-container")
// Peers div has total padding of 30px, we remove 30 on offsetHeight
let max_video_height = Math.trunc((peers.offsetHeight - 30) / columns);
let media_list = document.getElementsByClassName("media");
[].forEach.call(media_list, function (element) {
element.style['max-height'] = max_video_height + "px";
});
if (count <= 2 && container.offsetHeight > container.offsetWidth) {
peers.style['grid-template-columns'] = "repeat(1, 1fr)";
} else {
peers.style['grid-template-columns'] = `repeat(${columns}, 1fr)`;
}
}
/** @type{Object.<string,string>} */
@ -642,6 +705,7 @@ function addUser(id, name) {
let div = document.getElementById('users');
let user = document.createElement('div');
user.id = 'user-' + id;
user.classList.add("user-p");
user.textContent = name ? name : '(anon)';
div.appendChild(user);
}
@ -711,6 +775,9 @@ function clearUsername() {
function gotPermissions(perms) {
displayUsername();
setButtonsVisibility();
if(serverConnection.permissions.present)
displayMessage("Press Present to enable your camera or microphone",
"info");
}
const urlRegexp = /https?:\/\/[-a-zA-Z0-9@:%/._\\+~#=?]+[-a-zA-Z0-9@:%/_\\+~#=]/g;
@ -759,8 +826,15 @@ function formatLines(lines) {
let lastMessage = {};
function addToChatbox(peerId, nick, kind, message){
let userpass = getUserPass();
let row = document.createElement('div');
row.classList.add('message-row');
let container = document.createElement('div');
container.classList.add('message');
row.appendChild(container);
if (userpass.username === nick) {
container.classList.add('message-sender');
}
if(kind !== 'me') {
let p = formatLines(message.split('\n'));
if (lastMessage.nick !== nick || lastMessage.peerId !== peerId) {
@ -794,7 +868,7 @@ function addToChatbox(peerId, nick, kind, message){
}
let box = document.getElementById('box');
box.appendChild(container);
box.appendChild(row);
if(box.scrollHeight > box.clientHeight) {
box.scrollTop = box.scrollHeight - box.clientHeight;
}
@ -928,19 +1002,17 @@ document.getElementById('input').onkeypress = function(e) {
function chatResizer(e) {
e.preventDefault();
let chat = document.getElementById('chat');
let full_width = document.getElementById("mainrow").offsetWidth;
let left = document.getElementById("left");
let right = document.getElementById("right");
let start_x = e.clientX;
let start_width = parseFloat(
document.defaultView.getComputedStyle(chat).width.replace('px', ''),
);
let inputbutton = document.getElementById('inputbutton');
let start_width = parseFloat(left.offsetWidth);
function start_drag(e) {
let width = start_width + e.clientX - start_x;
if(width < 40)
inputbutton.style.display = 'none';
else
inputbutton.style.display = 'inline';
chat.style.width = width + 'px';
let left_width = (start_width + e.clientX - start_x) * 100 / full_width;
left.style.flex = left_width;
right.style.flex = 100 - left_width;
}
function stop_drag(e) {
document.documentElement.removeEventListener(
@ -961,39 +1033,33 @@ function chatResizer(e) {
document.getElementById('resizer').addEventListener('mousedown', chatResizer, false);
/** @type {number} */
let errorTimeout = null;
function setErrorTimeout(ms) {
if(errorTimeout) {
clearTimeout(errorTimeout);
errorTimeout = null;
function displayError(message, level, position, gravity) {
var background = "linear-gradient(to right, #e20a0a, #df2d2d)";
if (level === "info") {
background = "linear-gradient(to right, #529518, #96c93d)";
}
if(ms) {
errorTimeout = setTimeout(clearError, ms);
if (level === "warning") {
background = "linear-gradient(to right, #edd800, #c9c200)";
}
}
function displayError(message) {
let errspan = document.getElementById('errspan');
errspan.textContent = message;
errspan.classList.remove('noerror');
errspan.classList.add('error');
setErrorTimeout(8000);
Toastify({
text: message,
duration: 4000,
close: true,
position: position ? position: 'center',
gravity: gravity ? gravity : 'top',
backgroundColor: background,
className: level,
}).showToast();
}
function displayWarning(message) {
// don't overwrite real errors
if(!errorTimeout)
return displayError(message);
let level = "warning";
return displayError(message, level);
}
function clearError() {
let errspan = document.getElementById('errspan');
errspan.textContent = '';
errspan.classList.remove('error');
errspan.classList.add('noerror');
setErrorTimeout(null);
function displayMessage(message) {
return displayError(message, "info", "right", "bottom");
}
document.getElementById('userform').onsubmit = function(e) {
@ -1006,6 +1072,82 @@ document.getElementById('userform').onsubmit = function(e) {
document.getElementById('disconnectbutton').onclick = function(e) {
serverConnection.close();
let user_box = document.getElementById('userDropdown');
if (user_box.classList.contains("show")) {
user_box.classList.toggle("show");
}
};
function openNav() {
document.getElementById("sidebarnav").style.width = "250px";
}
function closeNav() {
document.getElementById("sidebarnav").style.width = "0";
}
document.getElementById('sidebarCollapse').onclick = function(e) {
document.getElementById("left-sidebar").classList.toggle("active");
document.getElementById("mainrow").classList.toggle("full-width-active");
};
document.getElementById('openside').onclick = function(e) {
e.preventDefault();
let sidewidth = document.getElementById("sidebarnav").style.width;
if (sidewidth !== "0px" && sidewidth !== "") {
closeNav();
return;
} else {
openNav();
}
};
document.getElementById('user').onclick = function(e) {
e.preventDefault();
document.getElementById("userDropdown").classList.toggle("show");
};
document.getElementById('clodeside').onclick = function(e) {
e.preventDefault();
closeNav();
};
document.getElementById('collapse-video').onclick = function(e) {
e.preventDefault();
let width = window.innerWidth;
if (width <= 768) {
let user_box = document.getElementById('userDropdown');
if (user_box.classList.contains("show")) {
return;
}
// fixed div for small screen
this.style.display = "";
hideVideo(true);
document.getElementById('switch-video').style.display = "block";
}
};
document.getElementById('switch-video').onclick = function(e) {
e.preventDefault();
showVideo();
this.style.display = "";
document.getElementById('collapse-video').style.display = "block";
};
window.onclick = function(event) {
let user_box = document.getElementById('userDropdown');
if (user_box.classList.contains("show") && event.target.id != "user") {
let parent = event.target;
while (parent.id !== "main" && parent.id !== "userDropdown" &&
parent.id !== "user" && parent.tagName !== "body") {
parent = parent.parentNode;
}
if (parent.id !="userDropdown" && parent.id !== "user") {
user_box.classList.toggle("show");
}
}
};
function serverConnect() {
@ -1036,11 +1178,14 @@ function start() {
setLocalMute(localMute);
document.getElementById('connectbutton').disabled = false;
let userpass = getUserPass();
if(userpass)
serverConnect();
else {
document.getElementById("user").classList.add('invisible');
document.getElementById("login-container").classList.remove('invisible');
}
}
start();