diff --git a/views/default.handlebars b/views/default.handlebars
index 946d87fa..10c0e5fb 100644
--- a/views/default.handlebars
+++ b/views/default.handlebars
@@ -606,7 +606,7 @@
';
+ r += '' + EscapeHtml(meshes[node.meshid].name) + '' + getMeshActions(mesh2, meshrights) + '';
if (view == 2) { r += ''; }
current = node.meshid;
displayedMeshes[current] = 1;
@@ -3062,7 +3062,7 @@
var icon = node.icon;
if ((!node.conn) || (node.conn == 0)) { icon += ' gray'; }
if (view == 1) {
- r += '' + name + '
' + NodeStateStr(node) + '
';
+ r += '' + name + '
' + NodeStateStr(node) + '
';
} else if (view == 2) {
var states = [];
if (node.conn) {
@@ -3999,65 +3999,56 @@
var contextelement = null;
function handleContextMenu(event) {
+ // When called, we look for elements with "cmenu=xxx" and show the right context menu for that element.
hideContextMenu();
var scrollLeft = (window.pageXOffset !== null) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft;
var scrollTop = (window.pageYOffset !== null) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
var elem = document.elementFromPoint(event.pageX - scrollLeft, event.pageY - scrollTop);
- //console.log('handleContextMenu', scrollLeft, scrollTop, elem, elem.parentElement, elem.parentElement.parentElement);
+ while (elem && elem != null && elem.attributes.cmenu == null) { elem = elem.parentElement; } // Go up until element with context menu or root is reached.
+ if (elem == null) return true; // No "cmenu=xxx" found at the element that was clicked.
+ var cmenu = elem.attributes.cmenu.value;
- // Look for a file entry element
- var fileElement = null, elx = elem;
- while (elx && elx != null && elx.id != 'fileEntry') { elx = elx.parentElement; }
- if (elx && (elx.id == 'fileEntry')) { fileElement = elx; }
-
- if (elem && elem != null && elem.id == 'rdpClickOnceLink' && currentNode && currentNode.agent && (currentNode.agent.id > 0) && (currentNode.agent.id < 5)) {
- contextelement = elem;
- var contextmenudiv = document.getElementById('altPortContextMenu');
- showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- } else if (elem && elem != null && elem.id == 'connectbutton2' && currentNode && currentNode.agent && (currentNode.agent.id > 0) && (currentNode.agent.id < 5)) {
- contextelement = elem;
- var contextmenudiv = document.getElementById('termShellContextMenu');
- showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- } else if (elem && elem != null && elem.id == 'connectbutton2' && currentNode && currentNode.agent && (currentNode.agent.id > 4)) {
- contextelement = elem;
- var contextmenudiv = document.getElementById('termShellContextMenuLinux');
- showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- } else if (fileElement && currentNode) {
- contextelement = fileElement;
- var contextmenudiv = document.getElementById('filesContextMenu');
- showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- } else if (elem && elem != null && elem.id == 'MxMESH') {
- contextelement = elem;
- var contextmenudiv = document.getElementById('meshContextMenu');
- showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- /*} else if (elem && elem != null && elem.classList.contains('pluginTab')) {
+ switch (cmenu) {
+ case 'termConnectButton': {
+ // Terminal connect button context menu
+ if ((currentNode == null) || (currentNode.agent == null)) return true;
contextelement = elem;
- var contextmenudiv = document.getElementById('pluginTabContextMenu');
+ var contextmenudiv = document.getElementById('termShellContextMenu'); // Windows options (Power Shell)
+ if (currentNode.agent.id > 4) { contextmenudiv = document.getElementById('termShellContextMenuLinux'); } // Non-Windows options
+ showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
+ break;
+ }
+ case 'devsContentMenu': {
+ // Device content menu
+ contextelement = elem;
+ var contextmenudiv = document.getElementById('contextMenu');
showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- */
- } else {
- while (elem && elem != null && elem.id != 'devs') { elem = elem.parentElement; }
- if (!elem || elem == null) return true;
- contextelement = elem;
- var contextmenudiv = document.getElementById('contextMenu');
- showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
- // Get the node and set the menu options
- var nodeid = contextelement.children[1].attributes.onclick.value;
- var node = getNodeFromId(nodeid.substring(12, nodeid.length - 18));
- var mesh = meshes[node.meshid];
- var rights = GetNodeRights(node);
- var consoleRights = ((rights & 16) != 0);
+ // Get the node and set the menu options
+ var nodeid = contextelement.children[1].attributes.onclick.value;
+ var node = getNodeFromId(nodeid.substring(12, nodeid.length - 18));
+ var mesh = meshes[node.meshid];
+ var rights = GetNodeRights(node);
+ var consoleRights = ((rights & 16) != 0);
- // Check if we have terminal and file access
- var terminalAccess = ((rights == 0xFFFFFFFF) || ((rights & 512) == 0));
- var fileAccess = ((rights == 0xFFFFFFFF) || ((rights & 1024) == 0));
+ // Check if we have terminal and file access
+ var terminalAccess = ((rights == 0xFFFFFFFF) || ((rights & 512) == 0));
+ var fileAccess = ((rights == 0xFFFFFFFF) || ((rights & 1024) == 0));
- QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((rights & 8) || (rights & 256)));
- QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (rights & 8) && terminalAccess);
- QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (rights & 8) && fileAccess);
- QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (rights & 8));
- QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (rights & 8));
+ QV('cxdesktop', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 1) != 0) || (node.intelamt && (node.intelamt.state == 2))) && ((rights & 8) || (rights & 256)));
+ QV('cxterminal', ((mesh.mtype == 1) || (node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 2) != 0) || (node.intelamt && (node.intelamt.state == 2))) && (rights & 8) && terminalAccess);
+ QV('cxfiles', ((mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 4) != 0))) && (rights & 8) && fileAccess);
+ QV('cxevents', (node.intelamt != null) && ((node.intelamt.state == 2) || (node.conn & 2)) && (rights & 8));
+ QV('cxconsole', (consoleRights && (mesh.mtype == 2) && ((node.agent == null) || (node.agent.caps == null) || ((node.agent.caps & 8) != 0))) && (rights & 8));
+ break;
+ }
+ default: {
+ // Basic context menu
+ if ((contextmenudiv = document.getElementById(cmenu)) == null) return true;
+ contextelement = elem;
+ showContextMenuDiv(contextmenudiv, event.pageX, event.pageY);
+ break;
+ }
}
return haltEvent(event);
}
@@ -4989,7 +4980,7 @@
// 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 ((node.agent.id > 0) && (node.agent.id < 5)) { x += '' + "RDP" + ' '; }
+ if ((node.agent.id > 0) && (node.agent.id < 5)) { x += '' + "RDP" + ' '; }
if (node.agent.id > 4) {
x += '' + "Putty" + ' ';
x += '' + "WinSCP" + ' ';
@@ -6847,7 +6838,7 @@
} else {
var link = shortname;
if (f.s > 0) { link = '' + shortname + ''; }
- h = '';
+ h = '';
}
if (f.t < 3) { html1 += h; } else { html2 += h; }