|
48 | 48 | let lastMouseX = lastMouseY = 0;
|
49 | 49 | let mouseX = mouseY = 0;
|
50 | 50 | let selection;
|
| 51 | + |
51 | 52 | // get the vis.js canvas
|
52 | 53 | const graphDiv = document.getElementById('network');
|
53 | 54 | const visDiv = graphDiv.firstElementChild;
|
|
79 | 80 | const hierarchicalOptionsDirection = document.getElementById('hierarchicalOptions_direction');
|
80 | 81 | const hierarchicalOptionsSortMethod = document.getElementById('hierarchicalOptions_sortmethod');
|
81 | 82 |
|
| 83 | + let hierarchicalOptionsDirectionSelectValue = undefined; |
| 84 | + let hierarchicalOptionsSortMethodSelectValue = undefined; |
| 85 | + let showHierarchicalOptionsCheckboxChecked = false; |
| 86 | + showHierarchicalOptionsCheckbox.checked = showHierarchicalOptionsCheckboxChecked; |
| 87 | + showHierarchicalOptions(); |
| 88 | + |
82 | 89 | function mouseUpEventListener(event) {
|
83 | 90 | // Convert the canvas to image data that can be saved
|
84 | 91 | const aspectRatioX = graphCanvas.width / selectionCanvas.width;
|
|
305 | 312 |
|
306 | 313 | function regenerateGraph() {
|
307 | 314 | seed = Math.random();
|
| 315 | + hierarchicalOptionsDirectionSelect.value = 'Random'; |
| 316 | + hierarchicalOptionsDirectionSelectValue = hierarchicalOptionsDirectionSelect.value; |
| 317 | + hierarchicalOptionsSortMethodSelect.value = 'hubsize'; |
| 318 | + hierarchicalOptionsSortMethodSelectValue = hierarchicalOptionsSortMethodSelect.value; |
308 | 319 | removeNodePositions();
|
309 | 320 | setNetworkLayout();
|
310 | 321 | }
|
|
344 | 355 | }
|
345 | 356 |
|
346 | 357 | function showHierarchicalOptions(){
|
| 358 | + showHierarchicalOptionsCheckboxChecked = showHierarchicalOptionsCheckbox.checked; |
347 | 359 | if (showHierarchicalOptionsCheckbox.checked) {
|
348 | 360 | hierarchicalOptionsDirection.style['display'] = 'block';
|
| 361 | + hierarchicalOptionsDirectionSelect.value = hierarchicalOptionsDirectionSelectValue ? hierarchicalOptionsDirectionSelectValue : 'Random'; |
349 | 362 | hierarchicalOptionsSortMethod.style['display'] = 'block';
|
| 363 | + hierarchicalOptionsSortMethodSelect.value = hierarchicalOptionsSortMethodSelectValue ? hierarchicalOptionsSortMethodSelectValue : 'hubsize'; |
350 | 364 | if (hierarchicalOptionsDirectionSelect.value && hierarchicalOptionsDirectionSelect.value === 'Random') {
|
351 | 365 | regenerateGraphButton.style['display'] = 'block';
|
352 | 366 | } else {
|
|
357 | 371 | hierarchicalOptionsSortMethod.style['display'] = 'none';
|
358 | 372 | regenerateGraphButton.style['display'] = 'block';
|
359 | 373 | }
|
| 374 | + postGraphState(); |
360 | 375 | }
|
361 | 376 |
|
362 | 377 | function setNetworkLayout() {
|
|
392 | 407 | function postGraphState() {
|
393 | 408 | const message = JSON.stringify({
|
394 | 409 | networkSeed: seed,
|
395 |
| - graphDirection: showHierarchicalOptionsCheckbox.checked ? hierarchicalOptionsDirectionSelect.value : undefined, |
396 |
| - graphLayout: showHierarchicalOptionsCheckbox.checked ? hierarchicalOptionsSortMethodSelect.value : undefined, |
| 410 | + graphDirection: showHierarchicalOptionsCheckbox.checked ? hierarchicalOptionsDirectionSelect.value : 'Random', |
| 411 | + graphLayout: showHierarchicalOptionsCheckbox.checked ? hierarchicalOptionsSortMethodSelect.value : 'hubsize', |
397 | 412 | showHierarchicalOptions: showHierarchicalOptionsCheckbox.checked,
|
398 | 413 | nodePositions: getNodePositions()
|
399 | 414 | });
|
|
0 commit comments