XTerm.js is now the default device terminal.

This commit is contained in:
Ylian Saint-Hilaire 2020-02-07 15:14:36 -08:00
parent e9dd9dc270
commit 11e46830fc
3 changed files with 1174 additions and 1001 deletions

View File

@ -627,14 +627,15 @@ body {
resize: none; resize: none;
} }
#idx_deskFullBtn2 { #idx_deskFullBtn2, #idx_termFullBtn2 {
float: left; float: left;
font-size: 16px; font-size: 16px;
cursor: pointer; cursor: pointer;
display: none; display: none;
margin-right: 5px;
} }
.fulldesk #idx_deskFullBtn2 { .fulldesk #idx_deskFullBtn2, .fulldesk #idx_termFullBtn2 {
display: block; display: block;
} }
@ -2284,6 +2285,14 @@ a {
margin-top: 0px; margin-top: 0px;
} }
.fulldesk #termTable {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
}
#termarea3x { #termarea3x {
background: black; background: black;
text-align: center; text-align: center;

File diff suppressed because it is too large Load Diff

View File

@ -10,6 +10,7 @@
<link keeplink=1 type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" /> <link keeplink=1 type="text/css" href="styles/style.css" media="screen" rel="stylesheet" title="CSS" />
<link type="text/css" href="styles/ol.css" media="screen" rel="stylesheet" title="CSS" /> <link type="text/css" href="styles/ol.css" media="screen" rel="stylesheet" title="CSS" />
<link type="text/css" href="styles/ol3-contextmenu.min.css" media="screen" rel="stylesheet" title="CSS" /> <link type="text/css" href="styles/ol3-contextmenu.min.css" media="screen" rel="stylesheet" title="CSS" />
<link type="text/css" href="styles/xterm.css" media="screen" rel="stylesheet" title="CSS" />
<script type="text/javascript" src="scripts/common-0.0.1.js"></script> <script type="text/javascript" src="scripts/common-0.0.1.js"></script>
<script type="text/javascript" src="scripts/meshcentral.js"></script> <script type="text/javascript" src="scripts/meshcentral.js"></script>
<script type="text/javascript" src="scripts/amt-0.2.0.js"></script> <script type="text/javascript" src="scripts/amt-0.2.0.js"></script>
@ -26,6 +27,8 @@
<script type="text/javascript" src="scripts/agent-redir-rtc-0.1.0.js"></script> <script type="text/javascript" src="scripts/agent-redir-rtc-0.1.0.js"></script>
<script type="text/javascript" src="scripts/agent-desktop-0.0.2.js"></script> <script type="text/javascript" src="scripts/agent-desktop-0.0.2.js"></script>
<script type="text/javascript" src="scripts/qrcode.min.js"></script> <script type="text/javascript" src="scripts/qrcode.min.js"></script>
<script type="text/javascript" src="scripts/xterm.js"></script>
<script type="text/javascript" src="scripts/xterm-addon-fit.js"></script>
<script keeplink=1 type="text/javascript" src="scripts/u2f-api.js"></script> <script keeplink=1 type="text/javascript" src="scripts/u2f-api.js"></script>
<script keeplink=1 type="text/javascript" src="scripts/charts.js"></script> <script keeplink=1 type="text/javascript" src="scripts/charts.js"></script>
<script keeplink=1 type="text/javascript" src="scripts/filesaver.js"></script> <script keeplink=1 type="text/javascript" src="scripts/filesaver.js"></script>
@ -576,6 +579,7 @@
<div id=p12 style="display:none"> <div id=p12 style="display:none">
<div id="p12title"> <div id="p12title">
<div id="p12BackButton"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div> <div id="p12BackButton"><div class="backButton" tabindex=0 onclick=goBack() title="Back" onkeypress="if (event.key == 'Enter') goBack()"><div class="backButtonEx"></div></div></div>
<div id="devListToolbarViewIcons2" style="float:right"><div class="viewSelector" onclick=deskToggleFull(event) title="Full Screen. Hold shift to browser full screen."><div class="viewSelector5"></div></div></div>
<h1>Terminal - <span id=p12deviceName></span></h1> <h1>Terminal - <span id=p12deviceName></span></h1>
</div> </div>
<div id="p12warning" onclick=showFeaturesDlg()> <div id="p12warning" onclick=showFeaturesDlg()>
@ -595,6 +599,7 @@
<input id="termActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() /> <input id="termActionsBtn" type=button title="Perform power actions on the device" onkeypress="return false" onkeydown="return false" value=Actions onclick=deviceActionFunction() />
</div> </div>
<div> <div>
<div id="idx_termFullBtn2" onclick=deskToggleFull(event)>&nbsp;&#x2716;</div>
<input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none" /> <input type="button" id="autoconnectbutton2" value="AutoConnect" onclick=autoConnectTerminal(event) onkeypress="return false" onkeydown="return false" style="display:none" />
<span id="connectbutton2span"><input type="button" id="connectbutton2" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span> <span id="connectbutton2span"><input type="button" id="connectbutton2" value="Connect" onclick=connectTerminal(event,1) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
<span id="connectbutton2hspan">&nbsp;<input type="button" id="connectbutton2h" value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span> <span id="connectbutton2hspan">&nbsp;<input type="button" id="connectbutton2h" value="HW Connect" title="Connect using Intel AMT hardware KVM" onclick=connectTerminal(event,2) onkeypress="return false" onkeydown="return false" disabled="disabled" /></span>
@ -610,6 +615,7 @@
</tr> </tr>
<tr> <tr>
<td id="termarea3x"> <td id="termarea3x">
<div id="termarea3xdiv" style="width:100%;height:100%"></div>
<pre id="Term"></pre> <pre id="Term"></pre>
</td> </td>
</tr> </tr>
@ -622,19 +628,21 @@
<input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()" /> <input id="id_tfxkeysbutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Intel (F10 = ESC+[OM)" title="Toggle F1 to F10 keys emulation type" onclick="termToggleFx()" />
<input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()" /> <input id="id_ttypebutton" type="button" onkeypress="return false" onkeydown="return false" class="bottombutton" value="Extended Ascii" title="Toggle terminal emulation type" onclick="termToggleType()" />
</span> </span>
<span id="terminalSizeDropDown"> <span id="terminalSizeDropDown" style="display:none">
<select id="termSizeList" onkeypress="return false"><option value="1">80x25</option><option value="2">100x30</option><option value="3" selected>Auto</option></select> <select id="termSizeList" onkeypress="return false"><option value="1">80x25</option><option value="2">100x30</option><option value="3" selected>Auto</option></select>
</span> </span>
<select id="specialkeylist" onkeypress="return false"></select> <span id="specialKeyDropDown">
<input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()" /> <select id="specialkeylist" onkeypress="return false"></select>
<input id="specialkeylistinput" type="button" onkeypress="return false" class="bottombutton" value="Send" title="Send the selected special key" onclick="sendSpecialKey()" />
</span>
</div> </div>
<div> <div>
&nbsp; &nbsp;
<input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')" /> <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlcbutton" value="Ctl-C" onclick="termSendKey(3,'ctrlcbutton')" />
<input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')" /> <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="ctrlxbutton" value="Ctl-X" onclick="termSendKey(24,'ctrlxbutton')" />
<input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')" /> <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="escbutton" value="ESC" onclick="termSendKey(27,'escbutton')" />
<input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')" /> <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="bsbutton" value="Backspace" onclick="termSendKey(8,'bsbutton')" style="display:none" />
<input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()" /> <input type=button onkeypress="return false" onkeydown="return false" class="bottombutton" id="pastebutton" value="Paste" title="Paste text into the terminal" onclick="showTermPasteDialog()" style="display:none" />
</div> </div>
</td> </td>
</tr> </tr>
@ -1179,6 +1187,9 @@
var goBackStack = []; var goBackStack = [];
var CollapsedGroups = {}; var CollapsedGroups = {};
try { CollapsedGroups = JSON.parse(getstore('_collapse', '{}')); } catch(ex) {} try { CollapsedGroups = JSON.parse(getstore('_collapse', '{}')); } catch(ex) {}
var xterm = null;
var xtermfit = null;
var xtermResizeTimer = null;
// Console Message Display Timers // Console Message Display Timers
var p11DeskConsoleMsgTimer = null; var p11DeskConsoleMsgTimer = null;
@ -1239,7 +1250,11 @@
document.onkeyup = ondockeyup; document.onkeyup = ondockeyup;
//window.addEventListener('focus', ondocfocus, false); //window.addEventListener('focus', ondocfocus, false);
window.addEventListener('blur', ondocblur, false); window.addEventListener('blur', ondocblur, false);
window.onresize = function () { hideContextMenu(); masterUpdate(512); } window.onresize = function () {
hideContextMenu();
masterUpdate(512);
if (xtermfit != null) { xtermfit.fit(); }
}
setTimeout(function() { masterUpdate(512); }, 200); setTimeout(function() { masterUpdate(512); }, 200);
// Connect to the mesh server // Connect to the mesh server
@ -1318,6 +1333,14 @@
if (('{{{lang}}}' != 'en') && ('{{{lang}}}' != '')) { QC('body').add('nonenglish'); } if (('{{{lang}}}' != 'en') && ('{{{lang}}}' != '')) { QC('body').add('nonenglish'); }
var elements = document.getElementsByClassName('topbar_td'); var elements = document.getElementsByClassName('topbar_td');
for (var i in elements) { if (elements[i].innerHTML) { elements[i].innerHTML = elements[i].innerHTML.split(' ').join('&nbsp;'); } } for (var i in elements) { if (elements[i].innerHTML) { elements[i].innerHTML = elements[i].innerHTML.split(' ').join('&nbsp;'); } }
// Display extra buttons on legacy terminal
if (args.xterm === 0) {
QV('termarea3xdiv', false);
QV('bsbutton', true);
QV('pastebutton', true);
QV('terminalSizeDropDown', true);
}
} }
function adjustPanels() { function adjustPanels() {
@ -1380,11 +1403,21 @@
QS('deskarea3x')['max-height'] = null; QS('deskarea3x')['max-height'] = null;
QS('p14iframe')['height'] = null; QS('p14iframe')['height'] = null;
QS('p14iframe')['max-height'] = null; QS('p14iframe')['max-height'] = null;
if (args.xterm !== 0) {
QS('termarea3x')['height'] = 'calc(100vh - 55px)';
QS('termarea3xdiv')['height'] = 'calc(100vh - 55px)';
QS('termarea3x')['max-width'] = 'calc(1px)';
}
} else { } else {
QS('deskarea3x')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)'; QS('deskarea3x')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)'; QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('p14iframe')['height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)'; QS('p14iframe')['height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)';
QS('p14iframe')['max-height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)'; QS('p14iframe')['max-height'] = 'calc(100vh - ' + (23 + xh + xh2) + 'px)';
if (args.xterm !== 0) {
QS('termarea3x')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('termarea3xdiv')['height'] = 'calc(100vh - ' + (74 + xh + xh2) + 'px)';
QS('termarea3x')['max-width'] = 'calc(1px)';
}
} }
QS('p43iframe')['height'] = 'calc(100vh - ' + (84 + xh) + 'px)'; QS('p43iframe')['height'] = 'calc(100vh - ' + (84 + xh) + 'px)';
QS('p43iframe')['max-height'] = 'calc(100vh - ' + (84 + xh) + 'px)'; QS('p43iframe')['max-height'] = 'calc(100vh - ' + (84 + xh) + 'px)';
@ -2757,7 +2790,7 @@
} }
return desktop.m.handleKeys(e); return desktop.m.handleKeys(e);
} }
if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { return terminal.m.TermHandleKeys(e); } if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3 && xterm == null) { return terminal.m.TermHandleKeys(e); }
if (!xxdialogMode && ((xxcurrentView == 15) || (xxcurrentView == 115))) return agentConsoleHandleKeys(e); if (!xxdialogMode && ((xxcurrentView == 15) || (xxcurrentView == 115))) return agentConsoleHandleKeys(e);
if (!xxdialogMode && xxcurrentView == 4) { if (!xxdialogMode && xxcurrentView == 4) {
if (e.ctrlKey == true || e.altKey == true || e.metaKey == true) return; if (e.ctrlKey == true || e.altKey == true || e.metaKey == true) return;
@ -2816,7 +2849,7 @@
} }
return desktop.m.handleKeyDown(e); return desktop.m.handleKeyDown(e);
} }
if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { terminal.m.TermHandleKeyDown(e); if ((e.keyCode >= 37) && (e.keyCode <= 40)) { haltEvent(e); } } if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3 && xterm == null) { terminal.m.TermHandleKeyDown(e); if ((e.keyCode >= 37) && (e.keyCode <= 40)) { haltEvent(e); } }
if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { haltEvent(e); return false; } // F5 Refresh on files if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { haltEvent(e); return false; } // F5 Refresh on files
if (!xxdialogMode && ((xxcurrentView == 15) || (xxcurrentView == 115))) { return agentConsoleHandleKeys(e); } if (!xxdialogMode && ((xxcurrentView == 15) || (xxcurrentView == 115))) { return agentConsoleHandleKeys(e); }
if (!xxdialogMode && xxcurrentView == 4) { if (!xxdialogMode && xxcurrentView == 4) {
@ -2850,7 +2883,7 @@
} }
return desktop.m.handleKeyUp(e); return desktop.m.handleKeyUp(e);
} }
if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3) { return terminal.m.TermHandleKeyUp(e); } if (!xxdialogMode && xxcurrentView == 12 && terminal && terminal.State == 3 && xterm == null) { return terminal.m.TermHandleKeyUp(e); }
if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { p13folderup(9999); haltEvent(e); return false; } // F5 Refresh on files if (!xxdialogMode && xxcurrentView == 13 && e.keyCode == 116 && p13filetree != null) { p13folderup(9999); haltEvent(e); return false; } // F5 Refresh on files
if (!xxdialogMode && xxcurrentView == 4) { if ((e.keyCode === 8 && searchFocus == 0) || e.keyCode === 27) { return haltEvent(e); } } if (!xxdialogMode && xxcurrentView == 4) { if ((e.keyCode === 8 && searchFocus == 0) || e.keyCode === 27) { return haltEvent(e); } }
if (xxdialogMode && e.keyCode == 27) { dialogclose(0); } if (xxdialogMode && e.keyCode == 27) { dialogclose(0); }
@ -4867,7 +4900,7 @@
if (mesh.mtype == 2) x += '<a href=# onclick=p10showNodeNetInfoDialog("' + node._id + '") title=\"' + "Show device network interface information" + '\">' + "Interfaces" + '</a>&nbsp;'; if (mesh.mtype == 2) x += '<a href=# onclick=p10showNodeNetInfoDialog("' + node._id + '") title=\"' + "Show device network interface information" + '\">' + "Interfaces" + '</a>&nbsp;';
if (xxmap != null) x += '<a href=# onclick=p10showNodeLocationDialog("' + node._id + '") title=\"' + "Show device locations information" + '\">' + "Location" + '</a>&nbsp;'; if (xxmap != null) x += '<a href=# onclick=p10showNodeLocationDialog("' + node._id + '") title=\"' + "Show device locations information" + '\">' + "Location" + '</a>&nbsp;';
if ((terminalAccess) && ((meshrights & 8) != 0) && (mesh.mtype == 2)) x += '<a href=# onclick=p10showMeshCmdDialog(1,"' + node._id + '") title=\"' + "Traffic router used to connect to a device thru this server" + '.\">' + "Router" + '</a>&nbsp;'; if ((terminalAccess) && ((meshrights & 8) != 0) && (mesh.mtype == 2)) x += '<a href=# onclick=p10showMeshCmdDialog(1,"' + node._id + '") title=\"' + "Traffic router used to connect to a device thru this server" + '.\">' + "Router" + '</a>&nbsp;';
if ((mesh.mtype == 2) && ((node.agent.caps & 2) != 0) && ((meshrights & 8) != 0) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0))) { x += '<a href=# onclick=p10openxterm(event,"' + node._id + '") title=\"' + "Open XTerm terminal" + '\">' + "XTerm" + '</a>&nbsp;'; } //if ((mesh.mtype == 2) && ((node.agent.caps & 2) != 0) && ((meshrights & 8) != 0) && ((meshrights == 0xFFFFFFFF) || ((meshrights & 512) == 0))) { x += '<a href=# onclick=p10openxterm(event,"' + node._id + '") title=\"' + "Open XTerm terminal" + '\">' + "XTerm" + '</a>&nbsp;'; }
// RDP link, show this link only of the remote machine is Windows. // RDP link, show this link only of the remote machine is Windows.
if (((connectivity & 1) != 0) && (clickOnce == true) && (mesh.mtype == 2) && ((meshrights & 8) != 0)) { if (((connectivity & 1) != 0) && (clickOnce == true) && (mesh.mtype == 2) && ((meshrights & 8) != 0)) {
@ -5825,8 +5858,21 @@
QC('body').add('fulldesk'); QC('body').add('fulldesk');
QS('deskarea3x')['height'] = '100%'; QS('deskarea3x')['height'] = '100%';
QS('deskarea3x')['max-height'] = '100%'; QS('deskarea3x')['max-height'] = '100%';
if (args.xterm !== 0) {
// XTerm terminal
QS('termTable')['position'] = 'absolute';
QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = '0';
} else {
// Legacy terminal
QS('termTable')['height'] = '100%';
QS('termTable')['max-height'] = '100%';
}
// If shift is pressed, enter browser full screen. // If shift is pressed, enter browser full screen.
if (e.shiftKey == true) { enterBrowserFullscreen(Q('deskarea0')); browserfullscreen = true; } if (e.shiftKey == true) {
if (xxcurrentView == 12) { enterBrowserFullscreen(Q('termTable')); } else { enterBrowserFullscreen(Q('deskarea0')); }
browserfullscreen = true;
}
} else { } else {
QC('body').remove('fulldesk'); QC('body').remove('fulldesk');
var hide = args.hide; var hide = args.hide;
@ -5834,11 +5880,23 @@
var xh = (((hide & 1) ? 0 : 66) + ((hide & 2) ? 0 : 24) + ((hide & 4) ? 0 : 45) + ((hide & 8) ? 0 : 60)); // 0 to 195 var xh = (((hide & 1) ? 0 : 66) + ((hide & 2) ? 0 : 24) + ((hide & 4) ? 0 : 45) + ((hide & 8) ? 0 : 60)); // 0 to 195
QS('deskarea3x')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)'; QS('deskarea3x')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)'; QS('deskarea3x')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
if (args.xterm !== 0) {
// XTerm terminal
QS('termTable')['position'] = null;
QS('termTable')['top'] = QS('termTable')['bottom'] = QS('termTable')['left'] = QS('termTable')['right'] = null;
} else {
// Legacy terminal
QS('termTable')['height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
QS('termTable')['max-height'] = 'calc(100vh - ' + (75 + xh) + 'px)';
}
if (browserfullscreen == true) { exitBrowserFullscreen(); browserfullscreen = false; } if (browserfullscreen == true) { exitBrowserFullscreen(); browserfullscreen = false; }
} }
deskAdjust(); deskAdjust();
updateDesktopButtons(); updateDesktopButtons();
adjustPanels(); adjustPanels();
//setTimeout(adjustPanels, 10);
//setTimeout(function() { xtermfit.fit(); }, 10);
if (xterm != null) { xtermfit.fit(); if (xxcurrentView == 12) { xterm.focus(); } }
} }
function deskToggleFocus() { function deskToggleFocus() {
@ -6307,8 +6365,13 @@
QE('termSizeList', true); QE('termSizeList', true);
QH('termtitle', ''); QH('termtitle', '');
QV('termRecordIcon', false); QV('termRecordIcon', false);
xterminal.m.TermResetScreen(); if (xterm == null) {
xterminal.m.TermDraw(); xterminal.m.TermResetScreen();
xterminal.m.TermDraw();
} else {
xterm.dispose();
xterm = xtermfit = null;
}
if (terminal != null) { terminal.Stop(); terminal = null; } if (terminal != null) { terminal.Stop(); terminal = null; }
break; break;
case 3: case 3:
@ -6316,6 +6379,7 @@
if (xterminal && (xterminal.serverIsRecording == true)) { QV('termRecordIcon', true); } if (xterminal && (xterminal.serverIsRecording == true)) { QV('termRecordIcon', true); }
terminal.startTime = new Date(); terminal.startTime = new Date();
if (updateSessionTimer == null) { updateSessionTimer = setInterval(updateSessionTime, 1000); } if (updateSessionTimer == null) { updateSessionTimer = setInterval(updateSessionTime, 1000); }
if (xterm != null) { xterm.focus(); }
break; break;
default: default:
QE('termSizeList', false); QE('termSizeList', false);
@ -6329,6 +6393,25 @@
var autoConnectTerminalTimer = null; var autoConnectTerminalTimer = null;
function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } } function autoConnectTerminal(e) { if (autoConnectTerminalTimer == null) { autoConnectTerminalTimer = setInterval(connectTerminal, 100); } else { clearInterval(autoConnectTerminalTimer); autoConnectTerminalTimer = null; } }
// Handles a tunnel to a remote shell
function CreateRemoteTunnel(onTunnelUpdate, options) {
var obj = { protocol: 1 };
if ((options != null) && (typeof options.protocol == 'number')) { obj.protocol = options.protocol; }
obj.onTunnelUpdate = onTunnelUpdate;
obj.xxStateChange = function (state) { }
obj.ProcessBinaryData = function (data) { obj.onTunnelUpdate(data); }
obj.ProcessData = function (data) { obj.onTunnelUpdate(data); }
return obj;
}
function tunnelUpdate(data) { if (typeof data == 'string') { xterm.writeUtf8(data); } else { xterm.writeUtf8(new Uint8Array(data)); } }
// Send the new terminal size to the agent
function xTermSendResize() {
xtermResizeTimer = null;
if ((xterm != null) && (terminal != null)) { terminal.sendCtrlMsg(JSON.stringify({ ctrlChannel: '102938', type: 'termsize', cols: xterm.cols, rows: xterm.rows })); }
}
function connectTerminal(e, contype, options) { function connectTerminal(e, contype, options) {
p12clearConsoleMsg(); p12clearConsoleMsg();
if (!terminal) { if (!terminal) {
@ -6337,16 +6420,45 @@
if ((terminalNode.intelamt.user == null) || (terminalNode.intelamt.user == '')) { editDeviceAmtSettings(terminalNode._id, connectTerminal, 2); return; } if ((terminalNode.intelamt.user == null) || (terminalNode.intelamt.user == '')) { editDeviceAmtSettings(terminalNode._id, connectTerminal, 2); return; }
var termoptions = {}; var termoptions = {};
if (Q('termSizeList').value == 2) { termoptions.width = 100; termoptions.height = 30; } if (Q('termSizeList').value == 2) { termoptions.width = 100; termoptions.height = 30; }
terminal = CreateAmtRedirect(CreateAmtRemoteTerminal('Term', termoptions), authCookie);
terminal.debugmode = debugmode; if (args.xterm !== 0) {
terminal.m.debugmode = debugmode; // Setup a mesh agent xterm terminal
terminal.m.onTitleChange = function (sender, title) { QH('termtitle', ' - ' + EscapeHtml(title)); }
terminal.onStateChanged = onTerminalStateChange; // Setup the terminal with auto-fit
terminal.Start(terminalNode._id, 16994, '*', '*', 0); if (xterm != null) { xterm.dispose(); }
terminal.contype = 2; xtermfit = new FitAddon.FitAddon();
Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation]; xterm = new Terminal();
if (xtermfit) { xterm.loadAddon(xtermfit); }
xterm.open(Q('termarea3xdiv')); // termarea3x
xterm.onData(function (data) { if (terminal != null) { terminal.send(data); } })
if (xtermfit) { xtermfit.fit(); }
xterm.onTitleChange(function (title) { QH('termtitle', ' - ' + EscapeHtml(title)); });
xterm.onResize(function (size) {
// Despam resize
if (xtermResizeTimer) clearTimeout(xtermResizeTimer);
xtermResizeTimer = setTimeout(xTermSendResize, 200);
});
// Setup a terminal tunnel to the agent
terminal = CreateAmtRedirect(CreateRemoteTunnel(tunnelUpdate, termoptions), authCookie);
terminal.debugmode = debugmode;
terminal.m.debugmode = debugmode;
terminal.Start(terminalNode._id, 16994, '*', '*', 0);
terminal.onStateChanged = onTerminalStateChange;
terminal.contype = 2;
} else {
// Setup a mesh agent legacy terminal
terminal = CreateAmtRedirect(CreateAmtRemoteTerminal('Term', termoptions), authCookie);
terminal.debugmode = debugmode;
terminal.m.debugmode = debugmode;
terminal.m.onTitleChange = function (sender, title) { QH('termtitle', ' - ' + EscapeHtml(title)); }
terminal.onStateChanged = onTerminalStateChange;
terminal.Start(terminalNode._id, 16994, '*', '*', 0);
terminal.contype = 2;
Q('id_ttypebutton').value = terminalEmulations[terminal.m.terminalEmulation];
}
} else { } else {
// Setup a mesh agent terminal // Terminal setup
var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number'))?options.protocol:1 }; var termoptions = { protocol: ((options != null) && (typeof options.protocol == 'number'))?options.protocol:1 };
if (options && options.requireLogin) { termoptions.requireLogin = true; } if (options && options.requireLogin) { termoptions.requireLogin = true; }
if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) { if ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) == -1) {
@ -6368,32 +6480,72 @@
} }
} }
terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term', termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl); if (args.xterm !== 0) {
terminal.options = termoptions; // Setup a mesh agent xterm terminal
terminal.debugmode = debugmode;
terminal.m.debugmode = debugmode; // Setup the terminal with auto-fit
terminal.m.onTitleChange = function (sender, title) { QH('termtitle', ' - ' + EscapeHtml(title)); } if (xterm != null) { xterm.dispose(); }
terminal.m.lineFeed = ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) >= 0) ? '\r\n' : '\r'; // On windows, send \r\n, on Linux only \r xtermfit = new FitAddon.FitAddon();
terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it. xterm = new Terminal();
terminal.onStateChanged = onTerminalStateChange; if (xtermfit) { xterm.loadAddon(xtermfit); }
terminal.onConsoleMessageChange = function () { xterm.open(Q('termarea3xdiv')); // termarea3x
p12clearConsoleMsg(); xterm.onData(function (data) { if (terminal != null) { terminal.sendText(data); } })
if (terminal.consoleMessage) { if (xtermfit) { xtermfit.fit(); }
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />')); xterm.onTitleChange(function (title) { QH('termtitle', ' - ' + EscapeHtml(title)); });
QV('p12TermConsoleMsg', true); xterm.onResize(function (size) {
p12TermConsoleMsgTimer = setTimeout(p12clearConsoleMsg, 8000); // Despam resize
if (xtermResizeTimer) clearTimeout(xtermResizeTimer);
xtermResizeTimer = setTimeout(xTermSendResize, 200);
});
// Setup a terminal tunnel to the agent
terminal = CreateAgentRedirect(meshserver, CreateRemoteTunnel(tunnelUpdate, options), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
terminal.debugmode = debugmode;
terminal.m.debugmode = debugmode;
terminal.options = { cols: xterm.cols, rows: xterm.rows };
if (options && options.requireLogin) { terminal.options.requireLogin = true; }
terminal.Start(terminalNode._id);
terminal.onStateChanged = onTerminalStateChange;
terminal.contype = 1;
terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it.
terminal.onConsoleMessageChange = function (server, msg) {
p12clearConsoleMsg();
if (terminal.consoleMessage) {
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />'));
QV('p12TermConsoleMsg', true);
p12TermConsoleMsgTimer = setTimeout(p12clearConsoleMsg, 8000);
}
};
} else {
// Setup a mesh agent legacy terminal
terminal = CreateAgentRedirect(meshserver, CreateAmtRemoteTerminal('Term', termoptions), serverPublicNamePort, authCookie, authRelayCookie, domainUrl);
terminal.options = termoptions;
terminal.debugmode = debugmode;
terminal.m.debugmode = debugmode;
terminal.m.onTitleChange = function (sender, title) { QH('termtitle', ' - ' + EscapeHtml(title)); }
terminal.m.lineFeed = ([1, 2, 3, 4, 21, 22].indexOf(currentNode.agent.id) >= 0) ? '\r\n' : '\r'; // On windows, send \r\n, on Linux only \r
terminal.attemptWebRTC = false; // Never do WebRTC on terminal, because of a race condition we can't do it.
terminal.onStateChanged = onTerminalStateChange;
terminal.onConsoleMessageChange = function () {
p12clearConsoleMsg();
if (terminal.consoleMessage) {
QH('p12TermConsoleMsg', EscapeHtml(terminal.consoleMessage).split('\n').join('<br />'));
QV('p12TermConsoleMsg', true);
p12TermConsoleMsgTimer = setTimeout(p12clearConsoleMsg, 8000);
}
} }
terminal.Start(terminalNode._id);
terminal.contype = 1;
terminal.m.terminalEmulation = 0;
terminal.m.fxEmulation = 0;
Q('id_ttypebutton').value = terminalEmulations[0];
} }
terminal.Start(terminalNode._id);
terminal.contype = 1;
terminal.m.terminalEmulation = 0;
terminal.m.fxEmulation = 0;
Q('id_ttypebutton').value = terminalEmulations[0];
} }
} else { } else {
//QH('Term', ''); //QH('Term', '');
terminal.Stop(); terminal.Stop();
terminal = null; terminal = null;
if (fullscreen) { deskToggleFull(); }
} }
Q('connectbutton2').blur(); // Deselect the connect button so the button does not get key presses. Q('connectbutton2').blur(); // Deselect the connect button so the button does not get key presses.
} }
@ -6422,8 +6574,13 @@
function termSendKey(key, id) { function termSendKey(key, id) {
if (!terminal || xxdialogMode) return; if (!terminal || xxdialogMode) return;
terminal.m.TermSendKey(key); if (xterm != null) {
Q(id).blur(); // Deselect the connect button so the button does not get key presses. terminal.sendText(String.fromCharCode(key));
xterm.focus();
} else if (terminal != null) {
terminal.m.TermSendKey(key);
Q(id).blur(); // Deselect the connect button so the button does not get key presses.
}
} }
function showTermPasteDialog() { function showTermPasteDialog() {
@ -6440,9 +6597,14 @@
// Send special key // Send special key
function sendSpecialKey() { function sendSpecialKey() {
terminal.m.TermSendKey(Q('specialkeylist').value); if (xterm != null) {
Q('specialkeylist').blur(); terminal.sendText(String.fromCharCode(Q('specialkeylist').value));
Q('specialkeylistinput').blur(); xterm.focus();
} else if (terminal != null) {
terminal.m.TermSendKey(Q('specialkeylist').value);
Q('specialkeylist').blur();
Q('specialkeylistinput').blur();
}
} }
// //
@ -10425,6 +10587,9 @@
for (var i = 0; i < 52; i++) { QV('p' + i, i == x); } for (var i = 0; i < 52; i++) { QV('p' + i, i == x); }
xxcurrentView = x; xxcurrentView = x;
// Get out of fullscreen if needed
if (fullscreen) { deskToggleFull(); }
// Change the URL // Change the URL
if (xxcurrentView > 0) { if (xxcurrentView > 0) {
var urlviewmode = ''; var urlviewmode = '';
@ -10539,6 +10704,9 @@
document.title = decodeURIComponent('{{{extitle}}}'); document.title = decodeURIComponent('{{{extitle}}}');
} }
if (pluginHandler != null) pluginHandler.callHook('goPageEnd', x, event); if (pluginHandler != null) pluginHandler.callHook('goPageEnd', x, event);
// Some panels must not have scroll bars
QS('column_l')['overflow'] = ([11,12].indexOf(x)>= 0)?'hidden':null;
} }
// //