fix sharing latency and timer
Signed-off-by: si458 <simonsmith5521@gmail.com>
si458 committed
May 24, 2024 at 15:30 UTC
89b67ff999543399e3a05d0adada63663900d7f3
1 file changed
+21
-20
views/sharing.handlebars
+21
-20
@@ -71,8 +71,8 @@
71
</div>
72
<div id=deskarea4 class="areaFoot" style="min-height:24px">
73
<div class="toright2">
74
- <span id="DeskLatency" title="Desktop Session Latency"></span>
75
- <span id="DeskTimer" style="display:none" title="Session time"></span>
74
+ <span id="DeskLatency" style="line-height:22px;width:50px" title="Desktop Session Latency"></span>
75
+ <span id="DeskTimer" style="line-height:22px" title="Session time"></span>
76
<select id=termdisplays style="display:none" onchange=deskSetDisplay(event) onkeypress="return false" onkeydown="return false"></select>
77
<span id=DeskSaveImageButton title="Save a screenshot of the remote desktop"><img src='images/icon-camera.png' onclick=deskSaveImage() height=16 width=16 style=padding-top:2px /></span>
78
</div>
@@ -480,6 +480,9 @@
480
QE('DeskWD', deskState == 3);
481
QV('deskkeys', viewOnly != 1);
482
QE('deskkeys', deskState == 3);
483
+ QV('DeskTimer', deskState == 3);
484
+ QV('DeskLatency', deskState == 3);
485
+ QS('DeskLatency').display = (deskState == 3 ? 'inline-block' : 'none');
486
487
// Display this only if we have Chat & Notify permissions
488
QV('DeskSaveImageButton', (deskState == 3) && (Q('Desk')['toBlob'] != null));
@@ -624,7 +627,7 @@
627
desktop.m.onDisplayinfo = deskDisplayInfo;
628
desktop.m.onScreenSizeChange = deskAdjust;
629
desktop.Start(null);
627
- desktop.latency.callback = function (ms) { console.log('latency', ms); updateSessionTime(); };
630
+ desktop.latency.callback = function (ms) { /* console.log('latency', ms); */ updateSessionTime(); };
631
desktop.contype = 1;
632
}
633
} else {
@@ -736,14 +739,26 @@
739
// Desktop
740
var latencyStr = '', seconds = 0;
741
if (desktop && desktop.startTime) {
739
- if (desktop.latency && (desktop.latency.current >= 0)) { latencyStr = format('{0} ms, ', desktop.latency.current); }
742
+ if (desktop.latency && (desktop.latency.current >= 0)) { latencyStr = format('{0} ms', desktop.latency.current); }
743
seconds = Math.floor((new Date() - desktop.startTime) / 1000);
741
- QH('DeskTimer', latencyStr + zeroPad(Math.floor(seconds / 3600), 2) + ':' + zeroPad((Math.floor(seconds / 60) % 60), 2) + ':' + zeroPad((seconds % 60), 2));
744
+ QH('DeskTimer', zeroPad(Math.floor(seconds / 3600), 2) + ':' + zeroPad((Math.floor(seconds / 60) % 60), 2) + ':' + zeroPad((seconds % 60), 2));
745
+ QH('DeskLatency', latencyStr);
746
} else {
747
QH('DeskTimer', '');
748
+ QH('DeskLatency', '');
749
}
750
746
- if (desktop == null) { clearInterval(updateSessionTimer); updateSessionTimer = null; }
751
+ // Terminal
752
+ seconds = 0;
753
+ if (terminal && terminal.startTime) {
754
+ if (terminal.latency && (terminal.latency.current >= 0)) { latencyStr = format('{0} ms, ', terminal.latency.current); }
755
+ seconds = Math.floor((new Date() - terminal.startTime) / 1000);
756
+ QH('TermTimer', latencyStr + zeroPad(Math.floor(seconds / 3600), 2) + ':' + zeroPad((Math.floor(seconds / 60) % 60), 2) + ':' + zeroPad((seconds % 60), 2));
757
+ } else {
758
+ QH('TermTimer', '');
759
+ }
760
+
761
+ if ((desktop == null) && (terminal == null)) { clearInterval(updateSessionTimer); updateSessionTimer = null; }
762
}
763
764
function showDesktopSettings() {
@@ -1373,20 +1388,6 @@
1388
updateTerminalButtons();
1389
}
1390
1376
- function updateSessionTime() {
1377
- // Terminal
1378
- var latencyStr = '', seconds = 0;
1379
- if (terminal && terminal.startTime) {
1380
- if (terminal.latency && (terminal.latency.current >= 0)) { latencyStr = format('{0} ms, ', terminal.latency.current); }
1381
- seconds = Math.floor((new Date() - terminal.startTime) / 1000);
1382
- QH('TermTimer', latencyStr + zeroPad(Math.floor(seconds / 3600), 2) + ':' + zeroPad((Math.floor(seconds / 60) % 60), 2) + ':' + zeroPad((seconds % 60), 2));
1383
- } else {
1384
- QH('TermTimer', '');
1385
- }
1386
-
1387
- if (terminal == null) { clearInterval(updateSessionTimer); updateSessionTimer = null; }
1388
- }
1389
-
1391
// DEBUG
1392
var autoConnectTerminalTimer = null;
1393
function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }