MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / initializeAdvancedSettings

Function initializeAdvancedSettings

assets/main.js:355–662  ·  view source on GitHub ↗
({ neuralScene, digitCanvas, onConnectionsSettingsChange } = {})

Source from the content-addressed store, hash-verified

353}
354
355function initializeAdvancedSettings({ neuralScene, digitCanvas, onConnectionsSettingsChange } = {}) {
356 const button = document.getElementById("advancedSettingsButton");
357 const modal = document.getElementById("advancedSettingsModal");
358 const closeButton = document.getElementById("closeAdvancedSettings");
359 if (!button || !modal) return;
360
361 const connectionSlider = document.getElementById("connectionLimitSlider");
362 const connectionValue = document.getElementById("connectionLimitValue");
363 const connectionThresholdSlider = document.getElementById("connectionThresholdSlider");
364 const connectionThresholdValue = document.getElementById("connectionThresholdValue");
365 const connectionThicknessSlider = document.getElementById("connectionThicknessSlider");
366 const connectionThicknessValue = document.getElementById("connectionThicknessValue");
367 const thicknessSlider = document.getElementById("brushThicknessSlider");
368 const thicknessValue = document.getElementById("brushThicknessValue");
369 const strengthSlider = document.getElementById("brushStrengthSlider");
370 const strengthValue = document.getElementById("brushStrengthValue");
371 let refreshConnectionThresholdBounds = null;
372
373 const focusTarget =
374 connectionSlider ||
375 connectionThresholdSlider ||
376 connectionThicknessSlider ||
377 thicknessSlider ||
378 strengthSlider;
379
380 const showModal = () => {
381 modal.classList.add("visible");
382 if (typeof refreshConnectionThresholdBounds === "function") {
383 refreshConnectionThresholdBounds();
384 }
385 window.requestAnimationFrame(() => {
386 if (focusTarget && typeof focusTarget.focus === "function") {
387 try {
388 focusTarget.focus({ preventScroll: true });
389 } catch (_error) {
390 focusTarget.focus();
391 }
392 }
393 });
394 };
395
396 const hideModal = () => {
397 modal.classList.remove("visible");
398 if (typeof button.focus === "function") {
399 try {
400 button.focus({ preventScroll: true });
401 } catch (_error) {
402 button.focus();
403 }
404 }
405 };
406
407 button.addEventListener("click", showModal);
408 closeButton?.addEventListener("click", hideModal);
409 modal.addEventListener("click", (event) => {
410 if (event.target === modal) {
411 hideModal();
412 }

Callers 1

initializeVisualizerFunction · 0.85

Calls 9

hideModalFunction · 0.85
applyConnectionLimitFunction · 0.85
applyConnectionThresholdFunction · 0.85
clampFunction · 0.85
applyConnectionThicknessFunction · 0.85
applyThicknessFunction · 0.85
applyStrengthFunction · 0.85
getBrushSettingsMethod · 0.80

Tested by

no test coverage detected