WIP: cleanup code

This commit is contained in:
matt 2021-10-12 14:11:26 +00:00
parent f3418af9b7
commit f8fde81dfb
2 changed files with 20 additions and 21 deletions

View File

@ -1122,7 +1122,7 @@ const UI = {
}, },
copyFromLocalClipboard: function copyFromLocalClipboard() { copyFromLocalClipboard: function copyFromLocalClipboard() {
if (!document.hasFocus()) { if (!document.hasFocus()) {
console.log("window does not have focus"); Log.Debug("window does not have focus");
return; return;
} }
if (UI.rfb && UI.rfb.clipboardUp && UI.rfb.clipboardSeamless) { if (UI.rfb && UI.rfb.clipboardUp && UI.rfb.clipboardSeamless) {
@ -1134,7 +1134,7 @@ const UI = {
} }
UI.needToCheckClipboardChange = false; UI.needToCheckClipboardChange = false;
}, (err) => { }, (err) => {
console.log("No data in clipboard"); Log.Debug("No data in clipboard");
}); });
} }
} }
@ -1283,7 +1283,7 @@ const UI = {
//Only explicitly request permission to clipboard on browsers that support binary clipboard access //Only explicitly request permission to clipboard on browsers that support binary clipboard access
if (supportsBinaryClipboard()) { if (supportsBinaryClipboard()) {
// explicitly request permission to the clipboard // explicitly request permission to the clipboard
navigator.permissions.query({ name: "clipboard-read" }).then((result) => { console.log('binary clipboard enabled') }); navigator.permissions.query({ name: "clipboard-read" }).then((result) => { Log.Debug('binary clipboard enabled') });
} }
// KASM-960 workaround, disable seamless on Safari // KASM-960 workaround, disable seamless on Safari
if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) if (/^((?!chrome|android).)*safari/i.test(navigator.userAgent))

View File

@ -794,7 +794,7 @@ export default class RFB extends EventTargetMixin {
let h = hashUInt8Array(data); let h = hashUInt8Array(data);
if (h === this._clipHash) { if (h === this._clipHash) {
console.log('No clipboard changes'); Log.Debug('No clipboard changes');
return; return;
} else { } else {
this._clipHash = h; this._clipHash = h;
@ -832,7 +832,7 @@ export default class RFB extends EventTargetMixin {
if (!h) { if (!h) {
h = hashUInt8Array(data); h = hashUInt8Array(data);
if (h === this._clipHash) { if (h === this._clipHash) {
console.log('No clipboard changes'); Log.Debug('No clipboard changes');
return; return;
} else { } else {
this._clipHash = h; this._clipHash = h;
@ -845,10 +845,10 @@ export default class RFB extends EventTargetMixin {
mimes.push(mime); mimes.push(mime);
dataset.push(data); dataset.push(data);
console.log('Sending mime type: ' + mime); Log.Debug('Sending mime type: ' + mime);
break; break;
default: default:
console.log('skipping clip send mime type: ' + mime) Log.Debug('skipping clip send mime type: ' + mime)
} }
} }
@ -1073,7 +1073,7 @@ export default class RFB extends EventTargetMixin {
try { try {
if (x > 1280 && limited && this.videoQuality == 1) { if (x > 1280 && limited && this.videoQuality == 1) {
var ratio = y / x; var ratio = y / x;
console.log(ratio); Log.Debug(ratio);
x = 1280; x = 1280;
y = x * ratio; y = x * ratio;
} }
@ -1082,7 +1082,7 @@ export default class RFB extends EventTargetMixin {
y = 720; y = 720;
} }
} catch (err) { } catch (err) {
console.log(err); Log.Debug(err);
} }
return { w: x, return { w: x,
@ -2480,8 +2480,8 @@ export default class RFB extends EventTargetMixin {
let mimes = []; let mimes = [];
let clipItemData = {}; let clipItemData = {};
let buffByteLen = 2; let buffByteLen = 2;
console.log(num + ' Clipboard items recieved.'); Log.Debug(num + ' Clipboard items recieved.');
console.log('Client sockjs buffer size ' + this._sock.rQlen); Log.Debug('Started clipbooard processing with Client sockjs buffer size ' + this._sock.rQlen);
@ -2516,8 +2516,7 @@ export default class RFB extends EventTargetMixin {
textdata = textdata.slice(0, -1); textdata = textdata.slice(0, -1);
} }
console.log('Clipboard item raw: ' + data); Log.Debug("Plain text clipboard recieved and placed in text element, size: " + textdata.length);
console.log('Clipboard item decoded: ' + textdata);
this.dispatchEvent(new CustomEvent( this.dispatchEvent(new CustomEvent(
"clipboard", "clipboard",
{ detail: { text: textdata } }) { detail: { text: textdata } })
@ -2526,17 +2525,17 @@ export default class RFB extends EventTargetMixin {
if (!this.clipboardBinary) { continue; } if (!this.clipboardBinary) { continue; }
console.log("Mime " + mime + ", len ", len); Log.Debug("Processed binary clipboard of MIME " + mime + " of length " + len);
console.log(data);
clipItemData[mime] = new Blob([data], { type: mime }); clipItemData[mime] = new Blob([data], { type: mime });
break; break;
default: default:
console.log('Mime type skipped: ' + mime); Log.Debug('Mime type skipped: ' + mime);
break; break;
} }
} }
console.log('Client sockjs buffer size ' + this._sock.rQlen); Log.Debug('Finished processing binary clipboard with client sockjs buffer size ' + this._sock.rQlen);
if (Object.keys(clipItemData).length > 0) { if (Object.keys(clipItemData).length > 0) {
if (this.clipboardBinary) { if (this.clipboardBinary) {
@ -2544,7 +2543,7 @@ export default class RFB extends EventTargetMixin {
navigator.clipboard.write([new ClipboardItem(clipItemData)]).then( navigator.clipboard.write([new ClipboardItem(clipItemData)]).then(
function() {}, function() {},
function(err) { function(err) {
console.log("Error writing to client clipboard: " + err); Log.Debug("Error writing to client clipboard: " + err);
}); });
} }
} }
@ -2559,8 +2558,8 @@ export default class RFB extends EventTargetMixin {
const text = this._sock.rQshiftStr(length); const text = this._sock.rQshiftStr(length);
console.log("Received KASM bottleneck stats:"); Log.Debug("Received KASM bottleneck stats:");
console.log(text); Log.Debug(text);
this.dispatchEvent(new CustomEvent( this.dispatchEvent(new CustomEvent(
"bottleneck_stats", "bottleneck_stats",
{ detail: { text: text } })); { detail: { text: text } }));
@ -3373,7 +3372,7 @@ RFB.messages = {
let length = data.length; let length = data.length;
console.log('Clipboard data sent mime type ' + mime + ' len ' + length); Log.Debug('Clipboard data sent mime type ' + mime + ' len ' + length);
buff[offset++] = length >> 24; buff[offset++] = length >> 24;
buff[offset++] = length >> 16; buff[offset++] = length >> 16;