2019-08-11 01:34:21 -04:00
<!DOCTYPE html>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<meta name="viewport" content="user-scalable=1.0,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no" />
<link type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
2020-05-02 02:11:43 -04:00
<script type="text/javascript" src="scripts/common-0.0.1 {{ min }} .js"></script>
<script type="text/javascript" src="scripts/agent-desktop-0.0.2 {{ min }} .js"></script>
<script type="text/javascript" src="scripts/amt-desktop-0.0.2 {{ min }} .js"></script>
<script type="text/javascript" src="scripts/amt-terminal-0.0.2 {{ min }} .js"></script>
<script type="text/javascript" src="scripts/zlib {{ min }} .js"></script>
<script type="text/javascript" src="scripts/zlib-inflate {{ min }} .js"></script>
<script type="text/javascript" src="scripts/zlib-adler32 {{ min }} .js"></script>
<script type="text/javascript" src="scripts/zlib-crc32 {{ min }} .js"></script>
2019-08-11 01:34:21 -04:00
</head>
<body style="overflow:hidden;background-color:black">
<div id=p11 class="noselect" style="overflow:hidden">
<div id=deskarea0>
<div id=deskarea1 class="areaHead">
<div class="toright2">
<div class='deskareaicon' title="Toggle View Mode" onclick="toggleAspectRatio(1)">⇲</div>
</div>
<div>
<input id="OpenFileButton" type=button value="Open File..." onclick="openfile()">
<span id="deskstatus"></span>
</div>
</div>
2020-02-11 22:02:30 -05:00
<div id=deskarea3x style="max-height:calc(100vh - 58px);height:calc(100vh - 58px);" onclick="togglePause()">
2019-08-11 01:34:21 -04:00
<div id="bigok" style="display:none;left:calc((100vh / 2))"><b>✓</b></div>
<div id="bigfail" style="display:none;left:calc((100vh / 2))"><b>✗</b></div>
<div id="metadatadiv" style="padding:20px;color:lightgrey;text-align:left;display:none"></div>
2019-08-13 20:06:45 -04:00
<div id=DeskParent>
2019-08-11 01:34:21 -04:00
<canvas id=Desk width=640 height=480></canvas>
</div>
2019-08-13 20:06:45 -04:00
<div id=TermParent style="display:none">
2019-08-13 17:22:55 -04:00
<pre id=Term></pre>
2019-08-13 16:55:25 -04:00
</div>
2019-08-11 01:34:21 -04:00
<div id=p11DeskConsoleMsg style="display:none;cursor:pointer;position:absolute;left:30px;top:17px;color:yellow;background-color:rgba(0,0,0,0.6);padding:10px;border-radius:5px" onclick=clearConsoleMsg()></div>
</div>
2020-02-12 19:57:05 -05:00
<div id=deskarea2 style="">
<div class="areaProgress" style="cursor:pointer" onclick="progressBarSeek(event)"><div id="progressbar" style="height:6px;cursor:pointer"></div></div>
</div>
2019-08-11 01:34:21 -04:00
<div id=deskarea4 class="areaFoot">
<div class="toright2">
<div id="timespan" style="padding-top:4px;padding-right:4px">00:00:00</div>
</div>
<div>
<input id="PlayButton" type=button value="Play" disabled="disabled" onclick="play()">
<input id="PauseButton" type=button value="Pause" disabled="disabled" onclick="pause()">
<input id="RestartButton" type=button value="Restart" disabled="disabled" onclick="restart()">
<select id="PlaySpeed" onchange="this.blur();">
<option value=4>1/4 Speed</option>
<option value=2>1/2 Speed</option>
<option value=1 selected>Normal Speed</option>
<option value=0.5>2x Speed</option>
<option value=0.25>4x Speed</option>
<option value=0.1>10x Speed</option>
</select>
2020-02-11 18:34:27 -05:00
<input id="SeekBackwardButton" type=button value="<<" disabled="disabled" onclick="seekBackward()">
<input id="SeekForwardButton" type=button value=">>" disabled="disabled" onclick="seekForward()">
2019-08-11 01:34:21 -04:00
</div>
</div>
</div>
<div id=dialog class="noselect" style="display:none">
<div id=dialogHeader>
<div tabindex=0 id=id_dialogclose onclick=setDialogMode() onkeypress="if (event.key == 'Enter') setDialogMode()">✖</div>
<div id=id_dialogtitle></div>
</div>
<div id=dialogBody>
<div id=dialog1>
<div id=id_dialogMessage style=""></div>
</div>
<div id=dialog2 style="">
<div id=id_dialogOptions></div>
</div>
</div>
<div id="idx_dlgButtonBar">
<input id="idx_dlgCancelButton" type="button" value="Cancel" style="" onclick="dialogclose(0)">
<input id="idx_dlgOkButton" type="button" value="OK" style="" onclick="dialogclose(1)">
<div><input id="idx_dlgDeleteButton" type="button" value="Delete" style="display:none" onclick="dialogclose(2)"></div>
</div>
</div>
</div>
<script>
var recFile = null;
var recFilePtr = 0;
var recFileStartTime = 0;
var recFileLastTime = 0;
2019-08-13 14:49:05 -04:00
var recFileEndTime = 0;
2019-08-11 01:34:21 -04:00
var recFileMetadata = null;
var recFileProtocol = 0;
2020-02-11 18:34:27 -05:00
var recFileIndexBasePtr = null;
2019-08-11 01:34:21 -04:00
var agentDesktop = null;
2019-08-12 19:16:52 -04:00
var amtDesktop = null;
2019-08-11 01:34:21 -04:00
var playing = false;
var readState = 0;
var waitTimer = null;
var waitTimerArgs = null;
var deskAspectRatio = 0;
var currentDeltaTimeTotalSec = 0;
function start() {
window.onresize = deskAdjust;
document.ondrop = ondrop;
document.ondragover = ondragover;
document.ondragleave = ondragleave;
document.onkeypress = onkeypress;
Q('PlaySpeed').value = 1;
cleanup();
}
function readNextBlock(func) {
2019-08-13 14:49:05 -04:00
if ((recFilePtr + 16) > recFile.size) { QS('progressbar').width = '100%'; func(-1); } else {
2019-08-11 01:34:21 -04:00
var fr = new FileReader();
fr.onload = function () {
var type = ReadShort(this.result, 0);
var flags = ReadShort(this.result, 2);
var size = ReadInt(this.result, 4);
var time = (ReadInt(this.result, 8) << 32) + ReadInt(this.result, 12);
2019-08-13 14:49:05 -04:00
if ((recFilePtr + 16 + size) > recFile.size) { QS('progressbar').width = '100%'; func(-1); } else {
2019-08-11 01:34:21 -04:00
var fr2 = new FileReader();
fr2.onload = function () {
recFilePtr += (16 + size);
2019-08-13 14:49:05 -04:00
if (recFileEndTime == 0) {
// File pointer progress bar
QS('progressbar').width = Math.floor(100 * (recFilePtr / recFile.size)) + '%';
} else {
// Time progress bar
QS('progressbar').width = Math.floor(((recFileLastTime - recFileStartTime) / (recFileEndTime - recFileStartTime)) * 100) + '%';
}
2019-08-11 01:34:21 -04:00
func(type, flags, time, this.result);
};
fr2.readAsBinaryString(recFile.slice(recFilePtr + 16, recFilePtr + 16 + size));
}
};
fr.readAsBinaryString(recFile.slice(recFilePtr, recFilePtr + 16));
}
}
2020-02-11 18:34:27 -05:00
function readBlockAt(ptr, func) {
var fr = new FileReader();
fr.onload = function () {
var type = ReadShort(this.result, 0);
var flags = ReadShort(this.result, 2);
var size = ReadInt(this.result, 4);
var time = (ReadInt(this.result, 8) << 32) + ReadInt(this.result, 12);
if ((ptr + 16 + size) > recFile.size) { func(-1); } else {
var fr2 = new FileReader();
fr2.onload = function () { func(type, flags, time, this.result); };
fr2.readAsBinaryString(recFile.slice(ptr + 16, ptr + 16 + size));
}
};
fr.readAsBinaryString(recFile.slice(ptr, ptr + 16));
}
2019-08-13 14:49:05 -04:00
function readLastBlock(func) {
if (recFile.size < 32) { func(-1); } else {
var fr = new FileReader();
fr.onload = function () {
var type = ReadShort(this.result, 0);
var flags = ReadShort(this.result, 2);
var size = ReadInt(this.result, 4);
var time = (ReadInt(this.result, 8) << 32) + ReadInt(this.result, 12);
2020-02-12 19:57:05 -05:00
var magic = this.result.substring(16, 32);
if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCNDX')) {
// Extra metadata present, lets read it.
var fr2 = new FileReader();
fr2.onload = function () {
var xtype = ReadShort(this.result, 0);
var xflags = ReadShort(this.result, 2);
var xsize = ReadInt(this.result, 4);
var xtime = (ReadInt(this.result, 8) << 32) + ReadInt(this.result, 12);
var extras = JSON.parse(this.result.substring(16));
func(type, flags, xtime, extras); // Include extra metadata
}
fr2.readAsBinaryString(recFile.slice(time, recFile.size - 32));
} else if ((type == 3) && (size == 16) && (magic == 'MeshCentralMCREC')) {
func(type, flags, time); // No extra metadata
} else {
func(-1); // Fail
}
2019-08-13 14:49:05 -04:00
};
fr.readAsBinaryString(recFile.slice(recFile.size - 32, recFile.size));
}
}
2019-08-11 01:34:21 -04:00
function addInfo(name, value) { if (value == null) return ''; return addInfoNoEsc(name, EscapeHtml(value)); }
function addInfoNoEsc(name, value) {
if (value == null) return '';
return '<span style=color:gray>' + EscapeHtml(name) + '</span>: <span style=font-size:20px>' + value + '</span><br/>';
}
function processFirstBlock(type, flags, time, data) {
recFileProtocol = 0;
2020-03-11 03:17:10 -04:00
if ((type != 1) || (flags > 2)) { cleanup(); return; }
2019-08-11 01:34:21 -04:00
try { recFileMetadata = JSON.parse(data) } catch (ex) { cleanup(); return; }
if ((recFileMetadata == null) || (recFileMetadata.magic != 'MeshCentralRelaySession') || (recFileMetadata.ver != 1)) { cleanup(); return; }
2020-02-12 19:57:05 -05:00
if (recFileExtras) { for (var i in recFileExtras) { recFileMetadata[i] = recFileExtras[i]; } }
2019-08-11 01:34:21 -04:00
var x = '';
2019-10-17 20:13:55 -04:00
x += addInfo("Time", recFileMetadata.time);
if (recFileEndTime != 0) { var secs = Math.floor((recFileEndTime - time) / 1000); x += addInfo("Duration", format(" { 0} second { 1}", secs, (secs > 1) ? 's' : '')); }
x += addInfo("Username", recFileMetadata.username);
x += addInfo("UserID", recFileMetadata.userid);
x += addInfo("SessionID", recFileMetadata.sessionid);
if (recFileMetadata.ipaddr1 && recFileMetadata.ipaddr2) { x += addInfo("Addresses", format(" { 0} to { 1}", recFileMetadata.ipaddr1, recFileMetadata.ipaddr2)); }
2019-12-01 18:21:33 -05:00
if (recFileMetadata.devicename) { x += addInfo("Device Name", recFileMetadata.devicename); }
2019-10-17 20:13:55 -04:00
x += addInfo("NodeID", recFileMetadata.nodeid);
2019-08-11 01:34:21 -04:00
if (recFileMetadata.protocol) {
var p = recFileMetadata.protocol;
2019-10-17 20:13:55 -04:00
if (p == 1) { p = "MeshCentral Terminal"; }
else if (p == 2) { p = "MeshCentral Desktop"; }
else if (p == 100) { p = "Intel® AMT WSMAN"; }
else if (p == 101) { p = "Intel® AMT Redirection"; }
x += addInfoNoEsc("Protocol", p);
2019-08-11 01:34:21 -04:00
}
2020-02-11 18:34:27 -05:00
if (recFileMetadata.indexInterval) {
recFileIndexBasePtr = recFilePtr;
x += addInfoNoEsc("Seeking", format("Indexed every { 0} seconds", recFileMetadata.indexInterval));
2020-02-11 22:02:30 -05:00
QV('SeekBackwardButton', true);
QV('SeekForwardButton', true);
2020-02-11 18:34:27 -05:00
QE('SeekBackwardButton', true);
QE('SeekForwardButton', true);
2020-02-11 22:02:30 -05:00
} else {
QV('SeekBackwardButton', false);
QV('SeekForwardButton', false);
2020-02-11 18:34:27 -05:00
}
2019-08-13 16:55:25 -04:00
QV('DeskParent', true);
QV('TermParent', false);
if (recFileMetadata.protocol == 1) {
// MeshCentral remote terminal
recFileProtocol = 1;
2019-10-17 20:13:55 -04:00
x += '<br /><br /><span style=color:gray>' + "Press [space] to play/pause." + '</span>';
2019-08-13 16:55:25 -04:00
QE('PlayButton', true);
QE('PauseButton', false);
QE('RestartButton', false);
recFileStartTime = recFileLastTime = time;
}
else if (recFileMetadata.protocol == 2) {
2019-08-11 01:34:21 -04:00
// MeshCentral remote desktop
recFileProtocol = 2;
2019-10-17 20:13:55 -04:00
x += '<br /><br /><span style=color:gray>' + "Press [space] to play/pause." + '</span>';
2019-08-11 01:34:21 -04:00
QE('PlayButton', true);
QE('PauseButton', false);
QE('RestartButton', false);
recFileStartTime = recFileLastTime = time;
agentDesktop = CreateAgentRemoteDesktop('Desk');
agentDesktop.onScreenSizeChange = deskAdjust;
agentDesktop.State = 3;
deskAdjust();
}
2019-08-12 19:16:52 -04:00
else if (recFileMetadata.protocol == 101) {
// Intel AMT Redirection
recFileProtocol = 101;
x += '<br /><br /><span style=color:gray>Press [space] to play/pause.</span>';
QE('PlayButton', true);
QE('PauseButton', false);
QE('RestartButton', false);
recFileStartTime = recFileLastTime = time;
amtDesktop = CreateAmtRemoteDesktop('Desk');
amtDesktop.onScreenSizeChange = deskAdjust;
amtDesktop.State = 3;
2019-08-13 14:49:05 -04:00
amtDesktop.Start();
2019-08-12 19:16:52 -04:00
deskAdjust();
}
2019-08-11 01:34:21 -04:00
QV('metadatadiv', true);
QH('metadatadiv', x);
QH('deskstatus', recFile.name);
2020-02-11 22:02:30 -05:00
QS('progressbar').width = '0px';
2019-08-11 01:34:21 -04:00
}
function processBlock(type, flags, time, data) {
if (type < 0) { pause(); return; }
var waitTime = Math.round((time - recFileLastTime) * parseFloat(Q('PlaySpeed').value));
if (waitTime < 5) {
processBlockEx(type, flags, time, data);
} else {
waitTimerArgs = [type, flags, time, data]
2020-02-11 22:02:30 -05:00
waitTimer = setTimeout(function () { waitTimer = null; if (waitTimerArgs) { processBlockEx(waitTimerArgs[0], waitTimerArgs[1], waitTimerArgs[2], waitTimerArgs[3]); } }, waitTime);
2019-08-11 01:34:21 -04:00
}
}
2020-02-11 18:34:27 -05:00
function processBlockEx(type, flags, time, data, forced) {
if ((playing == false) && (forced !== true)) return;
2019-08-11 01:34:21 -04:00
var flagBinary = (flags & 1) != 0, flagUser = (flags & 2) != 0;
2019-08-12 19:16:52 -04:00
2020-03-03 19:22:50 -05:00
if (type == 2) {
// Update the clock
recFileLastTime = time;
var deltaTimeTotalSec = Math.floor((time - recFileStartTime) / 1000);
if (currentDeltaTimeTotalSec != deltaTimeTotalSec) {
// Hours, minutes and seconds
currentDeltaTimeTotalSec = deltaTimeTotalSec;
var hrs = Math.floor(deltaTimeTotalSec / 3600);
var mins = Math.floor((deltaTimeTotalSec % 3600) / 60);
var secs = Math.floor(deltaTimeTotalSec % 60);
QH('timespan', pad2(hrs) + ':' + pad2(mins) + ':' + pad2(secs))
}
2019-08-12 19:16:52 -04:00
}
2019-08-11 01:34:21 -04:00
if ((type == 2) && flagBinary && !flagUser) {
2019-08-13 14:49:05 -04:00
// Device --> User data
2019-08-13 16:55:25 -04:00
if (recFileProtocol == 1) {
// MeshCentral Terminal
agentTerminal.ProcessData(data);
} else if (recFileProtocol == 2) {
2019-08-12 19:16:52 -04:00
// MeshCentral Remote Desktop
agentDesktop.ProcessData(data);
} else if (recFileProtocol == 101) {
// Intel AMT KVM
2019-09-15 15:47:59 -04:00
if ((readState == 0) && (rstr2hex(data) == '4100000000000000')) {
// We are not authenticated, KVM data starts here.
readState = 1;
if (data.length > 8) { amtDesktop.ProcessData(data.substring(8)); }
} else if (readState == 1) {
amtDesktop.ProcessData(data);
}
2019-08-13 14:49:05 -04:00
}
} else if ((type == 2) && flagBinary && flagUser) {
// User --> Device data
if (recFileProtocol == 101) {
// Intel AMT KVM
if (rstr2hex(data) == '0000000008080001000700070003050200000000') { amtDesktop.bpp = 1; } // Switch to 1 byte per pixel.
2019-08-11 01:34:21 -04:00
}
}
2019-08-12 19:16:52 -04:00
2019-08-11 01:34:21 -04:00
if (playing) { readNextBlock(processBlock); }
}
function cleanup() {
recFile = null;
recFilePtr = 0;
recFileMetadata = null;
2019-08-13 20:06:45 -04:00
playing = false;
2019-08-12 19:16:52 -04:00
if (agentDesktop != null) { agentDesktop.Canvas.clearRect(0, 0, agentDesktop.CanvasId.width, agentDesktop.CanvasId.height); agentDesktop = null; }
if (amtDesktop != null) { amtDesktop.canvas.clearRect(0, 0, amtDesktop.CanvasId.width, amtDesktop.CanvasId.height); amtDesktop = null; }
2019-08-11 01:34:21 -04:00
readState = 0;
waitTimerArgs = null;
currentDeltaTimeTotalSec = 0;
2019-08-13 14:49:05 -04:00
recFileEndTime = 0;
2019-08-13 17:22:55 -04:00
agentTerminal = null;
2019-08-11 01:34:21 -04:00
if (waitTimer != null) { clearTimeout(waitTimer); waitTimer = null; }
QH('deskstatus', '');
QE('PlayButton', false);
QE('PauseButton', false);
QE('RestartButton', false);
2020-02-11 18:34:27 -05:00
QE('SeekBackwardButton', false);
QE('SeekForwardButton', false);
2019-08-11 01:34:21 -04:00
QS('progressbar').width = '0px';
QH('timespan', '00:00:00');
QV('metadatadiv', true);
2019-10-17 20:13:55 -04:00
QH('metadatadiv', '<span style=\"font-family:Arial,Helvetica Neue,Helvetica,sans-serif;font-size:28px\">MeshCentral Session Player</span><br /><br /><span style=color:gray>' + "Drag & drop a .mcrec file or click \"Open File...\"" + '</span>');
2019-08-13 16:55:25 -04:00
QV('DeskParent', true);
QV('TermParent', false);
2019-08-11 01:34:21 -04:00
}
function ondrop(e) {
haltEvent(e);
QV('bigfail', false);
QV('bigok', false);
// Check if these are files we can upload, remove all folders.
if (e.dataTransfer == null) return;
var files = [];
for (var i in e.dataTransfer.files) {
if ((e.dataTransfer.files[i].type != null) && (e.dataTransfer.files[i].size != null) && (e.dataTransfer.files[i].size != 0) && (e.dataTransfer.files[i].name.endsWith('.mcrec'))) {
files.push(e.dataTransfer.files[i]);
}
}
if (files.length == 0) return;
cleanup();
recFile = files[0];
recFilePtr = 0;
2020-02-12 19:57:05 -05:00
readLastBlock(function (type, flags, time, extras) {
if (type == 3) {
// File is ok
recFileEndTime = time;
recFileExtras = extras;
readNextBlock(processFirstBlock);
} else {
// This is not a good file
recFileEndTime = 0;
}
});
2019-08-11 01:34:21 -04:00
}
var dragtimer = null;
function ondragover(e) {
haltEvent(e);
if (dragtimer != null) { clearTimeout(dragtimer); dragtimer = null; }
var ac = true;
QV('bigok', ac);
QV('bigfail', !ac);
}
function ondragleave(e) {
haltEvent(e);
dragtimer = setTimeout(function () { QV('bigfail', false); QV('bigok', false); dragtimer = null; }, 10);
}
function onkeypress(e) {
if (xxdialogMode) return;
if (e.key == ' ') { togglePause(); haltEvent(e); }
if (e.key == '1') { Q('PlaySpeed').value = 4; haltEvent(e); }
if (e.key == '2') { Q('PlaySpeed').value = 2; haltEvent(e); }
if (e.key == '3') { Q('PlaySpeed').value = 1; haltEvent(e); }
if (e.key == '4') { Q('PlaySpeed').value = 0.5; haltEvent(e); }
if (e.key == '5') { Q('PlaySpeed').value = 0.25; haltEvent(e); }
if (e.key == '6') { Q('PlaySpeed').value = 0.1; haltEvent(e); }
if (e.key == '0') { pause(); restart(); haltEvent(e); }
}
function openfile() {
var x = '<input type=file name=files id=p2fileinput style=width:100% accept=".mcrec" onchange="openfileChanged()" />';
setDialogMode(2, "Open File...", 3, openfileEx, x);
QE('idx_dlgOkButton', false);
}
function openfileEx() {
var xfiles = Q('p2fileinput').files;
if (xfiles != null) { var files = []; for (var i in xfiles) { if ((xfiles[i].type != null) && (xfiles[i].size != null) && (xfiles[i].size != 0) && (xfiles[i].name.endsWith('.mcrec'))) { files.push(xfiles[i]); } } }
if (files.length == 0) return;
cleanup();
recFile = files[0];
recFilePtr = 0;
readNextBlock(processFirstBlock);
2020-03-11 03:17:10 -04:00
readLastBlock(function (type, flags, time, extras) {
2020-02-12 19:57:05 -05:00
if (type == 3) {
// File is ok
recFileEndTime = time;
recFileExtras = extras;
readNextBlock(processFirstBlock);
} else {
// This is not a good file
recFileEndTime = 0;
}
});
2019-08-11 01:34:21 -04:00
Q('OpenFileButton').blur();
}
function openfileChanged() {
var xfiles = Q('p2fileinput').files;
if (xfiles != null) { var files = []; for (var i in xfiles) { if ((xfiles[i].type != null) && (xfiles[i].size != null) && (xfiles[i].size != 0) && (xfiles[i].name.endsWith('.mcrec'))) { files.push(xfiles[i]); } } }
QE('idx_dlgOkButton', files.length == 1);
}
2019-08-13 20:06:45 -04:00
function togglePause() {
if (recFile != null) { if (playing == true) { pause(); } else { if (recFilePtr != recFile.size) { play(); } } } return false;
}
2019-08-11 01:34:21 -04:00
function play() {
Q('PlayButton').blur();
if ((playing == true) || (recFileProtocol == 0)) return;
playing = true;
QV('metadatadiv', false);
QE('PlayButton', false);
QE('PauseButton', true);
QE('RestartButton', false);
2019-08-13 17:22:55 -04:00
if ((recFileProtocol == 1) && (agentTerminal == null)) {
2019-08-13 16:55:25 -04:00
QV('DeskParent', false);
QV('TermParent', true);
2019-08-13 17:22:55 -04:00
agentTerminal = CreateAmtRemoteTerminal('Term', { });
agentTerminal.State = 3;
2019-08-13 16:55:25 -04:00
}
2019-08-11 01:34:21 -04:00
readNextBlock(processBlock);
}
function pause() {
Q('PauseButton').blur();
if (playing == false) return;
playing = false;
QE('PlayButton', recFilePtr != recFile.size);
QE('PauseButton', false);
QE('RestartButton', recFilePtr != 0);
if (waitTimer != null) {
clearTimeout(waitTimer);
waitTimer = null;
processBlockEx(waitTimerArgs[0], waitTimerArgs[1], waitTimerArgs[2], waitTimerArgs[3]);
waitTimerArgs = null;
}
}
function restart() {
Q('RestartButton').blur();
if (playing == true) return;
recFilePtr = 0;
readState = 0;
currentDeltaTimeTotalSec = 0;
QV('metadatadiv', true);
QE('PlayButton', true);
QE('PauseButton', false);
QE('RestartButton', false);
QS('progressbar').width = '0px';
2019-08-12 19:16:52 -04:00
QH('timespan', '00:00:00');
2019-08-13 16:55:25 -04:00
QV('DeskParent', true);
QV('TermParent', false);
2019-08-13 14:49:05 -04:00
if (agentDesktop) {
agentDesktop.Canvas.clearRect(0, 0, agentDesktop.CanvasId.width, agentDesktop.CanvasId.height);
} else if (amtDesktop) {
amtDesktop.canvas.clearRect(0, 0, amtDesktop.CanvasId.width, amtDesktop.CanvasId.height);
amtDesktop = CreateAmtRemoteDesktop('Desk');
amtDesktop.onScreenSizeChange = deskAdjust;
amtDesktop.State = 3;
amtDesktop.Start();
2019-08-13 17:22:55 -04:00
} else if (agentTerminal) {
agentTerminal = null;
2019-08-13 14:49:05 -04:00
}
2019-08-11 01:34:21 -04:00
}
2019-08-13 14:49:05 -04:00
function clearConsoleMsg() { QH('p11DeskConsoleMsg', ''); }
2019-08-11 01:34:21 -04:00
// Toggle the web page to full screen
function toggleAspectRatio(toggle) {
if (toggle === 1) { deskAspectRatio = ((deskAspectRatio + 1) % 3); }
deskAdjust();
}
function deskAdjust() {
var parentH = Q('DeskParent').clientHeight, parentW = Q('DeskParent').clientWidth;
var deskH = Q('Desk').height, deskW = Q('Desk').width;
if (deskAspectRatio == 2) {
// Scale mode
QS('Desk')['margin-top'] = null;
QS('Desk').height = '100%';
QS('Desk').width = '100%';
QS('DeskParent').overflow = 'hidden';
} else if (deskAspectRatio == 1) {
// Zoomed mode
QS('Desk')['margin-top'] = '0px';
//QS('Desk')['margin-left'] = '0px';
QS('Desk').height = deskH + 'px';
QS('Desk').width = deskW + 'px';
QS('DeskParent').overflow = 'scroll';
} else {
// Fixed aspect ratio
if ((parentH / parentW) > (deskH / deskW)) {
var hNew = ((deskH * parentW) / deskW) + 'px';
//if (webPageFullScreen || fullscreen) {
//QS('deskarea3x').height = null;
//} else {
// QS('deskarea3x').height = hNew;
//QS('deskarea3x').height = null;
//}
QS('Desk').height = hNew;
QS('Desk').width = '100%';
} else {
var wNew = ((deskW * parentH) / deskH) + 'px';
//if (webPageFullScreen || fullscreen) {
2019-08-13 14:49:05 -04:00
//QS('Desk').height = null;
2019-08-11 01:34:21 -04:00
//} else {
2019-08-13 14:49:05 -04:00
QS('Desk').height = '100%';
2019-08-11 01:34:21 -04:00
//}
QS('Desk').width = wNew;
}
QS('Desk')['margin-top'] = null;
QS('DeskParent').overflow = 'hidden';
}
}
2020-02-11 18:34:27 -05:00
function seekBackward() {
2020-02-11 22:02:30 -05:00
var ndxNumber = Math.round(currentDeltaTimeTotalSec / recFileMetadata.indexInterval);
if (ndxNumber < 2) {
pause(); restart();
} else {
if (recFileMetadata.indexes[ndxNumber - 2] != null) { seek(ndxNumber - 2); }
}
2020-02-11 18:34:27 -05:00
}
function seekForward() {
2020-02-11 22:02:30 -05:00
var ndxNumber = Math.round(currentDeltaTimeTotalSec / recFileMetadata.indexInterval);
if (recFileMetadata.indexes[ndxNumber] != null) { seek(ndxNumber); }
2020-02-11 18:34:27 -05:00
}
2020-02-11 22:02:30 -05:00
function progressBarSeek(event) {
var ndxNumber = Math.round((event.clientX / document.body.offsetWidth) * (recFileMetadata.indexes.length + 1)) - 1;
if (ndxNumber == -1) { pause(); restart(); } else { seek(ndxNumber); }
}
2020-02-11 18:34:27 -05:00
var SeekIndex;
var SeekIndexPtr;
2020-02-11 22:02:30 -05:00
var SeekIndexTime;
var SeekPlayState;
2020-02-11 18:34:27 -05:00
function seek(indexNumber) {
//console.log('seek', indexNumber);
if ((recFileMetadata.indexes == null) || (recFileMetadata.indexes[indexNumber] == null)) return null;
2020-02-11 22:02:30 -05:00
SeekPlayState = playing;
pause();
2020-02-11 18:34:27 -05:00
restart();
SeekIndex = recFileMetadata.indexes[indexNumber];
SeekIndexPtr = 3;
2020-02-11 22:02:30 -05:00
recFileLastTime = SeekIndexTime = recFileStartTime + ((1 + indexNumber) * recFileMetadata.indexInterval * 1000);
recFilePtr = recFileIndexBasePtr + SeekIndex[0];
2020-02-11 18:34:27 -05:00
var width = SeekIndex[1];
var height = SeekIndex[2];
2020-02-11 22:02:30 -05:00
if (recFileEndTime == 0) {
// File pointer progress bar
QS('progressbar').width = Math.floor(100 * (recFilePtr / recFile.size)) + '%';
} else {
// Time progress bar
QS('progressbar').width = Math.floor(((recFileLastTime - recFileStartTime) / (recFileEndTime - recFileStartTime)) * 100) + '%';
}
if (agentDesktop) {
agentDesktop.Canvas.clearRect(0, 0, agentDesktop.CanvasId.width, agentDesktop.CanvasId.height);
agentDesktop.ProcessScreenMsg(width, height);
}
QV('metadatadiv', false);
QV('Desk', false);
seekFetchNext(function () { QV('Desk', true); if (SeekPlayState) { play(); } });
2020-02-11 18:34:27 -05:00
}
2020-02-11 22:02:30 -05:00
function seekFetchNext(func) {
if (SeekIndex[SeekIndexPtr] == null) { func(); return; }
2020-02-11 18:34:27 -05:00
readBlockAt(recFileIndexBasePtr + SeekIndex[SeekIndexPtr], function (type, flags, time, data) {
SeekIndexPtr++;
2020-02-11 22:02:30 -05:00
processBlockEx(type, flags, SeekIndexTime, data, true);
seekFetchNext(func);
2020-02-11 18:34:27 -05:00
});
}
2019-08-11 01:34:21 -04:00
//
// POPUP DIALOG
//
// null = Hidden, 1 = Generic Message
var xxdialogMode;
var xxdialogFunc;
var xxdialogButtons;
var xxdialogTag;
var xxcurrentView = -1;
// Display a dialog box
// Parameters: Dialog Mode (0 = none), Dialog Title, Buttons (1 = OK, 2 = Cancel, 3 = OK & Cancel), Call back function(0 = Cancel, 1 = OK), Dialog Content (Mode 2 only)
function setDialogMode(x, y, b, f, c, tag) {
xxdialogMode = x;
xxdialogFunc = f;
xxdialogButtons = b;
xxdialogTag = tag;
QE('idx_dlgOkButton', true);
QV('idx_dlgOkButton', b & 1);
QV('idx_dlgCancelButton', b & 2);
QV('id_dialogclose', (b & 2) || (b & 8));
QV('idx_dlgDeleteButton', b & 4);
QV('idx_dlgButtonBar', b & 7);
if (y) QH('id_dialogtitle', y);
for (var i = 1; i < 3; i++) { QV('dialog' + i, i == x); } // Edit this line when more dialogs are added
QV('dialog', x);
if (c) { if (x == 2) { QH('id_dialogOptions', c); } else { QH('id_dialogMessage', c); } }
}
function dialogclose(x) {
var f = xxdialogFunc, b = xxdialogButtons, t = xxdialogTag;
setDialogMode();
if (((b & 8) || x) && f) f(x, t);
}
function messagebox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t, 1); }
function statusbox(t, m) { setSessionActivity(); QH('id_dialogMessage', m); setDialogMode(1, t); }
function haltEvent(e) { if (e.preventDefault) e.preventDefault(); if (e.stopPropagation) e.stopPropagation(); return false; }
2019-10-17 20:13:55 -04:00
function pad2(num) { var s = '00' + num; return s.substr(s.length - 2); }
function format(format) { var args = Array.prototype.slice.call(arguments, 1); return format.replace(/ { (\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match; }); };
2019-08-11 01:34:21 -04:00
start();
</script>
</body>
</html>