Commit 382446eb authored by Alain Takoudjou's avatar Alain Takoudjou

sfu: update layout and make video working with mobile too

parent 76e812d0
/**
* 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 */
\ No newline at end of file
/**
* 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
\ No newline at end of file
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
.navbar { .navbar {
position: relative; position: relative;
padding: .5rem; padding: .5rem;
border-bottom: 1px solid #e6e6e6; /*border-bottom: 1px solid #e6e6e6;*/
} }
.topnav .navbar-brand { .topnav .navbar-brand {
...@@ -211,10 +211,8 @@ ...@@ -211,10 +211,8 @@
.users-header { .users-header {
height: 53px; height: 53px;
padding: 10px; padding: 10px;
/*background: #eee;*/
/*background: #4b4c7b;*/
background: #610a86; background: #610a86;
border-bottom: 1px solid #e6e6e6; /*border-bottom: 1px solid #e6e6e6;*/
font-size: .95rem; font-size: .95rem;
font-weight: 500; font-weight: 500;
} }
...@@ -348,6 +346,21 @@ textarea.form-reply { ...@@ -348,6 +346,21 @@ textarea.form-reply {
/*height: 100%;*/ /*height: 100%;*/
height: calc(100vh - 53px); height: calc(100vh - 53px);
position: relative; position: relative;
background: rgba(0, 0, 0, 0.61);
/* Display only when showing video */
display: block;
transition: all 1s ease-out;
opacity: 1;
}
.no-video {
display: none;
transition: opacity 1s ease-out;
opacity: 0;
}
.mobile-container {
display: block !important;
} }
.label-fallback { .label-fallback {
...@@ -565,7 +578,7 @@ h1 { ...@@ -565,7 +578,7 @@ h1 {
#peers { #peers {
padding: 10px; padding: 10px;
display: grid; display: grid;
grid-template-columns: repeat(3, 1fr); grid-template-columns: repeat(1, 1fr);
grid-template-rows: repeat(2, auto); grid-template-rows: repeat(2, auto);
grid-gap: 20px; grid-gap: 20px;
position: absolute; position: absolute;
...@@ -668,6 +681,44 @@ h1 { ...@@ -668,6 +681,44 @@ h1 {
list-style: none; list-style: none;
} }
.show-video {
position: absolute;
display: none;
right: 30px;
bottom: 120px;
color: white;
width: 50px;
height: 50px;
text-align: center;
line-height: 50px;
font-size: 150%;
border-radius: 30px;
background: #600aa0;
-webkit-box-shadow: 4px 4px 7px 1px rgba(0,0,0,0.16);
-moz-box-shadow: 4px 4px 7px 1px rgba(0,0,0,0.16);
box-shadow: 4px 4px 7px 1px rgba(0,0,0,0.16);
}
.blink {
-webkit-animation: blink 1.0s linear infinite;
-moz-animation: blink 1.0s linear infinite;
-ms-animation: blink 1.0s linear infinite;
-o-animation: blink 1.0s linear infinite;
animation: blink 1.0s linear infinite;
}
@keyframes blink {
0% { box-shadow: 0 0 15px #600aa0; }
50% { box-shadow: none; }
100% { box-shadow: 0 0 15px #600aa0; }
}
@-webkit-keyframes blink {
0% { box-shadow: 0 0 15px #600aa0; }
50% { box-shadow: 0 0 0; }
100% { box-shadow: 0 0 15px #600aa0; }
}
/* Dropdown Menu */ /* Dropdown Menu */
.dropbtn { .dropbtn {
cursor: pointer; cursor: pointer;
...@@ -820,7 +871,7 @@ header .colapse { ...@@ -820,7 +871,7 @@ header .colapse {
} }
/*@media only screen and (max-width: 768px) {*/ /*@media only screen and (max-width: 768px) {*/
@media only screen and (max-device-width: 480px) { @media only screen and (max-device-width: 768px) {
.nav-link { .nav-link {
margin: 0; margin: 0;
} }
...@@ -833,14 +884,12 @@ header .colapse { ...@@ -833,14 +884,12 @@ header .colapse {
} }
.video-container { .video-container {
height: calc(100vh - 113px); height: calc(100vh - 53px);
position: fixed; position: fixed;
top: 53px; top: 53px;
right: 0; right: 0;
left: 0; left: 0;
margin-bottom: 60px; margin-bottom: 60px;
/* Display only when showing video */
display: none;
} }
.coln-left { .coln-left {
......
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
<html lang="en"> <html lang="en">
<head> <head>
<title>SFU</title> <title>SFU</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <!--<meta name="viewport" content="width=device-width, initial-scale=1.0">-->
<meta name="viewport" content="minimal-ui, width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="stylesheet" type="text/css" href="/common.css"/> <link rel="stylesheet" type="text/css" href="/common.css"/>
<link rel="stylesheet" type="text/css" href="/sfu.css"/> <link rel="stylesheet" type="text/css" href="/sfu.css"/>
<link rel="author" href="https://www.irif.fr/~jch/"/> <link rel="author" href="https://www.irif.fr/~jch/"/>
<!-- Font Awesome File --> <!-- Font Awesome File -->
<link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css"> <link rel="stylesheet" type="text/css" href="/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="/css/toastify.min.css">
</head> </head>
<body> <body>
...@@ -81,7 +83,8 @@ ...@@ -81,7 +83,8 @@
</div> </div>
</div> </div>
<div class="coln-right"> <div class="coln-right">
<div class="video-container"> <span class="show-video blink" id="switch-video"><i class="fa fa-exchange" aria-hidden="true"></i></span>
<div class="video-container no-video" id="video-container">
<div id="peers"></div> <div id="peers"></div>
</div> </div>
</div> </div>
...@@ -130,5 +133,6 @@ ...@@ -130,5 +133,6 @@
<script src="/protocol.js" defer></script> <script src="/protocol.js" defer></script>
<script src="/sfu.js" defer></script> <script src="/sfu.js" defer></script>
<script src="/scripts/toastify-js" defer></script>
</body> </body>
</html> </html>
...@@ -45,6 +45,25 @@ function getUsername() { ...@@ -45,6 +45,25 @@ function getUsername() {
return userpass.username; return userpass.username;
} }
function showVideo() {
let video_container = document.getElementById('video-container');
//video_container[0].style.display = "block";
video_container.classList.remove('no-video');
}
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.style.display = "";
video_container.classList.add('no-video');
}
/** /**
* @param{boolean} connected * @param{boolean} connected
*/ */
...@@ -54,7 +73,6 @@ function setConnected(connected) { ...@@ -54,7 +73,6 @@ function setConnected(connected) {
let disconnectbutton = document.getElementById('disconnectbutton'); let disconnectbutton = document.getElementById('disconnectbutton');
let connectbutton = document.getElementById('connectbutton'); let connectbutton = document.getElementById('connectbutton');
if(connected) { if(connected) {
clearError();
resetUsers(); resetUsers();
clearChat(); clearChat();
statspan.textContent = 'Connected'; statspan.textContent = 'Connected';
...@@ -80,6 +98,7 @@ function setConnected(connected) { ...@@ -80,6 +98,7 @@ function setConnected(connected) {
disconnectbutton.classList.add('invisible'); disconnectbutton.classList.add('invisible');
connectbutton.classList.remove('invisible'); connectbutton.classList.remove('invisible');
clearUsername(); clearUsername();
displayError("Disconnected!", "error");
} }
} }
...@@ -94,8 +113,10 @@ function gotConnected() { ...@@ -94,8 +113,10 @@ function gotConnected() {
function gotClose(code, reason) { function gotClose(code, reason) {
delUpMediaKind(null); delUpMediaKind(null);
setConnected(false); setConnected(false);
if(code != 1000) if(code != 1000) {
//displayError('Socket close: Code ' + code, "error");
console.warn('Socket close', code, reason); console.warn('Socket close', code, reason);
}
} }
/** /**
...@@ -157,7 +178,7 @@ function setButtonsVisibility() { ...@@ -157,7 +178,7 @@ function setButtonsVisibility() {
setVisibility('presentbutton', permissions.present && !local); setVisibility('presentbutton', permissions.present && !local);
setVisibility('unpresentbutton', local); setVisibility('unpresentbutton', local);
// allow multiple shared documents // allow multiple shared documents
setVisibility('sharebutton', permissions.present); setVisibility('sharebutton', permissions.present && !share);
setVisibility('unsharebutton', share); setVisibility('unsharebutton', share);
setVisibility('mediaoptions', permissions.present); setVisibility('mediaoptions', permissions.present);
...@@ -420,7 +441,7 @@ async function addLocalMedia(id) { ...@@ -420,7 +441,7 @@ async function addLocalMedia(id) {
c.onstats = displayStats; c.onstats = displayStats;
c.setStatsInterval(2000); c.setStatsInterval(2000);
await setMedia(c, true); await setMedia(c, true);
setButtonsVisibility() setButtonsVisibility();
} }
async function addShareMedia(setup) { async function addShareMedia(setup) {
...@@ -496,7 +517,8 @@ function delUpMediaKind(kind) { ...@@ -496,7 +517,8 @@ function delUpMediaKind(kind) {
delete(serverConnection.up[id]); delete(serverConnection.up[id]);
} }
setButtonsVisibility() setButtonsVisibility();
hideVideo();
} }
function findUpMedia(kind) { function findUpMedia(kind) {
...@@ -563,6 +585,7 @@ function setMedia(c, isUp) { ...@@ -563,6 +585,7 @@ function setMedia(c, isUp) {
setLabel(c); setLabel(c);
setMediaStatus(c); setMediaStatus(c);
showVideo();
resizePeers(); resizePeers();
} }
...@@ -577,6 +600,7 @@ function delMedia(id) { ...@@ -577,6 +600,7 @@ function delMedia(id) {
mediadiv.removeChild(peer); mediadiv.removeChild(peer);
resizePeers(); resizePeers();
hideVideo();
} }
/** /**
...@@ -623,9 +647,16 @@ function resizePeers() { ...@@ -623,9 +647,16 @@ function resizePeers() {
let count = let count =
Object.keys(serverConnection.up).length + Object.keys(serverConnection.up).length +
Object.keys(serverConnection.down).length; Object.keys(serverConnection.down).length;
let peers = document.getElementById('peers');
let columns = Math.ceil(Math.sqrt(count)); let columns = Math.ceil(Math.sqrt(count));
document.getElementById('peers').style['grid-template-columns'] = if (columns > 1) {
`repeat(${columns}, 1fr)`; if (peers.offsetWidth < peers.offsetHeight) {
// we change view orientation
peers.style['grid-template-rows'] = `repeat(${columns}, auto)`;
}
} else {
peers.style['grid-template-columns'] = `repeat(${columns}, 1fr)`;
}
} }
/** @type{Object.<string,string>} */ /** @type{Object.<string,string>} */
...@@ -967,25 +998,21 @@ function chatResizer(e) { ...@@ -967,25 +998,21 @@ function chatResizer(e) {
document.getElementById('resizer').addEventListener('mousedown', chatResizer, false); document.getElementById('resizer').addEventListener('mousedown', chatResizer, false);
/** @type {number} */
let errorTimeout = null;
function setErrorTimeout(ms) {
if(errorTimeout) {
clearTimeout(errorTimeout);
errorTimeout = null;
}
if(ms) {
errorTimeout = setTimeout(clearError, ms);
}
}
function displayError(message) { function displayError(message, level) {
let errspan = document.getElementById('errspan'); var background = "linear-gradient(to right, #529518, #96c93d)";
errspan.textContent = message; if (level === undefined || level === "error") {
errspan.classList.remove('noerror'); level = "error";
errspan.classList.add('error'); background = "linear-gradient(to right, #e20a0a, #df2d2d)";
setErrorTimeout(8000); }
Toastify({
text: message,
duration: 5000,
close: true,
position: 'center',
backgroundColor: background,
className: level,
}).showToast();
} }
function displayWarning(message) { function displayWarning(message) {
...@@ -994,14 +1021,6 @@ function displayWarning(message) { ...@@ -994,14 +1021,6 @@ function displayWarning(message) {
return displayError(message); return displayError(message);
} }
function clearError() {
let errspan = document.getElementById('errspan');
errspan.textContent = '';
errspan.classList.remove('error');
errspan.classList.add('noerror');
setErrorTimeout(null);
}
document.getElementById('userform').onsubmit = function(e) { document.getElementById('userform').onsubmit = function(e) {
e.preventDefault(); e.preventDefault();
let username = document.getElementById('username').value.trim(); let username = document.getElementById('username').value.trim();
...@@ -1042,12 +1061,46 @@ document.getElementById('user').onclick = function(e) { ...@@ -1042,12 +1061,46 @@ document.getElementById('user').onclick = function(e) {
document.getElementById("userDropdown").classList.toggle("show"); document.getElementById("userDropdown").classList.toggle("show");
}; };
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");
}
}
};
document.getElementById('clodeside').onclick = function(e) { document.getElementById('clodeside').onclick = function(e) {
e.preventDefault(); e.preventDefault();
closeNav(); closeNav();
}; };
document.getElementById('video-container').onclick = function(e) {
e.preventDefault();
let width = (window.innerWidth > 0) ? window.innerWidth : screen.width;
if (width <= 768) {
let user_box = document.getElementById('userDropdown');
if (user_box.classList.contains("show")) {
return;
}
// fixed div for small screen
hideVideo(true);
document.getElementById('switch-video').style.display = "block";
}
};
document.getElementById('switch-video').onclick = function(e) {
e.preventDefault();
showVideo();
this.style.display = "";
};
function serverConnect() { function serverConnect() {
serverConnection = new ServerConnection(); serverConnection = new ServerConnection();
serverConnection.onconnected = gotConnected; serverConnection.onconnected = gotConnected;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment