add bulk node modal

This commit is contained in:
2025-09-08 14:45:17 -05:00
parent a4d9e71019
commit 193a83b1d5
3 changed files with 64 additions and 0 deletions
+8
View File
@@ -49,6 +49,7 @@
<button id="addNode" class="controlButton">Add Node</button> <button id="addNode" class="controlButton">Add Node</button>
<button id="sendPacket" class="controlButton">Send Packet</button> <button id="sendPacket" class="controlButton">Send Packet</button>
<button id="resetTTLColors" class="controlButton">Reset TTL Colors</button> <button id="resetTTLColors" class="controlButton">Reset TTL Colors</button>
<button id="createRandomGraph" class="controlButton">Create Random Graph</button>
</div> </div>
<div id="simToggles"> <div id="simToggles">
<input type="checkbox" id="showRanges" class="simToggle"> <input type="checkbox" id="showRanges" class="simToggle">
@@ -64,6 +65,13 @@
<details id="incomingConnections"><summary>Incoming Connections</summary></details> <details id="incomingConnections"><summary>Incoming Connections</summary></details>
<details id="outgoingConnections"><summary>Outgoing Connections</summary></details> <details id="outgoingConnections"><summary>Outgoing Connections</summary></details>
</div> </div>
<div id="randomGraphModal">
<div id="randomGraphModalContent">
<label for="randomGraphNodes">Number of Nodes</label>
<input type="number" id="randomGraphNodes" value="10" autocomplete="off">
<button id="createRandomGraphConfirm" class="controlButton">Create Random Graph</button>
</div>
</div>
</div> </div>
<script type="text/javascript" src="script.js"></script> <script type="text/javascript" src="script.js"></script>
</body> </body>
+29
View File
@@ -480,3 +480,32 @@ document.getElementById('maxOutgoingConnections').addEventListener('change', fun
document.getElementById('maxIncomingConnections').addEventListener('change', function() { document.getElementById('maxIncomingConnections').addEventListener('change', function() {
MAX_INCOMING_CONNECTIONS = parseInt(this.value); MAX_INCOMING_CONNECTIONS = parseInt(this.value);
}); });
document.getElementById('createRandomGraph').addEventListener('click', function() {
document.getElementById('randomGraphModal').style.display = 'block';
});
document.getElementById('createRandomGraphConfirm').addEventListener('click', function() {
const nodeCount = parseInt(document.getElementById('randomGraphNodes').value);
network.setOptions({
nodes: {
shape: 'box',
physics: true,
},
});
for (let i = 0; i < nodeCount; i++) {
const nodeId = generateRealisticLabel();
nodes.add({id: nodeId, label: nodeId, x: Math.random() * 100, y: Math.random() * 100});
nodeTable[nodeId] = {'incoming': [], 'outgoing': [], 'packetCache': []};
}
setTimeout(() => {
network.setOptions({
nodes: {
shape: 'box',
physics: false,
}
});
}, 2000);
document.getElementById('randomGraphModal').style.display = 'none';
});
+27
View File
@@ -79,3 +79,30 @@ html, body {
#simpleSettings, #hardwareConstraints, #engineSettings { #simpleSettings, #hardwareConstraints, #engineSettings {
margin-bottom: 10px; margin-bottom: 10px;
} }
#randomGraphModal {
display: none;
position: absolute;
top: 0%;
left: 0%;
transform: translate(0%, 0%);
background-color: rgba(0, 0, 0, 0.5);
padding: 20px;
border: 1px solid #000;
width: 100%;
height: 100%;
}
#randomGraphModalContent {
padding: 20px;
background-color: #fff;
border: 1px solid #000;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
#createRandomGraphConfirm {
margin-top: 10px;
}