update ui
parent
448b025701
commit
68ef6b3d25
|
|
@ -14,7 +14,7 @@
|
||||||
<video id="localVideo" class="video rnd" autoplay muted></video>
|
<video id="localVideo" class="video rnd" autoplay muted></video>
|
||||||
<video id="remoteVideo" class="video rnd" autoplay></video>
|
<video id="remoteVideo" class="video rnd" autoplay></video>
|
||||||
<div class="label">You</div>
|
<div class="label">You</div>
|
||||||
<div class="label">Remote</div>
|
<div class="label">Peer</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="btn-wrap">
|
<div class="btn-wrap">
|
||||||
<input type="button" id="dbg" onclick="showStatus(true)" value="DBG"></input>
|
<input type="button" id="dbg" onclick="showStatus(true)" value="DBG"></input>
|
||||||
|
|
|
||||||
|
|
@ -82,21 +82,21 @@ function addStatus(msg){
|
||||||
function sendMsg(){
|
function sendMsg(){
|
||||||
let content = _dom.chatInput.value;
|
let content = _dom.chatInput.value;
|
||||||
const msg = {
|
const msg = {
|
||||||
uuid: _s.uuid,
|
sender: 'Peer',
|
||||||
content: content
|
content: content
|
||||||
};
|
};
|
||||||
_s.dataChannel.send(JSON.stringify(msg, null, 2));
|
_s.dataChannel.send(JSON.stringify(msg, null, 2));
|
||||||
// write local
|
// write local
|
||||||
content = content.replace(_s.uuid, 'You');
|
content = content.replace(_s.uuid, 'You');
|
||||||
writeMsg({uuid:'You', content});
|
writeMsg({sender:'You', content});
|
||||||
_dom.chatInput.value = '';
|
_dom.chatInput.value = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeMsg(msg){
|
function writeMsg(msg){
|
||||||
let content = msg.content;
|
let content = msg.content;
|
||||||
const origin = msg.uuid || 'System >> ';
|
const origin = msg.sender || 'System';
|
||||||
content = content.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
content = content.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
||||||
const out = '<br>' + origin + ': ' + content + '<br>';
|
const out = '<br><strong>' + origin + '</strong>: ' + content + '<br>';
|
||||||
_dom.msgArea.innerHTML += out;
|
_dom.msgArea.innerHTML += out;
|
||||||
_dom.msgArea.scrollTop = msgArea.scrollHeight;
|
_dom.msgArea.scrollTop = msgArea.scrollHeight;
|
||||||
}
|
}
|
||||||
|
|
@ -128,7 +128,7 @@ function setupDataChannel(){
|
||||||
_s.dataChannel.onopen = () => {
|
_s.dataChannel.onopen = () => {
|
||||||
// The data channel is now open
|
// The data channel is now open
|
||||||
// You can now send data
|
// You can now send data
|
||||||
const msg = {uuid: _s.uuid, content: 'CONNECTED!'};
|
const msg = {sender: _s.uuid, content: 'Connected!'};
|
||||||
_s.dataChannel.send(JSON.stringify(msg, null, 2));
|
_s.dataChannel.send(JSON.stringify(msg, null, 2));
|
||||||
showChat(true);
|
showChat(true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue