mirror of
https://github.com/NetSPI/PowerHuntShares.git
synced 2025-05-04 19:28:42 +02:00
Update PowerHuntShares.psm1
Fixed sharegraph layout on page load.
This commit is contained in:
parent
b2c55204a8
commit
e3793c7e90
@ -4,7 +4,7 @@
|
|||||||
#--------------------------------------
|
#--------------------------------------
|
||||||
# Author: Scott Sutherland, 2024 NetSPI
|
# Author: Scott Sutherland, 2024 NetSPI
|
||||||
# License: 3-clause BSD
|
# License: 3-clause BSD
|
||||||
# Version: v1.110
|
# Version: v1.111
|
||||||
# References: This script includes custom code and code taken and modified from the open source projects PowerView, Invoke-Ping, and Invoke-Parrell.
|
# References: This script includes custom code and code taken and modified from the open source projects PowerView, Invoke-Ping, and Invoke-Parrell.
|
||||||
function Invoke-HuntSMBShares
|
function Invoke-HuntSMBShares
|
||||||
{
|
{
|
||||||
@ -8448,9 +8448,67 @@ document.querySelector('#nodemenu a:nth-child(2)').addEventListener('click', fun
|
|||||||
// START CYTOSCAPE EVENT LISTENERS
|
// START CYTOSCAPE EVENT LISTENERS
|
||||||
// #################################
|
// #################################
|
||||||
StartCytoListener();
|
StartCytoListener();
|
||||||
|
|
||||||
|
// #################################
|
||||||
|
// START CYTOSCAPE INITIAL LAYOUT
|
||||||
|
// #################################
|
||||||
|
// Flag to track if the layout has been applied
|
||||||
|
let layoutApplied = false;
|
||||||
|
|
||||||
|
// Set layout on sharegraph menu selection
|
||||||
|
document.getElementById('btnShareGraph').addEventListener('click', function () {
|
||||||
|
|
||||||
|
// Select nodes and edges
|
||||||
|
var selectedNodes = cy.nodes().not('.faded');
|
||||||
|
var selectedEdges = selectedNodes.connectedEdges().filter(function (edge) {
|
||||||
|
return edge.target().same(selectedNodes) || edge.source().same(selectedNodes);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Only apply the layout if it's the first time the button is clicked
|
||||||
|
if (!layoutApplied) {
|
||||||
|
// Get the selected layout from the dropdown (you can update this as needed)
|
||||||
|
var selectedLayout = 'breadthfirst';
|
||||||
|
|
||||||
|
// Apply the selected layout to the selected nodes and edges
|
||||||
|
cy.elements().layout({
|
||||||
|
name: selectedLayout,
|
||||||
|
fit: false,
|
||||||
|
animate: true,
|
||||||
|
eles: selectedNodes.union(selectedEdges), // Apply the layout to selected nodes and edges
|
||||||
|
ready: function() {
|
||||||
|
// This function is called when the layout is ready but not yet applied
|
||||||
|
},
|
||||||
|
stop: function() {
|
||||||
|
// This function is called after the layout has been completely applied
|
||||||
|
|
||||||
|
// Set the initial zoom level to 0.4 (40% of the original size)
|
||||||
|
cy.zoom(0.4);
|
||||||
|
|
||||||
|
// Re-center the graph after zooming
|
||||||
|
cy.center(selectedNodes);
|
||||||
|
|
||||||
|
// Optional: Ensure that the centered graph fits well within the viewport
|
||||||
|
cy.fit(selectedNodes, 50);
|
||||||
|
|
||||||
|
// Mark that the layout has been applied
|
||||||
|
layoutApplied = true;
|
||||||
|
}
|
||||||
|
}).run();
|
||||||
|
|
||||||
cy.layout({ name: 'breadthfirst' }).run();
|
// If the layout has already been applied, just re-center and zoom the graph
|
||||||
cy.fit(); // This ensures the graph is centered within the container
|
cy.zoom(0.4);
|
||||||
|
cy.center(selectedNodes);
|
||||||
|
cy.fit(selectedNodes, 50);
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zoom-in functionality
|
||||||
|
document.getElementById('zoom-in').addEventListener('click', function() {
|
||||||
|
const zoomLevel = cy.zoom();
|
||||||
|
cy.zoom(zoomLevel * 1.2); // Increase the zoom level by 20%
|
||||||
|
cy.center(selectedNodes); // Re-center after zooming in
|
||||||
|
});
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user