cleaner log

master
bel 2020-05-10 12:02:47 -06:00
parent ff9baa4d4c
commit 727a80a14d
3 changed files with 91 additions and 14 deletions

View File

@ -5,6 +5,7 @@
<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
-->
<script src="webrtc.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<style>
video {
width: 100%;
@ -18,6 +19,9 @@
</head>
<body>
<div>Video<label class="switch"><input onclick="toggle('video', this)" type="checkbox"><span class="slider round"></span></label></div>
<div>Audio<label class="switch"><input onclick="toggle('audio', this)" type="checkbox"><span class="slider round"></span></label></div>
<video id="localVideo" autoplay muted ></video>
<video id="remoteVideo" autoplay ></video>

62
public/style.css Normal file
View File

@ -0,0 +1,62 @@
/* The switch - the box around the slider */
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
/* Hide default HTML checkbox */
.switch input {
opacity: 0;
width: 0;
height: 0;
}
/* The slider */
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
/* Rounded sliders */
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}

View File

@ -48,29 +48,27 @@ class Config {
}
class View {
static write(color, msg) {
static write(foo, color) {
var msg = [].slice.call(arguments[2]).join(" ");
foo(msg);
document.getElementById("log").innerHTML +=
'<br><span style="color: ' + color + ';">' + msg + '</span>';
}
static info(msg) {
rconsole.info(msg);
View.write("gray", msg);
static info() {
View.write(rconsole.info, "gray", arguments);
}
static warn(msg) {
rconsole.warn(msg);
View.write("orange", msg);
static warn() {
View.write(rconsole.warn, "orange", arguments);
}
static log(msg) {
rconsole.log(msg);
View.write("black", msg);
static log() {
View.write(rconsole.log, "black", arguments);
}
static error(msg) {
rconsole.error(msg);
View.write("red", msg);
static error() {
View.write(rconsole.error, "red", arguments);
}
}
@ -181,10 +179,23 @@ function pageReady() {
Entropy.pageReady();
}
function start(b) {
function start(b, type = null) {
Entropy.start(b);
}
function toggle(type, caller) {
//start(true, type);
View.log(type, caller.checked, streams);
if (caller.checked && ! type in streams) {
View.log("start", type);
streams[type] = null;
} else if (type in streams) {
View.log("stop", type);
delete streams[type];
}
}
var streams = {}
var rconsole = console;
var console = {}
for (var i in ["log", "info", "warn", "error"]) {