mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Can now save chat session in messenger.
This commit is contained in:
parent
1f7a21205a
commit
69952904eb
7 changed files with 49 additions and 15 deletions
|
@ -13,7 +13,8 @@
|
|||
<body style="font-family:Arial,Helvetica,sans-serif">
|
||||
<div id="xtop" style="position:absolute;left:0;right:0;top:0;height:38px;background-color:#036;color:#c8c8c8;box-shadow:3px 3px 10px gray">
|
||||
<div style="position:absolute;background-color:#036;right:0;height:38px">
|
||||
<div id="notifyButton" class="icon13 topButton" style="margin-right:4px;display:none" title="Enable browser notification" onclick="enableNotificationsButtonClick()"></div>
|
||||
<div id="saveButton" class="icon15 topButton" style="margin-right:4px" title="Save conversation" onclick="saveChatSession()"></div>
|
||||
<div id="notifyButton" class="icon13 topButton" style="display:none" title="Enable browser notification" onclick="enableNotificationsButtonClick()"></div>
|
||||
<div id="fileButton" class="icon4 topButton" title="Share a file" style="display:none" onclick="fileButtonClick()"></div>
|
||||
<div id="camButton" class="icon2 topButton" title="Activate camera & microphone" style="display:none" onclick="camButtonClick()"></div>
|
||||
<div id="micButton" class="icon6 topButton" title="Activate microphone" style="display:none" onclick="micButtonClick()"></div>
|
||||
|
@ -61,6 +62,7 @@
|
|||
var webrtcconfiguration = '{{{webrtconfig}}}';
|
||||
if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: "' + webrtcconfiguration + '".'); webrtcconfiguration = null; } }
|
||||
var windowFocus = true;
|
||||
var chatTestSession = new Date().toString() + '\r\n';
|
||||
|
||||
// File transfer state
|
||||
var fileUploads = [];
|
||||
|
@ -119,7 +121,7 @@
|
|||
}
|
||||
|
||||
function onUserInputFocus(x) { userInputFocus = x; }
|
||||
function displayClear() { QH('xmsg', ''); cancelAllFileTransfers(); fileUploads = [], fileDownloads = {}; }
|
||||
function displayClear() { chatTestSession = new Date().toString() + '\r\n'; QH('xmsg', ''); cancelAllFileTransfers(); fileUploads = [], fileDownloads = {}; }
|
||||
|
||||
// Polyfill FileReader if needed
|
||||
if (!FileReader.prototype.readAsBinaryString) {
|
||||
|
@ -154,6 +156,7 @@
|
|||
|
||||
// Display a control message
|
||||
function displayControl(msg) {
|
||||
chatTestSession += ("Control" + '> ' + msg + '\r\n');
|
||||
QA('xmsg', '<div style="clear:both"><div style="color:gray;float:left;margin-bottom:2px">' + EscapeHtml(msg) + '</div><div></div></div>');
|
||||
Q('xmsgparent').scrollTop = Q('xmsgparent').scrollHeight;//Q('xmsg').scrollHeight;
|
||||
}
|
||||
|
@ -168,7 +171,7 @@
|
|||
|
||||
// Display a message from the remote user
|
||||
function displayRemote(msg) {
|
||||
console.log(document.activeElement);
|
||||
chatTestSession += ("Remote" + '> ' + msg + '\r\n');
|
||||
QA('xmsg', '<div style="clear:both"><div class="remoteBubble">' + EscapeHtml(msg) + '</div><div></div></div>');
|
||||
Q('xmsgparent').scrollTop = Q('xmsgparent').scrollHeight;
|
||||
|
||||
|
@ -191,6 +194,7 @@
|
|||
var outtext = Q('xouttext').value;
|
||||
if (outtext.length > 0) {
|
||||
Q('xouttext').value = '';
|
||||
chatTestSession += ("Local" + '> ' + outtext + '\r\n');
|
||||
QA('xmsg', '<div style="clear:both"><div class="localBubble">' + EscapeHtml(outtext) + '</div><div></div></div>');
|
||||
Q('xmsgparent').scrollTop = Q('xmsgparent').scrollHeight;
|
||||
send({ action: 'chat', msg: outtext });
|
||||
|
@ -425,6 +429,8 @@
|
|||
if (state != 2) return;
|
||||
file.id = Math.random();
|
||||
fileUploads.push(file);
|
||||
console.log(file);
|
||||
chatTestSession += ("Upload" + '> ' + file.name + '\r\n');
|
||||
QA('xmsg', '<div style="clear:both"></div><div id="FILEUP-' + file.id + '" class="localBubble" style="width:240px;cursor:pointer" onclick="cancelFileTransfer(\'' + file.id + '\')"><div id="FILEUP-ICON-' + file.id + '" class="fileicon" style="float:left;width:32px;height:32px"></div><div><div id="FILEUP-NAME-' + file.id + '" style="height:16px;overflow:hidden;white-space:nowrap;" title="' + file.name + '">' + file.name + '</div><div style="width:200px;background-color:lightgray;margin-left:32px;border-radius:3px;margin-top:3px;height:11px"><div id="FILEUP-PROGRESS-' + file.id + '" style="width:0px;background-color:green;border-radius:3px;height:11px"> </div></div></div></div>');
|
||||
Q('xmsgparent').scrollTop = Q('xmsgparent').scrollHeight;
|
||||
send({ action: 'file', size: file.size, id: file.id, type: file.type, name: file.name });
|
||||
|
@ -434,6 +440,8 @@
|
|||
function startFileDownload(file) {
|
||||
if (state != 2) return;
|
||||
fileDownloads[file.id] = file;
|
||||
console.log(file);
|
||||
chatTestSession += ("Download" + '> ' + file.name + '\r\n');
|
||||
QA('xmsg', '<div style="clear:both"></div><div id="FILEUP-' + file.id + '" class="remoteBubble" style="width:240px;cursor:pointer" onclick="saveFileTransfer(\'' + file.id + '\')"><div id="FILEUP-ICON-' + file.id + '" class="fileicon" style="float:left;width:32px;height:32px"></div><div><div id="FILEUP-NAME-' + file.id + '" style="height:16px;overflow:hidden;white-space:nowrap;" title="' + file.name + '">' + file.name + '</div><div style="width:200px;background-color:lightgray;margin-left:32px;border-radius:3px;margin-top:3px;height:11px"><div id="FILEUP-PROGRESS-' + file.id + '" style="width:0px;background-color:green;border-radius:3px;height:11px"> </div></div></div></div>');
|
||||
Q('xmsgparent').scrollTop = Q('xmsgparent').scrollHeight;
|
||||
}
|
||||
|
@ -637,6 +645,10 @@
|
|||
}
|
||||
}
|
||||
|
||||
function saveChatSession() {
|
||||
saveAs(data2blob(chatTestSession), "ChatSession");
|
||||
}
|
||||
|
||||
start();
|
||||
|
||||
function onUnLoad() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue