✨ feat: enhance mindmap functionality and improve user interaction
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -15,42 +15,269 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// Direkten Event-Listener für Knotenauswahl einrichten
|
||||
setupNodeSelectionListener();
|
||||
|
||||
// Neuronales Netzwerk-Hintergrund-Effekt aktivieren
|
||||
setupNeuralNetworkEffect();
|
||||
});
|
||||
|
||||
// Erzeugt subtile Hintergrundeffekte für neuronales Netzwerk
|
||||
function setupNeuralNetworkEffect() {
|
||||
const cyContainer = document.getElementById('cy');
|
||||
if (!cyContainer) return;
|
||||
|
||||
// Dendrite Animation CSS
|
||||
const dendriteStyle = document.createElement('style');
|
||||
dendriteStyle.textContent = `
|
||||
.neuron-pulse {
|
||||
position: absolute;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
opacity: 0;
|
||||
animation: neuronPulse 6s ease-in-out infinite;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
@keyframes neuronPulse {
|
||||
0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
|
||||
50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.2); }
|
||||
}
|
||||
|
||||
.synapse-line {
|
||||
position: absolute;
|
||||
height: 1px;
|
||||
background: linear-gradient(90deg, transparent, rgba(139, 92, 246, 0.3), transparent);
|
||||
pointer-events: none;
|
||||
z-index: 0;
|
||||
opacity: 0;
|
||||
transform-origin: 0% 50%;
|
||||
animation: synapseFlow 8s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes synapseFlow {
|
||||
0%, 100% { opacity: 0; }
|
||||
50% { opacity: 0.5; }
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(dendriteStyle);
|
||||
|
||||
// Zufällige Pulsierende Dendrite-Effekte
|
||||
setInterval(() => {
|
||||
if (Math.random() > 0.7) {
|
||||
const pulse = document.createElement('div');
|
||||
pulse.className = 'neuron-pulse';
|
||||
|
||||
// Zufällige Größe und Position
|
||||
const size = Math.random() * 200 + 100;
|
||||
pulse.style.width = `${size}px`;
|
||||
pulse.style.height = `${size}px`;
|
||||
pulse.style.left = `${Math.random() * 100}%`;
|
||||
pulse.style.top = `${Math.random() * 100}%`;
|
||||
|
||||
// Animation-Eigenschaften variieren
|
||||
pulse.style.animationDuration = `${Math.random() * 4 + 3}s`;
|
||||
pulse.style.animationDelay = `${Math.random() * 2}s`;
|
||||
|
||||
cyContainer.appendChild(pulse);
|
||||
|
||||
// Element nach Animation entfernen
|
||||
setTimeout(() => pulse.remove(), 7000);
|
||||
}
|
||||
|
||||
// Zufällige Synapse-Linien-Effekte
|
||||
if (Math.random() > 0.8) {
|
||||
const synapse = document.createElement('div');
|
||||
synapse.className = 'synapse-line';
|
||||
|
||||
// Zufällige Position und Größe
|
||||
const startX = Math.random() * 100;
|
||||
const startY = Math.random() * 100;
|
||||
const length = Math.random() * 200 + 50;
|
||||
const angle = Math.random() * 360;
|
||||
|
||||
synapse.style.width = `${length}px`;
|
||||
synapse.style.left = `${startX}%`;
|
||||
synapse.style.top = `${startY}%`;
|
||||
synapse.style.transform = `rotate(${angle}deg)`;
|
||||
|
||||
// Animation-Eigenschaften
|
||||
synapse.style.animationDuration = `${Math.random() * 3 + 5}s`;
|
||||
synapse.style.animationDelay = `${Math.random() * 2}s`;
|
||||
|
||||
cyContainer.appendChild(synapse);
|
||||
|
||||
// Element nach Animation entfernen
|
||||
setTimeout(() => synapse.remove(), 9000);
|
||||
}
|
||||
}, 800);
|
||||
}
|
||||
|
||||
// Richtet grundlegende statische Interaktionen ein
|
||||
function setupStaticInteractions() {
|
||||
// Vergrößert die Mindmap auf Vollbildmodus, wenn der entsprechende Button geklickt wird
|
||||
const fullscreenBtn = document.getElementById('fullscreen-btn');
|
||||
if (fullscreenBtn) {
|
||||
fullscreenBtn.addEventListener('click', toggleFullscreen);
|
||||
}
|
||||
|
||||
// Initialisiert die Hover-Effekte für die Seitenleisten-Panels
|
||||
initializePanelEffects();
|
||||
|
||||
// Prevent default Zoom bei CTRL + Mausrad
|
||||
document.addEventListener('wheel', function(e) {
|
||||
if (e.ctrlKey) {
|
||||
e.preventDefault();
|
||||
}
|
||||
}, { passive: false });
|
||||
|
||||
// Initialisiert verbesserten Zoom-Handler direkt nach dem Laden
|
||||
initializeZoomHandler();
|
||||
}
|
||||
|
||||
// Richtet erweiterte Interaktionen mit der geladenen Mindmap ein
|
||||
function setupInteractionEnhancements() {
|
||||
console.log('Mindmap geladen - verbesserte Interaktionen werden eingerichtet');
|
||||
|
||||
// Zugriff auf die Mindmap-Instanz
|
||||
const mindmap = window.mindmapInstance;
|
||||
if (!mindmap) {
|
||||
console.warn('Mindmap-Instanz nicht gefunden!');
|
||||
// Cytoscape-Instanz
|
||||
const cy = window.cy;
|
||||
if (!cy) {
|
||||
console.warn('Cytoscape-Instanz nicht gefunden!');
|
||||
return;
|
||||
}
|
||||
|
||||
// Verbesserte Zoom-Kontrollen
|
||||
setupZoomControls(mindmap);
|
||||
// Hover-Effekte für Knoten
|
||||
cy.on('mouseover', 'node', function(evt) {
|
||||
const node = evt.target;
|
||||
|
||||
// Nur anwenden, wenn der Knoten nicht ausgewählt ist
|
||||
if (!node.selected()) {
|
||||
node.style({
|
||||
'shadow-opacity': 0.8,
|
||||
'shadow-blur': 'mapData(neuronActivity, 0.3, 1, 10, 20)',
|
||||
'background-opacity': 1
|
||||
});
|
||||
}
|
||||
|
||||
// Verbundene Kanten hervorheben
|
||||
node.connectedEdges().style({
|
||||
'line-opacity': 0.7,
|
||||
'width': 'mapData(strength, 0.2, 0.8, 1.5, 2.5)'
|
||||
});
|
||||
});
|
||||
|
||||
cy.on('mouseout', 'node', function(evt) {
|
||||
const node = evt.target;
|
||||
|
||||
// Nur zurücksetzen, wenn nicht ausgewählt
|
||||
if (!node.selected()) {
|
||||
node.removeStyle();
|
||||
}
|
||||
|
||||
// Verbundene Kanten zurücksetzen, wenn nicht mit ausgewähltem Knoten verbunden
|
||||
node.connectedEdges().forEach(edge => {
|
||||
const sourceSelected = edge.source().selected();
|
||||
const targetSelected = edge.target().selected();
|
||||
|
||||
if (!sourceSelected && !targetSelected) {
|
||||
edge.removeStyle();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Verhindere, dass der Browser die Seite scrollt, wenn über der Mindmap gezoomt wird
|
||||
preventScrollWhileZooming();
|
||||
|
||||
// Tastaturkürzel für Mindmap-Interaktionen
|
||||
setupKeyboardShortcuts(mindmap);
|
||||
|
||||
// Verbesserte Touch-Gesten für mobile Geräte
|
||||
setupTouchInteractions(mindmap);
|
||||
setupKeyboardShortcuts(cy);
|
||||
}
|
||||
|
||||
// Initialisiert speziellen Zoom-Handler für sanften Zoom
|
||||
function initializeZoomHandler() {
|
||||
// Auf das Laden der Mindmap warten
|
||||
document.addEventListener('mindmap-loaded', function() {
|
||||
if (!window.cy) return;
|
||||
|
||||
const cy = window.cy;
|
||||
|
||||
// Laufenden AnimationsFrame-Request speichern
|
||||
let zoomAnimationFrame = null;
|
||||
let targetZoom = cy.zoom();
|
||||
let currentZoom = targetZoom;
|
||||
let zoomCenter = { x: 0, y: 0 };
|
||||
let zoomTime = 0;
|
||||
|
||||
// Aktuellen Zoom überwachen und sanft anpassen
|
||||
function updateZoom() {
|
||||
// Sanfter Übergang zum Ziel-Zoom-Level
|
||||
zoomTime += 0.08;
|
||||
|
||||
// Easing-Funktion für flüssigere Bewegung
|
||||
const easedProgress = 1 - Math.pow(1 - Math.min(zoomTime, 1), 3);
|
||||
|
||||
if (currentZoom !== targetZoom) {
|
||||
currentZoom += (targetZoom - currentZoom) * easedProgress;
|
||||
|
||||
// Zoom mit Position anwenden
|
||||
cy.zoom({
|
||||
level: currentZoom,
|
||||
position: zoomCenter
|
||||
});
|
||||
|
||||
// Loop fortsetzen, bis wir sehr nahe am Ziel sind
|
||||
if (Math.abs(currentZoom - targetZoom) > 0.001 && zoomTime < 1) {
|
||||
zoomAnimationFrame = requestAnimationFrame(updateZoom);
|
||||
} else {
|
||||
// Endgültigen Zoom setzen, um sicherzustellen, dass wir genau das Ziel erreichen
|
||||
cy.zoom({
|
||||
level: targetZoom,
|
||||
position: zoomCenter
|
||||
});
|
||||
zoomAnimationFrame = null;
|
||||
}
|
||||
} else {
|
||||
zoomAnimationFrame = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Überschreibe den Standard-mousewheel-Handler von Cytoscape
|
||||
cy.removeAllListeners('mousewheel');
|
||||
cy.on('mousewheel', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const delta = e.originalEvent.deltaY;
|
||||
const mousePosition = e.position || e.cyPosition;
|
||||
|
||||
// Glätten und Limitieren des Zoom-Faktors
|
||||
const factor = delta > 0 ? 0.97 : 1.03;
|
||||
|
||||
// Neues Zoom-Level berechnen mit Begrenzung
|
||||
const maxZoom = cy.maxZoom() || 3;
|
||||
const minZoom = cy.minZoom() || 0.2;
|
||||
targetZoom = Math.min(maxZoom, Math.max(minZoom, cy.zoom() * factor));
|
||||
|
||||
// Position für Zoom setzen
|
||||
zoomCenter = mousePosition;
|
||||
|
||||
// Zeit zurücksetzen
|
||||
zoomTime = 0;
|
||||
|
||||
// Laufende Animation abbrechen und neue starten
|
||||
if (zoomAnimationFrame) {
|
||||
cancelAnimationFrame(zoomAnimationFrame);
|
||||
}
|
||||
|
||||
zoomAnimationFrame = requestAnimationFrame(updateZoom);
|
||||
});
|
||||
|
||||
// Panning auch flüssiger gestalten
|
||||
cy.on('pan', function() {
|
||||
cy.style().selector('node').style({
|
||||
'transition-property': 'none',
|
||||
}).update();
|
||||
});
|
||||
|
||||
cy.on('panend', function() {
|
||||
cy.style().selector('node').style({
|
||||
'transition-property': 'background-color, shadow-color, shadow-opacity, shadow-blur',
|
||||
'transition-duration': '0.3s'
|
||||
}).update();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Verhindert Browser-Scrolling während Zoom in der Mindmap
|
||||
@@ -58,114 +285,33 @@ function preventScrollWhileZooming() {
|
||||
const cyContainer = document.getElementById('cy');
|
||||
if (cyContainer) {
|
||||
cyContainer.addEventListener('wheel', function(e) {
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault(); // Verhindert Browser-Zoom bei Ctrl+Wheel
|
||||
}
|
||||
// Verhindern des Standard-Scrollens während des Zooms
|
||||
e.preventDefault();
|
||||
}, { passive: false });
|
||||
}
|
||||
}
|
||||
|
||||
// Richtet verbesserte Zoom-Kontrollen ein
|
||||
function setupZoomControls(mindmap) {
|
||||
const zoomInBtn = document.getElementById('zoom-in-btn');
|
||||
const zoomOutBtn = document.getElementById('zoom-out-btn');
|
||||
const resetZoomBtn = document.getElementById('reset-btn');
|
||||
|
||||
if (zoomInBtn) {
|
||||
zoomInBtn.addEventListener('click', function() {
|
||||
mindmap.svg.transition()
|
||||
.duration(300)
|
||||
.call(mindmap.svg.zoom().scaleBy, 1.4);
|
||||
});
|
||||
}
|
||||
|
||||
if (zoomOutBtn) {
|
||||
zoomOutBtn.addEventListener('click', function() {
|
||||
mindmap.svg.transition()
|
||||
.duration(300)
|
||||
.call(mindmap.svg.zoom().scaleBy, 0.7);
|
||||
});
|
||||
}
|
||||
|
||||
if (resetZoomBtn) {
|
||||
resetZoomBtn.addEventListener('click', function() {
|
||||
mindmap.svg.transition()
|
||||
.duration(500)
|
||||
.call(mindmap.svg.zoom().transform, d3.zoomIdentity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Vollbildmodus umschalten
|
||||
function toggleFullscreen() {
|
||||
const mindmapContainer = document.querySelector('.mindmap-container');
|
||||
|
||||
if (!mindmapContainer) return;
|
||||
|
||||
if (!document.fullscreenElement) {
|
||||
// Vollbildmodus aktivieren
|
||||
if (mindmapContainer.requestFullscreen) {
|
||||
mindmapContainer.requestFullscreen();
|
||||
} else if (mindmapContainer.mozRequestFullScreen) {
|
||||
mindmapContainer.mozRequestFullScreen();
|
||||
} else if (mindmapContainer.webkitRequestFullscreen) {
|
||||
mindmapContainer.webkitRequestFullscreen();
|
||||
} else if (mindmapContainer.msRequestFullscreen) {
|
||||
mindmapContainer.msRequestFullscreen();
|
||||
}
|
||||
|
||||
// Icon ändern
|
||||
const fullscreenBtn = document.getElementById('fullscreen-btn');
|
||||
if (fullscreenBtn) {
|
||||
const icon = fullscreenBtn.querySelector('i');
|
||||
if (icon) {
|
||||
icon.className = 'fa-solid fa-compress';
|
||||
}
|
||||
fullscreenBtn.setAttribute('title', 'Vollbildmodus beenden');
|
||||
}
|
||||
} else {
|
||||
// Vollbildmodus beenden
|
||||
if (document.exitFullscreen) {
|
||||
document.exitFullscreen();
|
||||
} else if (document.mozCancelFullScreen) {
|
||||
document.mozCancelFullScreen();
|
||||
} else if (document.webkitExitFullscreen) {
|
||||
document.webkitExitFullscreen();
|
||||
} else if (document.msExitFullscreen) {
|
||||
document.msExitFullscreen();
|
||||
}
|
||||
|
||||
// Icon zurücksetzen
|
||||
const fullscreenBtn = document.getElementById('fullscreen-btn');
|
||||
if (fullscreenBtn) {
|
||||
const icon = fullscreenBtn.querySelector('i');
|
||||
if (icon) {
|
||||
icon.className = 'fa-solid fa-expand';
|
||||
}
|
||||
fullscreenBtn.setAttribute('title', 'Vollbildmodus');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Initialisiert Effekte für Seitenleisten-Panels
|
||||
function initializePanelEffects() {
|
||||
// Selektiert alle Panel-Elemente
|
||||
const panels = document.querySelectorAll('[data-sidebar]');
|
||||
const panels = document.querySelectorAll('.sidebar-panel');
|
||||
|
||||
panels.forEach(panel => {
|
||||
// Hover-Effekt für Panels
|
||||
panel.addEventListener('mouseenter', function() {
|
||||
this.classList.add('hover');
|
||||
this.style.transform = 'translateY(-5px)';
|
||||
this.style.boxShadow = '0 10px 25px rgba(0, 0, 0, 0.3), 0 0 15px rgba(139, 92, 246, 0.3)';
|
||||
});
|
||||
|
||||
panel.addEventListener('mouseleave', function() {
|
||||
this.classList.remove('hover');
|
||||
this.style.transform = '';
|
||||
this.style.boxShadow = '';
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Richtet Tastaturkürzel für Mindmap-Interaktionen ein
|
||||
function setupKeyboardShortcuts(mindmap) {
|
||||
function setupKeyboardShortcuts(cy) {
|
||||
document.addEventListener('keydown', function(e) {
|
||||
// Nur fortfahren, wenn keine Texteingabe im Fokus ist
|
||||
if (document.activeElement.tagName === 'INPUT' ||
|
||||
@@ -178,229 +324,249 @@ function setupKeyboardShortcuts(mindmap) {
|
||||
switch(e.key) {
|
||||
case '+':
|
||||
case '=':
|
||||
// Einzoomen
|
||||
// Einzoomen (sanfter)
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
mindmap.svg.transition()
|
||||
.duration(300)
|
||||
.call(mindmap.svg.zoom().scaleBy, 1.2);
|
||||
smoothZoom(cy, 1.15, 400);
|
||||
}
|
||||
break;
|
||||
|
||||
case '-':
|
||||
// Auszoomen
|
||||
// Auszoomen (sanfter)
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
mindmap.svg.transition()
|
||||
.duration(300)
|
||||
.call(mindmap.svg.zoom().scaleBy, 0.8);
|
||||
smoothZoom(cy, 0.85, 400);
|
||||
}
|
||||
break;
|
||||
|
||||
case '0':
|
||||
// Zoom zurücksetzen
|
||||
// Zoom auf Gesamtansicht
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
mindmap.svg.transition()
|
||||
.duration(500)
|
||||
.call(mindmap.svg.zoom().transform, d3.zoomIdentity);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'f':
|
||||
// Vollbildmodus umschalten
|
||||
if (e.ctrlKey || e.metaKey) {
|
||||
e.preventDefault();
|
||||
toggleFullscreen();
|
||||
smoothFit(cy);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'Escape':
|
||||
// Ausgewählten Knoten abwählen
|
||||
if (mindmap.selectedNode) {
|
||||
mindmap.nodeClicked(null, mindmap.selectedNode);
|
||||
}
|
||||
cy.nodes().unselect();
|
||||
resetNodeSelection();
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Richtet Touch-Gesten für mobile Geräte ein
|
||||
function setupTouchInteractions(mindmap) {
|
||||
const cyContainer = document.getElementById('cy');
|
||||
if (!cyContainer) return;
|
||||
// Sanften Zoom mit Animation anwenden
|
||||
function smoothZoom(cy, factor, duration = 400) {
|
||||
const currentZoom = cy.zoom();
|
||||
const targetZoom = currentZoom * factor;
|
||||
|
||||
let touchStartX, touchStartY;
|
||||
let touchStartTime;
|
||||
// Mittelpunkt der Ansicht verwenden
|
||||
const center = {
|
||||
x: cy.width() / 2,
|
||||
y: cy.height() / 2
|
||||
};
|
||||
|
||||
// Touch-Start-Event
|
||||
cyContainer.addEventListener('touchstart', function(e) {
|
||||
if (e.touches.length === 1) {
|
||||
touchStartX = e.touches[0].clientX;
|
||||
touchStartY = e.touches[0].clientY;
|
||||
touchStartTime = Date.now();
|
||||
}
|
||||
});
|
||||
|
||||
// Touch-End-Event für Doppeltipp-Erkennung
|
||||
cyContainer.addEventListener('touchend', function(e) {
|
||||
if (Date.now() - touchStartTime < 300) { // Kurzer Tipp
|
||||
const doubleTapDelay = 300;
|
||||
const now = Date.now();
|
||||
|
||||
if (now - (window.lastTapTime || 0) < doubleTapDelay) {
|
||||
// Doppeltipp erkannt - Zentriere Ansicht
|
||||
mindmap.svg.transition()
|
||||
.duration(500)
|
||||
.call(mindmap.svg.zoom().transform, d3.zoomIdentity);
|
||||
|
||||
e.preventDefault();
|
||||
// Sanftes Zoomen mit Animation
|
||||
cy.animation({
|
||||
zoom: {
|
||||
level: targetZoom,
|
||||
position: center
|
||||
},
|
||||
duration: duration,
|
||||
easing: 'cubic-bezier(0.19, 1, 0.22, 1)'
|
||||
}).play();
|
||||
}
|
||||
|
||||
// Sanftes Anpassen der Ansicht mit Animation
|
||||
function smoothFit(cy, padding = 50) {
|
||||
cy.animation({
|
||||
fit: {
|
||||
eles: cy.elements(),
|
||||
padding: padding
|
||||
},
|
||||
duration: 600,
|
||||
easing: 'cubic-bezier(0.19, 1, 0.22, 1)'
|
||||
}).play();
|
||||
}
|
||||
|
||||
// Richtet den Event-Listener für die Knotenauswahl ein
|
||||
function setupNodeSelectionListener() {
|
||||
document.addEventListener('mindmap-loaded', function() {
|
||||
if (!window.cy) return;
|
||||
|
||||
window.cy.on('tap', 'node', function(evt) {
|
||||
handleNodeSelection(evt.target);
|
||||
});
|
||||
|
||||
window.cy.on('tap', function(evt) {
|
||||
if (evt.target === window.cy) {
|
||||
resetNodeSelection();
|
||||
}
|
||||
|
||||
window.lastTapTime = now;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Richtet einen Event-Listener für die Knotenauswahl ein
|
||||
function setupNodeSelectionListener() {
|
||||
document.addEventListener('mindmap-node-selected', function(event) {
|
||||
const node = event.detail;
|
||||
if (node) {
|
||||
console.log('Knoten ausgewählt:', node);
|
||||
showNodeDescriptionSidebar(node);
|
||||
// Verarbeitet die Knotenauswahl
|
||||
function handleNodeSelection(node) {
|
||||
if (!node) return;
|
||||
|
||||
// Stelle sicher, dass nur dieser Knoten ausgewählt ist
|
||||
window.cy.nodes().unselect();
|
||||
node.select();
|
||||
|
||||
// Speichere ausgewählten Knoten global
|
||||
window.mindmapInstance.selectedNode = node;
|
||||
|
||||
// Zeige Informationen in der Sidebar an
|
||||
showNodeDescriptionSidebar(node);
|
||||
|
||||
// Informationspanel aktualisieren
|
||||
updateNodeInfoPanel(node);
|
||||
|
||||
// Node zentrieren mit Animation
|
||||
window.cy.animation({
|
||||
center: {
|
||||
eles: node
|
||||
},
|
||||
zoom: 1.3,
|
||||
duration: 800,
|
||||
easing: 'cubic-bezier(0.19, 1, 0.22, 1)'
|
||||
}).play();
|
||||
|
||||
// Hervorhebung für den ausgewählten Knoten mit Leuchteffekt
|
||||
node.style({
|
||||
'background-opacity': 1,
|
||||
'shadow-opacity': 1,
|
||||
'shadow-blur': 20,
|
||||
'shadow-color': node.data('color')
|
||||
});
|
||||
|
||||
// Verbindungen hervorheben
|
||||
node.connectedEdges().style({
|
||||
'line-color': '#a78bfa',
|
||||
'line-opacity': 0.7,
|
||||
'width': 2,
|
||||
'line-style': 'solid'
|
||||
});
|
||||
}
|
||||
|
||||
// Setzt die Knotenauswahl zurück
|
||||
function resetNodeSelection() {
|
||||
const nodeInfoPanel = document.getElementById('node-info-panel');
|
||||
if (nodeInfoPanel) {
|
||||
nodeInfoPanel.classList.remove('visible');
|
||||
}
|
||||
|
||||
showDefaultSidebar();
|
||||
|
||||
// Globale Referenz zurücksetzen
|
||||
if (window.mindmapInstance) {
|
||||
window.mindmapInstance.selectedNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Zeigt das Informationspanel für einen Knoten an
|
||||
function updateNodeInfoPanel(node) {
|
||||
const nodeInfoPanel = document.getElementById('node-info-panel');
|
||||
const nodeDescription = document.getElementById('node-description');
|
||||
const connectedNodes = document.getElementById('connected-nodes');
|
||||
const panelTitle = nodeInfoPanel ? nodeInfoPanel.querySelector('.info-panel-title') : null;
|
||||
|
||||
if (!nodeInfoPanel || !nodeDescription || !connectedNodes || !panelTitle) return;
|
||||
|
||||
// Titel und Beschreibung aktualisieren
|
||||
panelTitle.textContent = node.data('name');
|
||||
nodeDescription.textContent = node.data('description') || 'Keine Beschreibung verfügbar.';
|
||||
|
||||
// Verbundene Knoten auflisten
|
||||
connectedNodes.innerHTML = '';
|
||||
|
||||
// Verbundene Knoten ermitteln
|
||||
const connectedNodesList = [];
|
||||
node.connectedEdges().forEach(edge => {
|
||||
let connectedNode;
|
||||
if (edge.source().id() === node.id()) {
|
||||
connectedNode = edge.target();
|
||||
} else {
|
||||
connectedNode = edge.source();
|
||||
}
|
||||
|
||||
if (!connectedNodesList.some(n => n.id() === connectedNode.id())) {
|
||||
connectedNodesList.push(connectedNode);
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('mindmap-node-deselected', function() {
|
||||
console.log('Knoten abgewählt');
|
||||
showDefaultSidebar();
|
||||
});
|
||||
// Verbundene Knoten im Panel anzeigen
|
||||
if (connectedNodesList.length > 0) {
|
||||
connectedNodesList.forEach(connectedNode => {
|
||||
const nodeLink = document.createElement('span');
|
||||
nodeLink.className = 'inline-block px-2 py-1 text-xs rounded-md m-1 cursor-pointer opacity-80 hover:opacity-100 transition-opacity';
|
||||
nodeLink.style.backgroundColor = connectedNode.data('color');
|
||||
nodeLink.textContent = connectedNode.data('name');
|
||||
|
||||
// Beim Klick auf den verbundenen Knoten zu diesem navigieren
|
||||
nodeLink.addEventListener('click', function() {
|
||||
handleNodeSelection(connectedNode);
|
||||
});
|
||||
|
||||
connectedNodes.appendChild(nodeLink);
|
||||
});
|
||||
} else {
|
||||
connectedNodes.innerHTML = '<span class="text-sm italic">Keine verbundenen Knoten</span>';
|
||||
}
|
||||
|
||||
// Panel anzeigen mit Animation
|
||||
nodeInfoPanel.classList.add('visible');
|
||||
}
|
||||
|
||||
// Zeigt die Standard-Seitenleiste an
|
||||
function showDefaultSidebar() {
|
||||
// Finde die Seitenleistenelemente
|
||||
const aboutMindmapPanel = document.querySelector('[data-sidebar="about-mindmap"]');
|
||||
const categoriesPanel = document.querySelector('[data-sidebar="categories"]');
|
||||
const nodeDescriptionPanel = document.querySelector('[data-sidebar="node-description"]');
|
||||
|
||||
if (aboutMindmapPanel && categoriesPanel && nodeDescriptionPanel) {
|
||||
// Beschreibungspanel ausblenden
|
||||
nodeDescriptionPanel.style.display = 'none';
|
||||
|
||||
// Standardpanels einblenden mit Animation
|
||||
aboutMindmapPanel.style.display = 'block';
|
||||
categoriesPanel.style.display = 'block';
|
||||
|
||||
setTimeout(() => {
|
||||
aboutMindmapPanel.style.opacity = '1';
|
||||
aboutMindmapPanel.style.transform = 'translateY(0)';
|
||||
|
||||
categoriesPanel.style.opacity = '1';
|
||||
categoriesPanel.style.transform = 'translateY(0)';
|
||||
}, 50);
|
||||
}
|
||||
// Alle Seitenleisten-Panels anzeigen/ausblenden
|
||||
const allPanels = document.querySelectorAll('[data-sidebar]');
|
||||
allPanels.forEach(panel => {
|
||||
if (panel.getAttribute('data-sidebar') === 'node-description') {
|
||||
panel.classList.add('hidden');
|
||||
} else {
|
||||
panel.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Zeigt die Knotenbeschreibung in der Seitenleiste an
|
||||
function showNodeDescriptionSidebar(node) {
|
||||
// Finde die Seitenleistenelemente
|
||||
const aboutMindmapPanel = document.querySelector('[data-sidebar="about-mindmap"]');
|
||||
const categoriesPanel = document.querySelector('[data-sidebar="categories"]');
|
||||
const nodeDescriptionPanel = document.querySelector('[data-sidebar="node-description"]');
|
||||
// Das Knotenbeschreibungs-Panel finden
|
||||
const nodeDescPanel = document.querySelector('[data-sidebar="node-description"]');
|
||||
|
||||
if (aboutMindmapPanel && categoriesPanel && nodeDescriptionPanel) {
|
||||
// Standardpanels ausblenden
|
||||
aboutMindmapPanel.style.transition = 'all 0.3s ease';
|
||||
categoriesPanel.style.transition = 'all 0.3s ease';
|
||||
if (nodeDescPanel) {
|
||||
// Panel sichtbar machen
|
||||
nodeDescPanel.classList.remove('hidden');
|
||||
|
||||
aboutMindmapPanel.style.opacity = '0';
|
||||
aboutMindmapPanel.style.transform = 'translateY(10px)';
|
||||
// Titel und Beschreibung aktualisieren
|
||||
const nodeTitleElement = nodeDescPanel.querySelector('[data-node-title]');
|
||||
const nodeDescElement = nodeDescPanel.querySelector('[data-node-description]');
|
||||
|
||||
categoriesPanel.style.opacity = '0';
|
||||
categoriesPanel.style.transform = 'translateY(10px)';
|
||||
if (nodeTitleElement) {
|
||||
nodeTitleElement.textContent = node.data('name');
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
aboutMindmapPanel.style.display = 'none';
|
||||
categoriesPanel.style.display = 'none';
|
||||
|
||||
// Beschreibungspanel vorbereiten
|
||||
const titleElement = nodeDescriptionPanel.querySelector('[data-node-title]');
|
||||
const descriptionElement = nodeDescriptionPanel.querySelector('[data-node-description]');
|
||||
|
||||
if (titleElement && descriptionElement) {
|
||||
titleElement.textContent = node.name || 'Unbenannter Knoten';
|
||||
|
||||
// Beschreibung setzen oder Standardbeschreibung generieren
|
||||
let description = node.description;
|
||||
if (!description || description.trim() === '') {
|
||||
description = generateNodeDescription(node);
|
||||
}
|
||||
|
||||
descriptionElement.textContent = description;
|
||||
}
|
||||
|
||||
// Beschreibungspanel einblenden mit Animation
|
||||
nodeDescriptionPanel.style.display = 'block';
|
||||
nodeDescriptionPanel.style.opacity = '0';
|
||||
nodeDescriptionPanel.style.transform = 'translateY(10px)';
|
||||
|
||||
setTimeout(() => {
|
||||
nodeDescriptionPanel.style.transition = 'all 0.4s ease';
|
||||
nodeDescriptionPanel.style.opacity = '1';
|
||||
nodeDescriptionPanel.style.transform = 'translateY(0)';
|
||||
}, 50);
|
||||
}, 300);
|
||||
if (nodeDescElement) {
|
||||
// Beschreibung mit HTML-Formatierung anzeigen
|
||||
nodeDescElement.innerHTML = generateNodeDescription(node);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Generiert automatisch eine Beschreibung für einen Knoten ohne Beschreibung
|
||||
// Generiert eine formatierte HTML-Beschreibung für einen Knoten
|
||||
function generateNodeDescription(node) {
|
||||
const descriptions = {
|
||||
"Wissen": "Der zentrale Knotenpunkt der Mindmap, der alle wissenschaftlichen Disziplinen und Wissensgebiete verbindet. Hier finden sich grundlegende Erkenntnisse und Verbindungen zu spezifischeren Fachgebieten.",
|
||||
|
||||
"Quantenphysik": "Ein Zweig der Physik, der sich mit dem Verhalten und den Interaktionen von Materie und Energie auf der kleinsten Skala beschäftigt. Quantenmechanische Phänomene wie Superposition und Verschränkung bilden die Grundlage für moderne Technologien wie Quantencomputer und -kommunikation.",
|
||||
|
||||
"Neurowissenschaften": "Interdisziplinäres Forschungsgebiet, das die Struktur, Funktion und Entwicklung des Nervensystems und des Gehirns untersucht. Die Erkenntnisse beeinflussen unser Verständnis von Bewusstsein, Kognition, Verhalten und neurologischen Erkrankungen.",
|
||||
|
||||
"Künstliche Intelligenz": "Forschungsgebiet der Informatik, das sich mit der Entwicklung von Systemen befasst, die menschliche Intelligenzformen simulieren können. KI umfasst maschinelles Lernen, neuronale Netze und verschiedene Ansätze zur Problemlösung und Mustererkennung.",
|
||||
|
||||
"Klimaforschung": "Wissenschaftliche Disziplin, die sich mit der Untersuchung des Erdklimas, seinen Veränderungen und den zugrundeliegenden physikalischen Prozessen beschäftigt. Sie liefert wichtige Erkenntnisse zu Klimawandel, Wettermuster und globalen Umweltveränderungen.",
|
||||
|
||||
"Genetik": "Wissenschaft der Gene, Vererbung und der Variation von Organismen. Moderne genetische Forschung umfasst Genomik, Gentechnologie und das Verständnis der molekularen Grundlagen des Lebens sowie ihrer Anwendungen in Medizin und Biotechnologie.",
|
||||
|
||||
"Astrophysik": "Zweig der Astronomie, der die physikalischen Eigenschaften und Prozesse von Himmelskörpern und des Universums untersucht. Sie erforscht Phänomene wie Schwarze Löcher, Galaxien, kosmische Strahlung und die Entstehung und Entwicklung des Universums.",
|
||||
|
||||
"Philosophie": "Disziplin, die sich mit fundamentalen Fragen des Wissens, der Realität und der Existenz auseinandersetzt. Sie umfasst Bereiche wie Metaphysik, Erkenntnistheorie, Ethik und Logik und bildet die Grundlage für kritisches Denken und wissenschaftliche Methodik.",
|
||||
|
||||
"Wissenschaft": "Systematische Erforschung der Natur und der materiellen Welt durch Beobachtung, Experimente und die Formulierung überprüfbarer Theorien. Sie umfasst Naturwissenschaften, Sozialwissenschaften und angewandte Wissenschaften.",
|
||||
|
||||
"Technologie": "Anwendung wissenschaftlicher Erkenntnisse für praktische Zwecke. Sie umfasst die Entwicklung von Werkzeugen, Maschinen, Materialien und Prozessen zur Lösung von Problemen und zur Verbesserung der menschlichen Lebensbedingungen.",
|
||||
|
||||
"Künste": "Ausdruck menschlicher Kreativität und Imagination in verschiedenen Formen wie Malerei, Musik, Literatur, Theater und Film. Die Künste erforschen ästhetische, emotionale und intellektuelle Dimensionen der menschlichen Erfahrung.",
|
||||
|
||||
"Biologie": "Wissenschaft des Lebens und der lebenden Organismen. Sie umfasst Bereiche wie Molekularbiologie, Evolutionsbiologie, Ökologie und beschäftigt sich mit der Struktur, Funktion, Entwicklung und Evolution lebender Systeme.",
|
||||
|
||||
"Mathematik": "Wissenschaft der Muster, Strukturen und Beziehungen. Sie ist die Sprache der Naturwissenschaften und bildet die Grundlage für quantitative Analysen, logisches Denken und Problemlösung in allen wissenschaftlichen Disziplinen.",
|
||||
|
||||
"Psychologie": "Wissenschaftliche Untersuchung des menschlichen Verhaltens und der mentalen Prozesse. Sie erforscht Bereiche wie Kognition, Emotion, Persönlichkeit, soziale Interaktionen und die Behandlung psychischer Störungen.",
|
||||
|
||||
"Ethik": "Teilgebiet der Philosophie, das sich mit moralischen Prinzipien, Werten und der Frage nach richtigem und falschem Handeln beschäftigt. Sie bildet die Grundlage für moralische Entscheidungsfindung in allen Lebensbereichen."
|
||||
};
|
||||
let description = node.data('description') || 'Keine Beschreibung verfügbar.';
|
||||
|
||||
// Verwende vordefinierte Beschreibung, wenn verfügbar
|
||||
if (node.name && descriptions[node.name]) {
|
||||
return descriptions[node.name];
|
||||
}
|
||||
// Einfache HTML-Formatierung (kann erweitert werden)
|
||||
description = description
|
||||
.replace(/\n/g, '<br>')
|
||||
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
||||
.replace(/\*(.*?)\*/g, '<em>$1</em>')
|
||||
.replace(/`(.*?)`/g, '<code>$1</code>');
|
||||
|
||||
// Generische Beschreibung basierend auf dem Knotentyp
|
||||
switch (node.type) {
|
||||
case 'category':
|
||||
return `Dieser Knoten repräsentiert die Kategorie "${node.name}", die verschiedene verwandte Konzepte und Ideen zusammenfasst. Wählen Sie einen der verbundenen Unterthemen, um mehr Details zu erfahren.`;
|
||||
case 'subcategory':
|
||||
return `"${node.name}" ist eine Unterkategorie, die spezifische Aspekte eines größeren Themenbereichs beleuchtet. Die verbundenen Knoten zeigen wichtige Konzepte und Ideen innerhalb dieses Bereichs.`;
|
||||
default:
|
||||
return `Dieser Knoten repräsentiert das Konzept "${node.name}". Erforschen Sie die verbundenen Knoten, um Zusammenhänge und verwandte Ideen zu entdecken.`;
|
||||
}
|
||||
return description;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* Update Mindmap
|
||||
* Dieses Skript fügt die neuen wissenschaftlichen Knoten zur Mindmap hinzu
|
||||
* und stellt sicher, dass sie korrekt angezeigt werden.
|
||||
* Dieses Skript fügt Knoten zur Mindmap hinzu und stellt sicher,
|
||||
* dass sie im neuronalen Netzwerk-Design angezeigt werden.
|
||||
*/
|
||||
|
||||
// Warte bis DOM geladen ist
|
||||
@@ -16,13 +16,13 @@ document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
// Auf das Laden der Mindmap warten
|
||||
document.addEventListener('mindmap-loaded', function() {
|
||||
console.log('Mindmap geladen, füge wissenschaftliche Knoten hinzu...');
|
||||
console.log('Mindmap geladen, wende neuronales Netzwerk-Design an...');
|
||||
enhanceMindmap();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Erweitert die Mindmap mit den neu hinzugefügten wissenschaftlichen Knoten
|
||||
* Erweitert die Mindmap mit dem neuronalen Netzwerk-Design
|
||||
*/
|
||||
function enhanceMindmap() {
|
||||
// Auf die bestehende Cytoscape-Instanz zugreifen
|
||||
@@ -33,25 +33,295 @@ function enhanceMindmap() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Aktualisiere das Layout mit zusätzlichem Platz für die neuen Knoten
|
||||
// Aktualisiere das Layout für eine bessere Verteilung
|
||||
cy.layout({
|
||||
name: 'cose',
|
||||
animate: true,
|
||||
animationDuration: 800,
|
||||
animationDuration: 1800,
|
||||
nodeDimensionsIncludeLabels: true,
|
||||
padding: 100,
|
||||
spacingFactor: 1.8,
|
||||
randomize: false,
|
||||
fit: true
|
||||
fit: true,
|
||||
componentSpacing: 100,
|
||||
nodeRepulsion: 8000,
|
||||
edgeElasticity: 100,
|
||||
nestingFactor: 1.2,
|
||||
gravity: 80
|
||||
}).run();
|
||||
|
||||
console.log('Mindmap wurde erfolgreich aktualisiert!');
|
||||
// Neuronen-Namen mit besserer Lesbarkeit umgestalten
|
||||
cy.style()
|
||||
.selector('node')
|
||||
.style({
|
||||
'text-background-color': 'rgba(10, 14, 25, 0.7)',
|
||||
'text-background-opacity': 0.7,
|
||||
'text-background-padding': '2px',
|
||||
'text-border-opacity': 0.2,
|
||||
'text-border-width': 1,
|
||||
'text-border-color': '#8b5cf6'
|
||||
})
|
||||
.update();
|
||||
|
||||
// Wenn ein Wissen-Knoten existiert, sicherstellen, dass er im Zentrum ist
|
||||
const rootNode = cy.getElementById('1');
|
||||
if (rootNode.length > 0) {
|
||||
cy.center(rootNode);
|
||||
// Sicherstellen, dass alle Knoten Neuronen-Eigenschaften haben
|
||||
cy.nodes().forEach(node => {
|
||||
if (!node.data('neuronSize')) {
|
||||
const neuronSize = Math.floor(Math.random() * 8) + 3;
|
||||
node.data('neuronSize', neuronSize);
|
||||
}
|
||||
|
||||
if (!node.data('neuronActivity')) {
|
||||
const neuronActivity = Math.random() * 0.7 + 0.3;
|
||||
node.data('neuronActivity', neuronActivity);
|
||||
}
|
||||
|
||||
// Zusätzliche Neuronale Eigenschaften
|
||||
node.data('pulseFrequency', Math.random() * 4 + 2); // Pulsfrequenz (2-6 Hz)
|
||||
node.data('refractionPeriod', Math.random() * 300 + 700); // Refraktionszeit (700-1000ms)
|
||||
node.data('threshold', Math.random() * 0.3 + 0.6); // Aktivierungsschwelle (0.6-0.9)
|
||||
});
|
||||
|
||||
// Sicherstellen, dass alle Kanten Synapse-Eigenschaften haben
|
||||
cy.edges().forEach(edge => {
|
||||
if (!edge.data('strength')) {
|
||||
const strength = Math.random() * 0.6 + 0.2;
|
||||
edge.data('strength', strength);
|
||||
}
|
||||
|
||||
// Zusätzliche synaptische Eigenschaften
|
||||
edge.data('conductionVelocity', Math.random() * 0.5 + 0.3); // Leitungsgeschwindigkeit (0.3-0.8)
|
||||
edge.data('latency', Math.random() * 100 + 50); // Signalverzögerung (50-150ms)
|
||||
});
|
||||
|
||||
// Neuronales Netzwerk-Stil anwenden
|
||||
applyNeuralNetworkStyle(cy);
|
||||
|
||||
console.log('Mindmap wurde erfolgreich im neuronalen Netzwerk-Stil aktualisiert');
|
||||
|
||||
// Spezielle Effekte für das neuronale Netzwerk hinzufügen
|
||||
startNeuralActivitySimulation(cy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wendet detaillierte neuronale Netzwerkstile auf die Mindmap an
|
||||
* @param {Object} cy - Cytoscape-Instanz
|
||||
*/
|
||||
function applyNeuralNetworkStyle(cy) {
|
||||
// Wende erweiterte Stile für Neuronen und Synapsen an
|
||||
cy.style()
|
||||
.selector('node')
|
||||
.style({
|
||||
'label': 'data(name)',
|
||||
'text-valign': 'bottom',
|
||||
'text-halign': 'center',
|
||||
'color': '#ffffff',
|
||||
'text-outline-width': 1.5,
|
||||
'text-outline-color': '#0a0e19',
|
||||
'text-outline-opacity': 0.9,
|
||||
'font-size': 10,
|
||||
'text-margin-y': 7,
|
||||
'width': 'mapData(neuronSize, 3, 10, 15, 40)',
|
||||
'height': 'mapData(neuronSize, 3, 10, 15, 40)',
|
||||
'background-color': 'data(color)',
|
||||
'background-opacity': 0.85,
|
||||
'border-width': 0,
|
||||
'shape': 'ellipse',
|
||||
'shadow-blur': 'mapData(neuronActivity, 0.3, 1, 5, 15)',
|
||||
'shadow-color': 'data(color)',
|
||||
'shadow-opacity': 0.6,
|
||||
'shadow-offset-x': 0,
|
||||
'shadow-offset-y': 0
|
||||
})
|
||||
.selector('edge')
|
||||
.style({
|
||||
'width': 'mapData(strength, 0.2, 0.8, 0.7, 2)',
|
||||
'curve-style': 'bezier',
|
||||
'line-color': '#8a8aaa',
|
||||
'line-opacity': 'mapData(strength, 0.2, 0.8, 0.4, 0.7)',
|
||||
'line-style': function(ele) {
|
||||
const strength = ele.data('strength');
|
||||
if (strength <= 0.4) return 'dotted';
|
||||
if (strength <= 0.6) return 'dashed';
|
||||
return 'solid';
|
||||
},
|
||||
'target-arrow-shape': 'none',
|
||||
'source-endpoint': '0% 50%',
|
||||
'target-endpoint': '100% 50%'
|
||||
})
|
||||
.selector('node[isRoot]')
|
||||
.style({
|
||||
'font-size': 12,
|
||||
'font-weight': 'bold',
|
||||
'width': 50,
|
||||
'height': 50,
|
||||
'background-color': '#6366f1',
|
||||
'shadow-blur': 20,
|
||||
'shadow-color': '#6366f1',
|
||||
'shadow-opacity': 0.8,
|
||||
'text-margin-y': 8
|
||||
})
|
||||
.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Simuliert neuronale Aktivität in der Mindmap
|
||||
* @param {Object} cy - Cytoscape-Instanz
|
||||
*/
|
||||
function startNeuralActivitySimulation(cy) {
|
||||
// Neuronen-Zustand für die Simulation
|
||||
const neuronStates = new Map();
|
||||
|
||||
// Initialisieren aller Neuronen-Zustände
|
||||
cy.nodes().forEach(node => {
|
||||
neuronStates.set(node.id(), {
|
||||
potential: Math.random() * 0.3, // Startpotential
|
||||
lastFired: 0, // Zeitpunkt der letzten Aktivierung
|
||||
isRefractory: false, // Refraktärphase
|
||||
refractoryUntil: 0 // Ende der Refraktärphase
|
||||
});
|
||||
});
|
||||
|
||||
// Neuronale Aktivität simulieren
|
||||
function simulateNeuralActivity() {
|
||||
const currentTime = Date.now();
|
||||
const nodes = cy.nodes().toArray();
|
||||
|
||||
// Zufällige Stimulation eines Neurons
|
||||
if (Math.random() > 0.7) {
|
||||
const randomNodeIndex = Math.floor(Math.random() * nodes.length);
|
||||
const randomNode = nodes[randomNodeIndex];
|
||||
|
||||
const state = neuronStates.get(randomNode.id());
|
||||
if (state && !state.isRefractory) {
|
||||
state.potential += 0.5; // Erhöhe das Potential durch externe Stimulation
|
||||
}
|
||||
}
|
||||
|
||||
// Neuronen aktualisieren
|
||||
nodes.forEach(node => {
|
||||
const nodeId = node.id();
|
||||
const state = neuronStates.get(nodeId);
|
||||
const threshold = node.data('threshold') || 0.7;
|
||||
const refractoryPeriod = node.data('refractionPeriod') || 1000;
|
||||
|
||||
// Überprüfen, ob die Refraktärphase beendet ist
|
||||
if (state.isRefractory && currentTime >= state.refractoryUntil) {
|
||||
state.isRefractory = false;
|
||||
state.potential = 0.1; // Ruhepotential nach Refraktärphase
|
||||
}
|
||||
|
||||
// Wenn nicht in Refraktärphase und Potential über Schwelle
|
||||
if (!state.isRefractory && state.potential >= threshold) {
|
||||
// Neuron feuert
|
||||
fireNeuron(node, state, currentTime);
|
||||
} else if (!state.isRefractory) {
|
||||
// Potential langsam verlieren, wenn nicht gefeuert wird
|
||||
state.potential *= 0.95;
|
||||
}
|
||||
});
|
||||
|
||||
// Simulation fortsetzen
|
||||
requestAnimationFrame(simulateNeuralActivity);
|
||||
}
|
||||
|
||||
// Neuron "feuern" lassen
|
||||
function fireNeuron(node, state, currentTime) {
|
||||
// Neuron aktivieren
|
||||
node.animate({
|
||||
style: {
|
||||
'background-opacity': 1,
|
||||
'shadow-opacity': 1,
|
||||
'shadow-blur': 25
|
||||
},
|
||||
duration: 300,
|
||||
easing: 'ease-in-cubic',
|
||||
complete: function() {
|
||||
// Zurück zum normalen Zustand
|
||||
node.animate({
|
||||
style: {
|
||||
'background-opacity': 0.85,
|
||||
'shadow-opacity': 0.6,
|
||||
'shadow-blur': 'mapData(neuronActivity, 0.3, 1, 5, 15)'
|
||||
},
|
||||
duration: 600,
|
||||
easing: 'ease-out-cubic'
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Refraktärphase setzen
|
||||
state.isRefractory = true;
|
||||
state.lastFired = currentTime;
|
||||
state.refractoryPeriod = node.data('refractionPeriod') || 1000;
|
||||
state.refractoryUntil = currentTime + state.refractoryPeriod;
|
||||
state.potential = 0; // Potential zurücksetzen
|
||||
|
||||
// Signal über verbundene Synapsen weiterleiten
|
||||
propagateSignal(node, currentTime);
|
||||
}
|
||||
|
||||
// Signal über Synapsen propagieren
|
||||
function propagateSignal(sourceNode, currentTime) {
|
||||
// Verbundene Kanten auswählen
|
||||
const edges = sourceNode.connectedEdges().filter(edge =>
|
||||
edge.source().id() === sourceNode.id() // Nur ausgehende Kanten
|
||||
);
|
||||
|
||||
// Durch alle Kanten iterieren
|
||||
edges.forEach(edge => {
|
||||
// Signalverzögerung basierend auf synaptischen Eigenschaften
|
||||
const latency = edge.data('latency') || 100;
|
||||
const strength = edge.data('strength') || 0.5;
|
||||
|
||||
// Signal entlang der Kante senden
|
||||
setTimeout(() => {
|
||||
edge.animate({
|
||||
style: {
|
||||
'line-color': '#a78bfa',
|
||||
'line-opacity': 0.9,
|
||||
'width': 2.5
|
||||
},
|
||||
duration: 200,
|
||||
easing: 'ease-in',
|
||||
complete: function() {
|
||||
// Kante zurücksetzen
|
||||
edge.animate({
|
||||
style: {
|
||||
'line-color': '#8a8aaa',
|
||||
'line-opacity': 'mapData(strength, 0.2, 0.8, 0.4, 0.7)',
|
||||
'width': 'mapData(strength, 0.2, 0.8, 0.7, 2)'
|
||||
},
|
||||
duration: 400,
|
||||
easing: 'ease-out'
|
||||
});
|
||||
|
||||
// Zielknoten potenzial erhöhen
|
||||
const targetNode = edge.target();
|
||||
const targetState = neuronStates.get(targetNode.id());
|
||||
|
||||
if (targetState && !targetState.isRefractory) {
|
||||
// Potentialzunahme basierend auf synaptischer Stärke
|
||||
targetState.potential += strength * 0.4;
|
||||
|
||||
// Subtile Anzeige der Potenzialänderung
|
||||
targetNode.animate({
|
||||
style: {
|
||||
'background-opacity': Math.min(1, 0.85 + (strength * 0.2)),
|
||||
'shadow-opacity': Math.min(1, 0.6 + (strength * 0.3)),
|
||||
'shadow-blur': Math.min(25, 10 + (strength * 15))
|
||||
},
|
||||
duration: 300,
|
||||
easing: 'ease-in-out'
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, latency);
|
||||
});
|
||||
}
|
||||
|
||||
// Starte die Simulation
|
||||
simulateNeuralActivity();
|
||||
}
|
||||
|
||||
// Hilfe-Funktion zum Hinzufügen eines Flash-Hinweises
|
||||
|
||||
Reference in New Issue
Block a user