Compare commits
2 Commits
49e5e19b7c
...
58a5ea00bd
| Author | SHA1 | Date | |
|---|---|---|---|
| 58a5ea00bd | |||
| aeb829e36a |
@@ -1,358 +1,13 @@
|
|||||||
/**
|
/**
|
||||||
* Mindmap-Initialisierer
|
* Mindmap Initialisierung und Event-Handling
|
||||||
* Lädt und initialisiert die Mindmap-Visualisierung
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Warte bis DOM geladen ist
|
// Warte auf die Cytoscape-Instanz
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('mindmap-loaded', function() {
|
||||||
// Prüfe, ob wir auf der Mindmap-Seite sind
|
const cy = window.cy;
|
||||||
const cyContainer = document.getElementById('cy');
|
if (!cy) return;
|
||||||
|
|
||||||
if (!cyContainer) {
|
// Event-Listener für Knoten-Klicks
|
||||||
console.log('Kein Mindmap-Container gefunden, überspringe Initialisierung.');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Initialisiere Mindmap-Visualisierung...');
|
|
||||||
|
|
||||||
// Prüfe, ob Cytoscape.js verfügbar ist
|
|
||||||
if (typeof cytoscape === 'undefined') {
|
|
||||||
loadScript('/static/js/cytoscape.min.js', initMindmap);
|
|
||||||
} else {
|
|
||||||
initMindmap();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lädt ein Script dynamisch
|
|
||||||
* @param {string} src - Quelldatei
|
|
||||||
* @param {Function} callback - Callback nach dem Laden
|
|
||||||
*/
|
|
||||||
function loadScript(src, callback) {
|
|
||||||
const script = document.createElement('script');
|
|
||||||
script.src = src;
|
|
||||||
script.onload = callback;
|
|
||||||
document.head.appendChild(script);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialisiert die Mindmap-Visualisierung
|
|
||||||
*/
|
|
||||||
function initMindmap() {
|
|
||||||
const cyContainer = document.getElementById('cy');
|
|
||||||
|
|
||||||
// Erstelle Cytoscape-Instanz
|
|
||||||
const cy = cytoscape({
|
|
||||||
container: cyContainer,
|
|
||||||
style: getNeuralNetworkStyles(),
|
|
||||||
layout: {
|
|
||||||
name: 'cose',
|
|
||||||
animate: true,
|
|
||||||
animationDuration: 1500,
|
|
||||||
nodeDimensionsIncludeLabels: true,
|
|
||||||
padding: 100,
|
|
||||||
spacingFactor: 1.5,
|
|
||||||
randomize: true,
|
|
||||||
componentSpacing: 100,
|
|
||||||
nodeRepulsion: 8000,
|
|
||||||
edgeElasticity: 100,
|
|
||||||
nestingFactor: 1.2,
|
|
||||||
gravity: 80,
|
|
||||||
idealEdgeLength: 150
|
|
||||||
},
|
|
||||||
wheelSensitivity: 0.1, // Sanfterer Zoom
|
|
||||||
minZoom: 0.3,
|
|
||||||
maxZoom: 2.5,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Daten vom Server laden
|
|
||||||
loadMindmapData(cy);
|
|
||||||
|
|
||||||
// Event-Handler zuweisen
|
|
||||||
setupEventListeners(cy);
|
|
||||||
|
|
||||||
// Globale Referenz für Externe Zugriffe
|
|
||||||
window.cy = cy;
|
|
||||||
window.mindmapInstance = {
|
|
||||||
cy: cy,
|
|
||||||
selectedNode: null,
|
|
||||||
centerNodeInView: function(node) {
|
|
||||||
cy.animate({
|
|
||||||
center: { eles: node },
|
|
||||||
zoom: 1.2,
|
|
||||||
duration: 800,
|
|
||||||
easing: 'ease-in-out-cubic'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lädt die Mindmap-Daten vom Server
|
|
||||||
* @param {Object} cy - Cytoscape-Instanz
|
|
||||||
*/
|
|
||||||
function loadMindmapData(cy) {
|
|
||||||
fetch('/api/mindmap')
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP Fehler: ${response.status}`);
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
if (!data.nodes || data.nodes.length === 0) {
|
|
||||||
console.log('Keine Daten gefunden, versuche Refresh-API...');
|
|
||||||
return fetch('/api/refresh-mindmap')
|
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`HTTP Fehler beim Refresh: ${response.status}`);
|
|
||||||
}
|
|
||||||
return response.json();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
console.log('Mindmap-Daten geladen:', data);
|
|
||||||
|
|
||||||
// Cytoscape-Elemente vorbereiten
|
|
||||||
const elements = [];
|
|
||||||
|
|
||||||
// Prüfen, ob "Wissen"-Knoten existiert
|
|
||||||
let rootNode = data.nodes.find(node => node.name === "Wissen");
|
|
||||||
|
|
||||||
// Wenn nicht, Root-Knoten hinzufügen
|
|
||||||
if (!rootNode) {
|
|
||||||
rootNode = {
|
|
||||||
id: 'root',
|
|
||||||
name: 'Wissen',
|
|
||||||
description: 'Zentrale Wissensbasis',
|
|
||||||
color_code: '#4299E1'
|
|
||||||
};
|
|
||||||
data.nodes.unshift(rootNode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Knoten hinzufügen mit zufälligen Werten für neuronales Netzwerk
|
|
||||||
data.nodes.forEach(node => {
|
|
||||||
// Neuronenzell-Größe und Aktivität
|
|
||||||
const neuronSize = Math.floor(Math.random() * 8) + 3;
|
|
||||||
const neuronActivity = Math.random() * 0.7 + 0.3; // Aktivitätslevel zwischen 0.3 und 1.0
|
|
||||||
|
|
||||||
elements.push({
|
|
||||||
group: 'nodes',
|
|
||||||
data: {
|
|
||||||
id: node.id.toString(),
|
|
||||||
name: node.name,
|
|
||||||
description: node.description || '',
|
|
||||||
color: node.color_code || '#8B5CF6',
|
|
||||||
isRoot: node.name === 'Wissen',
|
|
||||||
neuronSize: neuronSize,
|
|
||||||
neuronActivity: neuronActivity
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Kanten hinzufügen, wenn vorhanden
|
|
||||||
if (data.edges && data.edges.length > 0) {
|
|
||||||
data.edges.forEach(edge => {
|
|
||||||
elements.push({
|
|
||||||
group: 'edges',
|
|
||||||
data: {
|
|
||||||
id: `${edge.source}-${edge.target}`,
|
|
||||||
source: edge.source.toString(),
|
|
||||||
target: edge.target.toString(),
|
|
||||||
strength: Math.random() * 0.6 + 0.2 // Zufällige Verbindungsstärke zwischen 0.2 und 0.8
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Wenn keine Kanten definiert sind, verbinde alle Knoten mit dem Root-Knoten
|
|
||||||
const rootId = rootNode.id.toString();
|
|
||||||
|
|
||||||
data.nodes.forEach(node => {
|
|
||||||
if (node.id.toString() !== rootId) {
|
|
||||||
elements.push({
|
|
||||||
group: 'edges',
|
|
||||||
data: {
|
|
||||||
id: `${rootId}-${node.id}`,
|
|
||||||
source: rootId,
|
|
||||||
target: node.id.toString(),
|
|
||||||
strength: Math.random() * 0.6 + 0.2
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Elemente zu Cytoscape hinzufügen
|
|
||||||
cy.elements().remove();
|
|
||||||
cy.add(elements);
|
|
||||||
|
|
||||||
// Layout anwenden
|
|
||||||
cy.layout({
|
|
||||||
name: 'cose',
|
|
||||||
animate: true,
|
|
||||||
animationDuration: 1800,
|
|
||||||
nodeDimensionsIncludeLabels: true,
|
|
||||||
padding: 100,
|
|
||||||
spacingFactor: 1.8,
|
|
||||||
randomize: false,
|
|
||||||
fit: true,
|
|
||||||
componentSpacing: 100,
|
|
||||||
nodeRepulsion: 8000,
|
|
||||||
edgeElasticity: 100
|
|
||||||
}).run();
|
|
||||||
|
|
||||||
// Neuronale Netzwerk-Effekte hinzufügen
|
|
||||||
setTimeout(() => {
|
|
||||||
addNeuralNetworkEffects(cy);
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// Nach dem Laden Event auslösen
|
|
||||||
document.dispatchEvent(new CustomEvent('mindmap-loaded'));
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Fehler beim Laden der Mindmap-Daten:', error);
|
|
||||||
|
|
||||||
// Fallback mit Standard-Daten
|
|
||||||
const fallbackData = {
|
|
||||||
nodes: [
|
|
||||||
{ id: 1, name: 'Wissen', description: 'Zentrale Wissensbasis', color_code: '#4299E1' },
|
|
||||||
{ id: 2, name: 'Philosophie', description: 'Philosophisches Denken', color_code: '#9F7AEA' },
|
|
||||||
{ id: 3, name: 'Wissenschaft', description: 'Wissenschaftliche Erkenntnisse', color_code: '#48BB78' },
|
|
||||||
{ id: 4, name: 'Technologie', description: 'Technologische Entwicklungen', color_code: '#ED8936' },
|
|
||||||
{ id: 5, name: 'Künste', description: 'Künstlerische Ausdrucksformen', color_code: '#ED64A6' }
|
|
||||||
],
|
|
||||||
edges: [
|
|
||||||
{ source: 1, target: 2 },
|
|
||||||
{ source: 1, target: 3 },
|
|
||||||
{ source: 1, target: 4 },
|
|
||||||
{ source: 1, target: 5 }
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
||||||
const fallbackElements = [];
|
|
||||||
|
|
||||||
// Knoten hinzufügen mit Neuronen-Eigenschaften
|
|
||||||
fallbackData.nodes.forEach(node => {
|
|
||||||
const neuronSize = Math.floor(Math.random() * 8) + 3;
|
|
||||||
const neuronActivity = Math.random() * 0.7 + 0.3;
|
|
||||||
|
|
||||||
fallbackElements.push({
|
|
||||||
group: 'nodes',
|
|
||||||
data: {
|
|
||||||
id: node.id.toString(),
|
|
||||||
name: node.name,
|
|
||||||
description: node.description || '',
|
|
||||||
color: node.color_code || '#8B5CF6',
|
|
||||||
isRoot: node.name === 'Wissen',
|
|
||||||
neuronSize: neuronSize,
|
|
||||||
neuronActivity: neuronActivity
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Kanten hinzufügen
|
|
||||||
fallbackData.edges.forEach(edge => {
|
|
||||||
fallbackElements.push({
|
|
||||||
group: 'edges',
|
|
||||||
data: {
|
|
||||||
id: `${edge.source}-${edge.target}`,
|
|
||||||
source: edge.source.toString(),
|
|
||||||
target: edge.target.toString(),
|
|
||||||
strength: Math.random() * 0.6 + 0.2
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Elemente zu Cytoscape hinzufügen
|
|
||||||
cy.elements().remove();
|
|
||||||
cy.add(fallbackElements);
|
|
||||||
|
|
||||||
// Layout anwenden
|
|
||||||
cy.layout({
|
|
||||||
name: 'cose',
|
|
||||||
animate: true,
|
|
||||||
animationDuration: 1800,
|
|
||||||
nodeDimensionsIncludeLabels: true,
|
|
||||||
fit: true
|
|
||||||
}).run();
|
|
||||||
|
|
||||||
// Neuronale Netzwerk-Effekte hinzufügen
|
|
||||||
setTimeout(() => {
|
|
||||||
addNeuralNetworkEffects(cy);
|
|
||||||
}, 2000);
|
|
||||||
|
|
||||||
// Nach dem Laden Event auslösen
|
|
||||||
document.dispatchEvent(new CustomEvent('mindmap-loaded'));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Neuronales Netzwerk-Effekte hinzufügen
|
|
||||||
function addNeuralNetworkEffects(cy) {
|
|
||||||
cy.nodes().forEach(node => {
|
|
||||||
const originalPos = node.position();
|
|
||||||
const activity = node.data('neuronActivity') || 0.5;
|
|
||||||
|
|
||||||
// Subtile Pulsierende Bewegung für Neuronen
|
|
||||||
setInterval(() => {
|
|
||||||
const randomFactor = Math.random() * 0.5 + 0.5; // Zufälliger Faktor zwischen 0.5 und 1
|
|
||||||
const offset = (Math.random() - 0.5) * activity;
|
|
||||||
const pulseIntensity = 0.7 + (Math.sin(Date.now() / 2000) * 0.3 * activity * randomFactor);
|
|
||||||
|
|
||||||
// Leichtes Pulsieren und Bewegung basierend auf "Neuronenaktivität"
|
|
||||||
node.animate({
|
|
||||||
position: {
|
|
||||||
x: originalPos.x + offset,
|
|
||||||
y: originalPos.y + offset
|
|
||||||
},
|
|
||||||
style: {
|
|
||||||
'background-opacity': Math.max(0.7, pulseIntensity),
|
|
||||||
'shadow-opacity': Math.max(0.5, pulseIntensity * 0.8)
|
|
||||||
},
|
|
||||||
duration: 3000 + (Math.random() * 2000),
|
|
||||||
easing: 'ease-in-out-cubic',
|
|
||||||
complete: function() {
|
|
||||||
node.animate({
|
|
||||||
position: { x: originalPos.x, y: originalPos.y },
|
|
||||||
style: {
|
|
||||||
'background-opacity': 0.9,
|
|
||||||
'shadow-opacity': 0.6
|
|
||||||
},
|
|
||||||
duration: 3000 + (Math.random() * 2000),
|
|
||||||
easing: 'ease-in-out-cubic'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 6000 + Math.random() * 4000); // Leicht zufällige Intervalle für organischeres Aussehen
|
|
||||||
|
|
||||||
// Zusätzliche "synaptische" Effekte für Kanten
|
|
||||||
node.connectedEdges().forEach(edge => {
|
|
||||||
const strength = edge.data('strength') || 0.5;
|
|
||||||
|
|
||||||
// Pulsierende Aktivität entlang der Kanten
|
|
||||||
setInterval(() => {
|
|
||||||
const pulseIntensity = 0.5 + (Math.sin(Date.now() / 1500) * 0.5 * strength);
|
|
||||||
|
|
||||||
edge.animate({
|
|
||||||
style: {
|
|
||||||
'line-opacity': Math.max(0.3, pulseIntensity),
|
|
||||||
'width': 1 + (pulseIntensity * 0.6)
|
|
||||||
},
|
|
||||||
duration: 1200,
|
|
||||||
easing: 'ease-in-out'
|
|
||||||
});
|
|
||||||
}, 3000 + (Math.random() * 2000));
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Richtet Event-Listener für die Mindmap ein
|
|
||||||
* @param {Object} cy - Cytoscape-Instanz
|
|
||||||
*/
|
|
||||||
function setupEventListeners(cy) {
|
|
||||||
// Klick auf Knoten
|
|
||||||
cy.on('tap', 'node', function(evt) {
|
cy.on('tap', 'node', function(evt) {
|
||||||
const node = evt.target;
|
const node = evt.target;
|
||||||
|
|
||||||
@@ -408,241 +63,152 @@ function setupEventListeners(cy) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Smooth Zoom mit Mouse Wheel
|
// Zoom-Controls
|
||||||
cy.on('mousewheel', function(evt) {
|
document.getElementById('zoomIn')?.addEventListener('click', () => {
|
||||||
const delta = evt.originalEvent.deltaY;
|
cy.zoom({
|
||||||
const factor = delta > 0 ? 0.95 : 1.05;
|
level: cy.zoom() * 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
cy.animate({
|
|
||||||
zoom: cy.zoom() * factor,
|
|
||||||
duration: 100
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Aktualisiert das Info-Panel mit Daten des ausgewählten Knotens
|
document.getElementById('zoomOut')?.addEventListener('click', () => {
|
||||||
function updateInfoPanel(node) {
|
cy.zoom({
|
||||||
const nodeInfoPanel = document.getElementById('node-info-panel');
|
level: cy.zoom() / 1.2,
|
||||||
const nodeDescription = document.getElementById('node-description');
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
const connectedNodes = document.getElementById('connected-nodes');
|
});
|
||||||
const panelTitle = nodeInfoPanel.querySelector('.info-panel-title');
|
|
||||||
|
|
||||||
if (!nodeInfoPanel || !nodeDescription || !connectedNodes) return;
|
|
||||||
|
|
||||||
// Titel und Beschreibung aktualisieren
|
|
||||||
panelTitle.textContent = node.data('name');
|
|
||||||
nodeDescription.textContent = node.data('description') || 'Keine Beschreibung verfügbar.';
|
|
||||||
|
|
||||||
// Verbundene Knoten anzeigen
|
|
||||||
connectedNodes.innerHTML = '';
|
|
||||||
|
|
||||||
// Verbundene Knoten sammeln (direktes Neighborhood)
|
|
||||||
const connectedNodesList = [];
|
|
||||||
node.neighborhood('node').forEach(n => {
|
|
||||||
if (!connectedNodesList.includes(n) && n.id() !== node.id()) {
|
|
||||||
connectedNodesList.push(n);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Verbundene Knoten im Panel anzeigen
|
document.getElementById('resetView')?.addEventListener('click', () => {
|
||||||
if (connectedNodesList.length > 0) {
|
cy.fit();
|
||||||
connectedNodesList.forEach(connectedNode => {
|
|
||||||
const nodeLink = document.createElement('span');
|
|
||||||
nodeLink.className = 'inline-block px-2 py-1 text-xs rounded-md m-1 cursor-pointer';
|
|
||||||
nodeLink.style.backgroundColor = connectedNode.data('color');
|
|
||||||
nodeLink.textContent = connectedNode.data('name');
|
|
||||||
|
|
||||||
// Beim Klick auf den verbundenen Knoten zu diesem wechseln
|
|
||||||
nodeLink.addEventListener('click', function() {
|
|
||||||
resetSelection(cy);
|
resetSelection(cy);
|
||||||
|
|
||||||
// Verzögerung vor der neuen Auswahl für besseren visuellen Übergang
|
|
||||||
setTimeout(() => {
|
|
||||||
connectedNode.trigger('tap');
|
|
||||||
}, 50);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
connectedNodes.appendChild(nodeLink);
|
// Legend-Toggle
|
||||||
});
|
document.getElementById('toggleLegend')?.addEventListener('click', () => {
|
||||||
} else {
|
const legend = document.getElementById('categoryLegend');
|
||||||
connectedNodes.innerHTML = '<span class="text-sm italic">Keine verbundenen Knoten</span>';
|
if (legend) {
|
||||||
}
|
isLegendVisible = !isLegendVisible;
|
||||||
|
legend.style.display = isLegendVisible ? 'block' : 'none';
|
||||||
// Panel anzeigen mit Animation
|
|
||||||
nodeInfoPanel.style.transition = 'all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1)';
|
|
||||||
nodeInfoPanel.classList.add('visible');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Aktualisiert die Seitenleiste
|
|
||||||
function updateSidebar(node) {
|
|
||||||
// Alle standard Panels ausblenden
|
|
||||||
document.querySelectorAll('[data-sidebar]').forEach(panel => {
|
|
||||||
if (panel.getAttribute('data-sidebar') === 'node-description') {
|
|
||||||
// Beschreibungs-Panel anzeigen
|
|
||||||
panel.classList.remove('hidden');
|
|
||||||
|
|
||||||
// Titel und Beschreibung aktualisieren
|
|
||||||
const titleElement = panel.querySelector('[data-node-title]');
|
|
||||||
const descriptionElement = panel.querySelector('[data-node-description]');
|
|
||||||
|
|
||||||
if (titleElement) {
|
|
||||||
titleElement.textContent = node.data('name');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (descriptionElement) {
|
|
||||||
descriptionElement.innerHTML = formatDescription(node.data('description') || 'Keine Beschreibung verfügbar.');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Andere Panels ausblenden
|
|
||||||
panel.classList.add('hidden');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
// Formatiert die Beschreibung mit etwas HTML-Markup
|
// Keyboard-Controls
|
||||||
function formatDescription(text) {
|
document.addEventListener('keydown', (e) => {
|
||||||
return text
|
if (e.key === '+' || e.key === '=') {
|
||||||
.replace(/\n/g, '<br>')
|
cy.zoom({
|
||||||
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
|
level: cy.zoom() * 1.2,
|
||||||
.replace(/\*(.*?)\*/g, '<em>$1</em>')
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
.replace(/`(.*?)`/g, '<code>$1</code>');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setzt die Auswahl zurück
|
|
||||||
function resetSelection(cy) {
|
|
||||||
// Alle Stile zurücksetzen
|
|
||||||
cy.nodes().forEach(n => {
|
|
||||||
n.removeStyle();
|
|
||||||
});
|
});
|
||||||
|
} else if (e.key === '-' || e.key === '_') {
|
||||||
cy.edges().forEach(e => {
|
cy.zoom({
|
||||||
e.removeStyle();
|
level: cy.zoom() / 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
});
|
});
|
||||||
|
} else if (e.key === 'Escape') {
|
||||||
// Kein Knoten ausgewählt
|
resetSelection(cy);
|
||||||
window.mindmapInstance.selectedNode = null;
|
|
||||||
|
|
||||||
// Info-Panel ausblenden
|
|
||||||
const nodeInfoPanel = document.getElementById('node-info-panel');
|
|
||||||
if (nodeInfoPanel) {
|
|
||||||
nodeInfoPanel.classList.remove('visible');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Standard-Seitenleisten-Panels anzeigen
|
|
||||||
document.querySelectorAll('[data-sidebar]').forEach(panel => {
|
|
||||||
if (panel.getAttribute('data-sidebar') === 'node-description') {
|
|
||||||
panel.classList.add('hidden');
|
|
||||||
} else {
|
|
||||||
panel.classList.remove('hidden');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert das Info-Panel mit Knoteninformationen
|
||||||
|
* @param {Object} node - Der ausgewählte Knoten
|
||||||
|
*/
|
||||||
|
function updateInfoPanel(node) {
|
||||||
|
const infoPanel = document.getElementById('infoPanel');
|
||||||
|
if (!infoPanel) return;
|
||||||
|
|
||||||
|
const data = node.data();
|
||||||
|
const connectedNodes = node.neighborhood('node');
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<h3>${data.label || data.name}</h3>
|
||||||
|
<p class="category">${data.category || 'Keine Kategorie'}</p>
|
||||||
|
${data.description ? `<p class="description">${data.description}</p>` : ''}
|
||||||
|
<div class="connections">
|
||||||
|
<h4>Verbindungen (${connectedNodes.length})</h4>
|
||||||
|
<ul>
|
||||||
|
`;
|
||||||
|
|
||||||
|
connectedNodes.forEach(connectedNode => {
|
||||||
|
const connectedData = connectedNode.data();
|
||||||
|
html += `
|
||||||
|
<li style="color: ${connectedData.color || '#60a5fa'}">
|
||||||
|
${connectedData.label || connectedData.name}
|
||||||
|
</li>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
|
html += `
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
infoPanel.innerHTML = html;
|
||||||
|
infoPanel.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gibt die Stile für das neuronale Netzwerk-Design zurück
|
* Aktualisiert die Seitenleiste mit Knoteninformationen
|
||||||
* @returns {Array} Stildefinitionen für Cytoscape
|
* @param {Object} node - Der ausgewählte Knoten
|
||||||
*/
|
*/
|
||||||
function getNeuralNetworkStyles() {
|
function updateSidebar(node) {
|
||||||
return [
|
const sidebar = document.getElementById('sidebar');
|
||||||
// Neuronen (Knoten)
|
if (!sidebar) return;
|
||||||
{
|
|
||||||
selector: 'node',
|
const data = node.data();
|
||||||
style: {
|
const connectedNodes = node.neighborhood('node');
|
||||||
'label': 'data(name)',
|
|
||||||
'text-valign': 'bottom',
|
let html = `
|
||||||
'text-halign': 'center',
|
<div class="node-details">
|
||||||
'color': '#ffffff',
|
<h3>${data.label || data.name}</h3>
|
||||||
'text-outline-width': 2,
|
<p class="category">${data.category || 'Keine Kategorie'}</p>
|
||||||
'text-outline-color': '#0a0e19',
|
${data.description ? `<p class="description">${data.description}</p>` : ''}
|
||||||
'text-outline-opacity': 0.9,
|
<div class="connections">
|
||||||
'font-size': 10,
|
<h4>Verbindungen (${connectedNodes.length})</h4>
|
||||||
'text-margin-y': 6,
|
<ul>
|
||||||
'width': 'mapData(neuronSize, 3, 10, 15, 40)',
|
`;
|
||||||
'height': 'mapData(neuronSize, 3, 10, 15, 40)',
|
|
||||||
'background-color': 'data(color)',
|
connectedNodes.forEach(connectedNode => {
|
||||||
'background-opacity': 0.9,
|
const connectedData = connectedNode.data();
|
||||||
'border-width': 0,
|
html += `
|
||||||
'shape': 'ellipse',
|
<li style="color: ${connectedData.color || '#60a5fa'}">
|
||||||
'shadow-blur': 'mapData(neuronActivity, 0.3, 1, 5, 15)',
|
${connectedData.label || connectedData.name}
|
||||||
'shadow-color': 'data(color)',
|
</li>
|
||||||
'shadow-opacity': 0.6,
|
`;
|
||||||
'shadow-offset-x': 0,
|
});
|
||||||
'shadow-offset-y': 0,
|
|
||||||
'text-wrap': 'wrap',
|
html += `
|
||||||
'text-max-width': 100,
|
</ul>
|
||||||
'transition-property': 'background-color, shadow-color, shadow-opacity, shadow-blur',
|
</div>
|
||||||
'transition-duration': '0.3s'
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
sidebar.innerHTML = html;
|
||||||
}
|
}
|
||||||
},
|
|
||||||
// Synapsen (Kanten)
|
/**
|
||||||
{
|
* Setzt die Auswahl zurück
|
||||||
selector: 'edge',
|
* @param {Object} cy - Cytoscape-Instanz
|
||||||
style: {
|
*/
|
||||||
'curve-style': 'bezier',
|
function resetSelection(cy) {
|
||||||
'line-color': '#8a8aaa',
|
window.mindmapInstance.selectedNode = null;
|
||||||
'width': 'mapData(strength, 0.2, 0.8, 0.8, 2)',
|
|
||||||
'line-opacity': 'mapData(strength, 0.2, 0.8, 0.4, 0.7)',
|
// Alle Hervorhebungen zurücksetzen
|
||||||
'target-arrow-shape': 'none', // Keine Pfeilspitzen bei Neuronen
|
cy.nodes().forEach(node => {
|
||||||
'target-arrow-color': '#8a8aaa',
|
node.removeStyle();
|
||||||
'arrow-scale': 0.6,
|
node.connectedEdges().removeStyle();
|
||||||
'transition-property': 'line-color, line-opacity, width',
|
});
|
||||||
'transition-duration': '0.3s'
|
|
||||||
|
// Info-Panel ausblenden
|
||||||
|
const infoPanel = document.getElementById('infoPanel');
|
||||||
|
if (infoPanel) {
|
||||||
|
infoPanel.style.display = 'none';
|
||||||
}
|
}
|
||||||
},
|
|
||||||
// Schwache Verbindungen
|
// Seitenleiste leeren
|
||||||
{
|
const sidebar = document.getElementById('sidebar');
|
||||||
selector: 'edge[strength <= 0.4]',
|
if (sidebar) {
|
||||||
style: {
|
sidebar.innerHTML = '';
|
||||||
'line-style': 'dotted'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Mittlere Verbindungen
|
|
||||||
{
|
|
||||||
selector: 'edge[strength > 0.4][strength <= 0.6]',
|
|
||||||
style: {
|
|
||||||
'line-style': 'dashed'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Starke Verbindungen
|
|
||||||
{
|
|
||||||
selector: 'edge[strength > 0.6]',
|
|
||||||
style: {
|
|
||||||
'line-style': 'solid'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Wurzelknoten (speziell gestaltet)
|
|
||||||
{
|
|
||||||
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
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Hover-Effekt für Knoten
|
|
||||||
{
|
|
||||||
selector: 'node:hover',
|
|
||||||
style: {
|
|
||||||
'shadow-blur': 20,
|
|
||||||
'shadow-opacity': 0.9,
|
|
||||||
'transition-property': 'shadow-opacity, shadow-blur',
|
|
||||||
'transition-duration': '0.2s'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// Hover-Effekt für Kanten
|
|
||||||
{
|
|
||||||
selector: 'edge:hover',
|
|
||||||
style: {
|
|
||||||
'line-color': '#a78bfa',
|
|
||||||
'line-opacity': 0.8,
|
|
||||||
'width': 2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
];
|
|
||||||
}
|
|
||||||
@@ -4,238 +4,216 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// Globale Variablen
|
// Globale Variablen
|
||||||
let cy;
|
|
||||||
let selectedNode = null;
|
let selectedNode = null;
|
||||||
let isLegendVisible = true;
|
let isLegendVisible = true;
|
||||||
|
|
||||||
// Initialisierung der Mindmap
|
// Initialisierung der Mindmap
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('mindmap-loaded', function() {
|
||||||
// Cytoscape-Container initialisieren
|
const cy = window.cy;
|
||||||
cy = cytoscape({
|
if (!cy) return;
|
||||||
container: document.getElementById('cy'),
|
|
||||||
style: [
|
|
||||||
{
|
|
||||||
selector: 'node',
|
|
||||||
style: {
|
|
||||||
'background-color': '#60a5fa',
|
|
||||||
'label': 'data(label)',
|
|
||||||
'text-valign': 'center',
|
|
||||||
'text-halign': 'center',
|
|
||||||
'text-wrap': 'wrap',
|
|
||||||
'text-max-width': '100px',
|
|
||||||
'font-size': '12px',
|
|
||||||
'color': '#fff',
|
|
||||||
'text-outline-color': '#000',
|
|
||||||
'text-outline-width': '2px',
|
|
||||||
'width': '40px',
|
|
||||||
'height': '40px',
|
|
||||||
'border-width': '2px',
|
|
||||||
'border-color': '#fff',
|
|
||||||
'border-opacity': '0.5',
|
|
||||||
'padding': '10px',
|
|
||||||
'text-events': 'yes'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
selector: 'edge',
|
|
||||||
style: {
|
|
||||||
'width': '2px',
|
|
||||||
'line-color': 'rgba(255, 255, 255, 0.3)',
|
|
||||||
'target-arrow-color': 'rgba(255, 255, 255, 0.3)',
|
|
||||||
'target-arrow-shape': 'triangle',
|
|
||||||
'curve-style': 'bezier',
|
|
||||||
'label': 'data(label)',
|
|
||||||
'font-size': '10px',
|
|
||||||
'color': '#fff',
|
|
||||||
'text-outline-color': '#000',
|
|
||||||
'text-outline-width': '2px',
|
|
||||||
'text-rotation': 'autorotate'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
selector: ':selected',
|
|
||||||
style: {
|
|
||||||
'background-color': '#8b5cf6',
|
|
||||||
'line-color': '#8b5cf6',
|
|
||||||
'target-arrow-color': '#8b5cf6',
|
|
||||||
'source-arrow-color': '#8b5cf6',
|
|
||||||
'text-outline-color': '#000',
|
|
||||||
'text-outline-width': '2px',
|
|
||||||
'border-width': '3px',
|
|
||||||
'border-color': '#fff',
|
|
||||||
'border-opacity': '1'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
selector: '.highlighted',
|
|
||||||
style: {
|
|
||||||
'background-color': '#10b981',
|
|
||||||
'line-color': '#10b981',
|
|
||||||
'target-arrow-color': '#10b981',
|
|
||||||
'source-arrow-color': '#10b981',
|
|
||||||
'transition-property': 'background-color, line-color, target-arrow-color',
|
|
||||||
'transition-duration': '0.3s'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
name: 'cose',
|
|
||||||
idealEdgeLength: 100,
|
|
||||||
nodeOverlap: 20,
|
|
||||||
refresh: 20,
|
|
||||||
fit: true,
|
|
||||||
padding: 30,
|
|
||||||
randomize: false,
|
|
||||||
componentSpacing: 100,
|
|
||||||
nodeRepulsion: 400000,
|
|
||||||
edgeElasticity: 100,
|
|
||||||
nestingFactor: 5,
|
|
||||||
gravity: 80,
|
|
||||||
numIter: 1000,
|
|
||||||
initialTemp: 200,
|
|
||||||
coolingFactor: 0.95,
|
|
||||||
minTemp: 1.0
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Event-Listener für Knoten
|
// Event-Listener für Knoten-Klicks
|
||||||
cy.on('tap', 'node', function(evt) {
|
cy.on('tap', 'node', function(evt) {
|
||||||
const node = evt.target;
|
const node = evt.target;
|
||||||
updateNodeInfo(node);
|
|
||||||
highlightConnectedNodes(node);
|
// Alle vorherigen Hervorhebungen zurücksetzen
|
||||||
|
cy.nodes().forEach(n => {
|
||||||
|
n.removeStyle();
|
||||||
|
n.connectedEdges().removeStyle();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Event-Listener für Hintergrund-Klick
|
// Speichere ausgewählten Knoten
|
||||||
cy.on('tap', function(evt) {
|
selectedNode = node;
|
||||||
if (evt.target === cy) {
|
|
||||||
resetHighlighting();
|
// Aktiviere leuchtenden Effekt statt Umkreisung
|
||||||
hideNodeInfo();
|
node.style({
|
||||||
}
|
'background-opacity': 1,
|
||||||
|
'background-color': node.data('color'),
|
||||||
|
'shadow-color': node.data('color'),
|
||||||
|
'shadow-opacity': 1,
|
||||||
|
'shadow-blur': 15,
|
||||||
|
'shadow-offset-x': 0,
|
||||||
|
'shadow-offset-y': 0
|
||||||
});
|
});
|
||||||
|
|
||||||
// Zoom-Kontrollen
|
// Verbundene Kanten und Knoten hervorheben
|
||||||
document.getElementById('zoom-in').addEventListener('click', function() {
|
const connectedEdges = node.connectedEdges();
|
||||||
cy.zoom({
|
const connectedNodes = node.neighborhood('node');
|
||||||
level: cy.zoom() * 1.2,
|
|
||||||
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
connectedEdges.style({
|
||||||
});
|
'line-color': '#a78bfa',
|
||||||
|
'target-arrow-color': '#a78bfa',
|
||||||
|
'source-arrow-color': '#a78bfa',
|
||||||
|
'line-opacity': 0.8,
|
||||||
|
'width': 2
|
||||||
});
|
});
|
||||||
|
|
||||||
document.getElementById('zoom-out').addEventListener('click', function() {
|
connectedNodes.style({
|
||||||
cy.zoom({
|
'shadow-opacity': 0.7,
|
||||||
level: cy.zoom() / 1.2,
|
'shadow-blur': 10,
|
||||||
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
'shadow-color': '#a78bfa'
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
document.getElementById('reset-view').addEventListener('click', function() {
|
|
||||||
cy.fit();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Legende ein-/ausblenden
|
|
||||||
document.getElementById('toggle-legend').addEventListener('click', function() {
|
|
||||||
const legend = document.querySelector('.category-legend');
|
|
||||||
isLegendVisible = !isLegendVisible;
|
|
||||||
legend.style.display = isLegendVisible ? 'flex' : 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Tastatursteuerung
|
|
||||||
document.addEventListener('keydown', function(evt) {
|
|
||||||
switch(evt.key) {
|
|
||||||
case '+':
|
|
||||||
cy.zoom({
|
|
||||||
level: cy.zoom() * 1.2,
|
|
||||||
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case '-':
|
|
||||||
cy.zoom({
|
|
||||||
level: cy.zoom() / 1.2,
|
|
||||||
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case 'Escape':
|
|
||||||
resetHighlighting();
|
|
||||||
hideNodeInfo();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Knoteninformationen aktualisieren
|
|
||||||
function updateNodeInfo(node) {
|
|
||||||
const infoPanel = document.getElementById('node-info');
|
|
||||||
const infoContent = infoPanel.querySelector('.info-content');
|
|
||||||
|
|
||||||
// Knotendaten abrufen
|
|
||||||
const nodeData = node.data();
|
|
||||||
|
|
||||||
// Info-Panel aktualisieren
|
// Info-Panel aktualisieren
|
||||||
infoContent.innerHTML = `
|
updateInfoPanel(node);
|
||||||
<h4 class="text-lg font-semibold mb-2">${nodeData.label}</h4>
|
|
||||||
<p class="mb-3">${nodeData.description || 'Keine Beschreibung verfügbar.'}</p>
|
// Seitenleiste aktualisieren
|
||||||
<div class="mt-4">
|
updateSidebar(node);
|
||||||
<h5 class="text-sm font-semibold mb-2">Verknüpfte Konzepte:</h5>
|
});
|
||||||
<ul class="space-y-1">
|
|
||||||
${getConnectedNodesList(node)}
|
// Klick auf Hintergrund - Auswahl zurücksetzen
|
||||||
|
cy.on('tap', function(evt) {
|
||||||
|
if (evt.target === cy) {
|
||||||
|
resetSelection(cy);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Zoom-Controls
|
||||||
|
document.getElementById('zoomIn')?.addEventListener('click', () => {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() * 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('zoomOut')?.addEventListener('click', () => {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() / 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('resetView')?.addEventListener('click', () => {
|
||||||
|
cy.fit();
|
||||||
|
resetSelection(cy);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Legend-Toggle
|
||||||
|
document.getElementById('toggleLegend')?.addEventListener('click', () => {
|
||||||
|
const legend = document.getElementById('categoryLegend');
|
||||||
|
if (legend) {
|
||||||
|
isLegendVisible = !isLegendVisible;
|
||||||
|
legend.style.display = isLegendVisible ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Keyboard-Controls
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === '+' || e.key === '=') {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() * 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
} else if (e.key === '-' || e.key === '_') {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() / 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
} else if (e.key === 'Escape') {
|
||||||
|
resetSelection(cy);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Aktualisiert das Info-Panel mit Knoteninformationen
|
||||||
|
* @param {Object} node - Der ausgewählte Knoten
|
||||||
|
*/
|
||||||
|
function updateInfoPanel(node) {
|
||||||
|
const infoPanel = document.getElementById('infoPanel');
|
||||||
|
if (!infoPanel) return;
|
||||||
|
|
||||||
|
const data = node.data();
|
||||||
|
const connectedNodes = node.neighborhood('node');
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<h3>${data.label || data.name}</h3>
|
||||||
|
<p class="category">${data.category || 'Keine Kategorie'}</p>
|
||||||
|
${data.description ? `<p class="description">${data.description}</p>` : ''}
|
||||||
|
<div class="connections">
|
||||||
|
<h4>Verbindungen (${connectedNodes.length})</h4>
|
||||||
|
<ul>
|
||||||
|
`;
|
||||||
|
|
||||||
|
connectedNodes.forEach(connectedNode => {
|
||||||
|
const connectedData = connectedNode.data();
|
||||||
|
html += `
|
||||||
|
<li style="color: ${connectedData.color || '#60a5fa'}">
|
||||||
|
${connectedData.label || connectedData.name}
|
||||||
|
</li>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
|
html += `
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Panel anzeigen
|
infoPanel.innerHTML = html;
|
||||||
infoPanel.classList.add('visible');
|
infoPanel.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verbundene Knoten hervorheben
|
/**
|
||||||
function highlightConnectedNodes(node) {
|
* Aktualisiert die Seitenleiste mit Knoteninformationen
|
||||||
// Vorherige Hervorhebungen zurücksetzen
|
* @param {Object} node - Der ausgewählte Knoten
|
||||||
resetHighlighting();
|
*/
|
||||||
|
function updateSidebar(node) {
|
||||||
|
const sidebar = document.getElementById('sidebar');
|
||||||
|
if (!sidebar) return;
|
||||||
|
|
||||||
// Ausgewählten Knoten hervorheben
|
const data = node.data();
|
||||||
node.addClass('highlighted');
|
|
||||||
|
|
||||||
// Verbundene Knoten und Kanten hervorheben
|
|
||||||
const connectedElements = node.neighborhood();
|
|
||||||
connectedElements.addClass('highlighted');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Hervorhebungen zurücksetzen
|
|
||||||
function resetHighlighting() {
|
|
||||||
cy.elements().removeClass('highlighted');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info-Panel ausblenden
|
|
||||||
function hideNodeInfo() {
|
|
||||||
const infoPanel = document.getElementById('node-info');
|
|
||||||
infoPanel.classList.remove('visible');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Liste der verbundenen Knoten generieren
|
|
||||||
function getConnectedNodesList(node) {
|
|
||||||
const connectedNodes = node.neighborhood('node');
|
const connectedNodes = node.neighborhood('node');
|
||||||
if (connectedNodes.length === 0) {
|
|
||||||
return '<li class="text-gray-400">Keine direkten Verbindungen</li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
return connectedNodes.map(connectedNode => {
|
let html = `
|
||||||
const data = connectedNode.data();
|
<div class="node-details">
|
||||||
return `
|
<h3>${data.label || data.name}</h3>
|
||||||
<li class="flex items-center space-x-2">
|
<p class="category">${data.category || 'Keine Kategorie'}</p>
|
||||||
<span class="w-2 h-2 rounded-full" style="background-color: ${getNodeColor(data.category)}"></span>
|
${data.description ? `<p class="description">${data.description}</p>` : ''}
|
||||||
<span>${data.label}</span>
|
<div class="connections">
|
||||||
|
<h4>Verbindungen (${connectedNodes.length})</h4>
|
||||||
|
<ul>
|
||||||
|
`;
|
||||||
|
|
||||||
|
connectedNodes.forEach(connectedNode => {
|
||||||
|
const connectedData = connectedNode.data();
|
||||||
|
html += `
|
||||||
|
<li style="color: ${connectedData.color || '#60a5fa'}">
|
||||||
|
${connectedData.label || connectedData.name}
|
||||||
</li>
|
</li>
|
||||||
`;
|
`;
|
||||||
}).join('');
|
});
|
||||||
|
|
||||||
|
html += `
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
sidebar.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Farbe basierend auf Kategorie
|
/**
|
||||||
function getNodeColor(category) {
|
* Setzt die Auswahl zurück
|
||||||
const colors = {
|
* @param {Object} cy - Cytoscape-Instanz
|
||||||
'Philosophie': '#60a5fa',
|
*/
|
||||||
'Wissenschaft': '#8b5cf6',
|
function resetSelection(cy) {
|
||||||
'Technologie': '#10b981',
|
selectedNode = null;
|
||||||
'Künste': '#f59e0b',
|
|
||||||
'Psychologie': '#ef4444'
|
// Alle Hervorhebungen zurücksetzen
|
||||||
};
|
cy.nodes().forEach(node => {
|
||||||
return colors[category] || '#60a5fa';
|
node.removeStyle();
|
||||||
|
node.connectedEdges().removeStyle();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Info-Panel ausblenden
|
||||||
|
const infoPanel = document.getElementById('infoPanel');
|
||||||
|
if (infoPanel) {
|
||||||
|
infoPanel.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seitenleiste leeren
|
||||||
|
const sidebar = document.getElementById('sidebar');
|
||||||
|
if (sidebar) {
|
||||||
|
sidebar.innerHTML = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,71 +1,161 @@
|
|||||||
/**
|
/**
|
||||||
* Mindmap.js - Interaktive Mind-Map Implementierung
|
* Mindmap.js - Interaktive Mind-Map Implementierung
|
||||||
* - Cytoscape.js für Graph-Rendering
|
* - Event-Listener und Interaktionslogik
|
||||||
* - Fetch API für REST-Zugriffe
|
* - Fetch API für REST-Zugriffe
|
||||||
* - Socket.IO für Echtzeit-Synchronisation
|
* - Socket.IO für Echtzeit-Synchronisation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
/* 1. Initialisierung und Grundkonfiguration */
|
/* 1. Event-Listener und Interaktionslogik */
|
||||||
const cy = cytoscape({
|
|
||||||
container: document.getElementById('cy'),
|
// Warte auf die Cytoscape-Instanz
|
||||||
style: [
|
document.addEventListener('mindmap-loaded', function() {
|
||||||
{
|
const cy = window.cy;
|
||||||
selector: 'node',
|
if (!cy) return;
|
||||||
style: {
|
|
||||||
'label': 'data(name)',
|
// Tooltip-Funktionalität
|
||||||
'text-valign': 'center',
|
cy.nodes().unbind('mouseover').bind('mouseover', (event) => {
|
||||||
'color': '#fff',
|
const node = event.target;
|
||||||
'background-color': 'data(color)',
|
const description = node.data('description');
|
||||||
'width': 45,
|
|
||||||
'height': 45,
|
if (description) {
|
||||||
'font-size': 11,
|
const tooltip = document.getElementById('node-tooltip') ||
|
||||||
'text-outline-width': 1,
|
document.createElement('div');
|
||||||
'text-outline-color': '#000',
|
|
||||||
'text-outline-opacity': 0.5,
|
if (!tooltip.id) {
|
||||||
'text-wrap': 'wrap',
|
tooltip.id = 'node-tooltip';
|
||||||
'text-max-width': 80
|
tooltip.style.position = 'absolute';
|
||||||
|
tooltip.style.backgroundColor = '#333';
|
||||||
|
tooltip.style.color = '#fff';
|
||||||
|
tooltip.style.padding = '8px';
|
||||||
|
tooltip.style.borderRadius = '4px';
|
||||||
|
tooltip.style.maxWidth = '250px';
|
||||||
|
tooltip.style.zIndex = 10;
|
||||||
|
tooltip.style.pointerEvents = 'none';
|
||||||
|
tooltip.style.transition = 'opacity 0.2s';
|
||||||
|
tooltip.style.boxShadow = '0 2px 10px rgba(0,0,0,0.3)';
|
||||||
|
document.body.appendChild(tooltip);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
{
|
const renderedPosition = node.renderedPosition();
|
||||||
selector: 'node[icon]',
|
const containerRect = cy.container().getBoundingClientRect();
|
||||||
style: {
|
|
||||||
'background-image': function(ele) {
|
tooltip.innerHTML = description;
|
||||||
return `static/img/icons/${ele.data('icon')}.svg`;
|
tooltip.style.left = (containerRect.left + renderedPosition.x + 25) + 'px';
|
||||||
},
|
tooltip.style.top = (containerRect.top + renderedPosition.y - 15) + 'px';
|
||||||
'background-width': '60%',
|
tooltip.style.opacity = '1';
|
||||||
'background-height': '60%',
|
|
||||||
'background-position-x': '50%',
|
|
||||||
'background-position-y': '40%',
|
|
||||||
'text-margin-y': 10
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
selector: 'edge',
|
|
||||||
style: {
|
|
||||||
'width': 2,
|
|
||||||
'line-color': '#888',
|
|
||||||
'target-arrow-shape': 'triangle',
|
|
||||||
'curve-style': 'bezier',
|
|
||||||
'target-arrow-color': '#888'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
selector: ':selected',
|
|
||||||
style: {
|
|
||||||
'border-width': 3,
|
|
||||||
'border-color': '#f8f32b'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
],
|
|
||||||
layout: {
|
|
||||||
name: 'breadthfirst',
|
|
||||||
directed: true,
|
|
||||||
padding: 30,
|
|
||||||
spacingFactor: 1.2
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Mouseout-Event für Tooltip
|
||||||
|
cy.nodes().unbind('mouseout').bind('mouseout', () => {
|
||||||
|
const tooltip = document.getElementById('node-tooltip');
|
||||||
|
if (tooltip) {
|
||||||
|
tooltip.style.opacity = '0';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Kontextmenü
|
||||||
|
setupContextMenu(cy);
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Richtet das Kontextmenü ein
|
||||||
|
* @param {Object} cy - Cytoscape-Instanz
|
||||||
|
*/
|
||||||
|
function setupContextMenu(cy) {
|
||||||
|
cy.on('cxttap', 'node', function(e) {
|
||||||
|
const node = e.target;
|
||||||
|
const nodeData = node.data();
|
||||||
|
|
||||||
|
// Position des Kontextmenüs berechnen
|
||||||
|
const renderedPosition = node.renderedPosition();
|
||||||
|
const containerRect = cy.container().getBoundingClientRect();
|
||||||
|
const menuX = containerRect.left + renderedPosition.x;
|
||||||
|
const menuY = containerRect.top + renderedPosition.y;
|
||||||
|
|
||||||
|
// Kontextmenü erstellen oder aktualisieren
|
||||||
|
let contextMenu = document.getElementById('context-menu');
|
||||||
|
if (!contextMenu) {
|
||||||
|
contextMenu = document.createElement('div');
|
||||||
|
contextMenu.id = 'context-menu';
|
||||||
|
contextMenu.style.position = 'absolute';
|
||||||
|
contextMenu.style.backgroundColor = '#fff';
|
||||||
|
contextMenu.style.border = '1px solid #ccc';
|
||||||
|
contextMenu.style.borderRadius = '4px';
|
||||||
|
contextMenu.style.padding = '5px 0';
|
||||||
|
contextMenu.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
|
||||||
|
contextMenu.style.zIndex = 1000;
|
||||||
|
document.body.appendChild(contextMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Menüinhalte
|
||||||
|
contextMenu.innerHTML = `
|
||||||
|
<div class="menu-item" data-action="edit">Knoten bearbeiten</div>
|
||||||
|
<div class="menu-item" data-action="connect">Verbindung erstellen</div>
|
||||||
|
<div class="menu-item" data-action="delete">Knoten löschen</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
// Styling für Menüpunkte
|
||||||
|
const menuItems = contextMenu.querySelectorAll('.menu-item');
|
||||||
|
menuItems.forEach(item => {
|
||||||
|
item.style.padding = '8px 16px';
|
||||||
|
item.style.cursor = 'pointer';
|
||||||
|
item.style.transition = 'background-color 0.2s';
|
||||||
|
|
||||||
|
item.addEventListener('mouseover', () => {
|
||||||
|
item.style.backgroundColor = '#f0f0f0';
|
||||||
|
});
|
||||||
|
|
||||||
|
item.addEventListener('mouseout', () => {
|
||||||
|
item.style.backgroundColor = '';
|
||||||
|
});
|
||||||
|
|
||||||
|
item.addEventListener('click', () => {
|
||||||
|
const action = item.dataset.action;
|
||||||
|
handleContextMenuAction(action, node);
|
||||||
|
contextMenu.style.display = 'none';
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// Menü positionieren
|
||||||
|
contextMenu.style.left = menuX + 'px';
|
||||||
|
contextMenu.style.top = menuY + 'px';
|
||||||
|
contextMenu.style.display = 'block';
|
||||||
|
|
||||||
|
// Klick außerhalb schließt Menü
|
||||||
|
document.addEventListener('click', function closeMenu(e) {
|
||||||
|
if (!contextMenu.contains(e.target)) {
|
||||||
|
contextMenu.style.display = 'none';
|
||||||
|
document.removeEventListener('click', closeMenu);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Behandelt Aktionen aus dem Kontextmenü
|
||||||
|
* @param {string} action - Die ausgewählte Aktion
|
||||||
|
* @param {Object} node - Der betroffene Knoten
|
||||||
|
*/
|
||||||
|
function handleContextMenuAction(action, node) {
|
||||||
|
switch (action) {
|
||||||
|
case 'edit':
|
||||||
|
// Implementiere Bearbeitungslogik
|
||||||
|
console.log('Bearbeite Knoten:', node.id());
|
||||||
|
break;
|
||||||
|
case 'connect':
|
||||||
|
// Implementiere Verbindungslogik
|
||||||
|
console.log('Erstelle Verbindung für:', node.id());
|
||||||
|
break;
|
||||||
|
case 'delete':
|
||||||
|
// Implementiere Löschlogik
|
||||||
|
console.log('Lösche Knoten:', node.id());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* 2. Hilfs-Funktionen für API-Zugriffe */
|
/* 2. Hilfs-Funktionen für API-Zugriffe */
|
||||||
const get = async endpoint => {
|
const get = async endpoint => {
|
||||||
try {
|
try {
|
||||||
@@ -226,48 +316,6 @@
|
|||||||
spacingFactor: 1.2
|
spacingFactor: 1.2
|
||||||
}).run();
|
}).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tooltip-Funktionalität
|
|
||||||
cy.nodes().unbind('mouseover').bind('mouseover', (event) => {
|
|
||||||
const node = event.target;
|
|
||||||
const description = node.data('description');
|
|
||||||
|
|
||||||
if (description) {
|
|
||||||
const tooltip = document.getElementById('node-tooltip') ||
|
|
||||||
document.createElement('div');
|
|
||||||
|
|
||||||
if (!tooltip.id) {
|
|
||||||
tooltip.id = 'node-tooltip';
|
|
||||||
tooltip.style.position = 'absolute';
|
|
||||||
tooltip.style.backgroundColor = '#333';
|
|
||||||
tooltip.style.color = '#fff';
|
|
||||||
tooltip.style.padding = '8px';
|
|
||||||
tooltip.style.borderRadius = '4px';
|
|
||||||
tooltip.style.maxWidth = '250px';
|
|
||||||
tooltip.style.zIndex = 10;
|
|
||||||
tooltip.style.pointerEvents = 'none';
|
|
||||||
tooltip.style.transition = 'opacity 0.2s';
|
|
||||||
tooltip.style.boxShadow = '0 2px 10px rgba(0,0,0,0.3)';
|
|
||||||
document.body.appendChild(tooltip);
|
|
||||||
}
|
|
||||||
|
|
||||||
const renderedPosition = node.renderedPosition();
|
|
||||||
const containerRect = cy.container().getBoundingClientRect();
|
|
||||||
|
|
||||||
tooltip.innerHTML = description;
|
|
||||||
tooltip.style.left = (containerRect.left + renderedPosition.x + 25) + 'px';
|
|
||||||
tooltip.style.top = (containerRect.top + renderedPosition.y - 15) + 'px';
|
|
||||||
tooltip.style.opacity = '1';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
cy.nodes().unbind('mouseout').bind('mouseout', () => {
|
|
||||||
const tooltip = document.getElementById('node-tooltip');
|
|
||||||
if (tooltip) {
|
|
||||||
tooltip.style.opacity = '0';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Fehler beim Laden der Mindmap:', error);
|
console.error('Fehler beim Laden der Mindmap:', error);
|
||||||
alert('Die Mindmap konnte nicht geladen werden. Bitte prüfen Sie die Konsole für Details.');
|
alert('Die Mindmap konnte nicht geladen werden. Bitte prüfen Sie die Konsole für Details.');
|
||||||
@@ -528,114 +576,7 @@
|
|||||||
// Andere Benutzer erhalten die Position über den node_updated Event
|
// Andere Benutzer erhalten die Position über den node_updated Event
|
||||||
});
|
});
|
||||||
|
|
||||||
/* 8. Kontextmenü (optional) */
|
/* 8. Export-Funktion (optional) */
|
||||||
const setupContextMenu = () => {
|
|
||||||
cy.on('cxttap', 'node', function(e) {
|
|
||||||
const node = e.target;
|
|
||||||
const nodeData = node.data();
|
|
||||||
|
|
||||||
// Position des Kontextmenüs berechnen
|
|
||||||
const renderedPosition = node.renderedPosition();
|
|
||||||
const containerRect = cy.container().getBoundingClientRect();
|
|
||||||
const menuX = containerRect.left + renderedPosition.x;
|
|
||||||
const menuY = containerRect.top + renderedPosition.y;
|
|
||||||
|
|
||||||
// Kontextmenü erstellen oder aktualisieren
|
|
||||||
let contextMenu = document.getElementById('context-menu');
|
|
||||||
if (!contextMenu) {
|
|
||||||
contextMenu = document.createElement('div');
|
|
||||||
contextMenu.id = 'context-menu';
|
|
||||||
contextMenu.style.position = 'absolute';
|
|
||||||
contextMenu.style.backgroundColor = '#fff';
|
|
||||||
contextMenu.style.border = '1px solid #ccc';
|
|
||||||
contextMenu.style.borderRadius = '4px';
|
|
||||||
contextMenu.style.padding = '5px 0';
|
|
||||||
contextMenu.style.boxShadow = '0 2px 10px rgba(0,0,0,0.2)';
|
|
||||||
contextMenu.style.zIndex = 1000;
|
|
||||||
document.body.appendChild(contextMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menüinhalte
|
|
||||||
contextMenu.innerHTML = `
|
|
||||||
<div class="menu-item" data-action="edit">Knoten bearbeiten</div>
|
|
||||||
<div class="menu-item" data-action="connect">Verbindung erstellen</div>
|
|
||||||
<div class="menu-item" data-action="delete">Knoten löschen</div>
|
|
||||||
`;
|
|
||||||
|
|
||||||
// Styling für Menüpunkte
|
|
||||||
const menuItems = contextMenu.querySelectorAll('.menu-item');
|
|
||||||
menuItems.forEach(item => {
|
|
||||||
item.style.padding = '8px 20px';
|
|
||||||
item.style.cursor = 'pointer';
|
|
||||||
item.style.fontSize = '14px';
|
|
||||||
|
|
||||||
item.addEventListener('mouseover', function() {
|
|
||||||
this.style.backgroundColor = '#f0f0f0';
|
|
||||||
});
|
|
||||||
|
|
||||||
item.addEventListener('mouseout', function() {
|
|
||||||
this.style.backgroundColor = 'transparent';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Event-Handler
|
|
||||||
item.addEventListener('click', async function() {
|
|
||||||
const action = this.getAttribute('data-action');
|
|
||||||
|
|
||||||
switch(action) {
|
|
||||||
case 'edit':
|
|
||||||
// Knoten bearbeiten (gleiche Logik wie beim Edit-Button)
|
|
||||||
const name = prompt('Knotenname:', nodeData.name);
|
|
||||||
if (name) {
|
|
||||||
const description = prompt('Beschreibung:', nodeData.description || '');
|
|
||||||
await post(`/api/mind_map_node/${nodeData.id}`, { name, description });
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'connect':
|
|
||||||
// Modus zum Verbinden aktivieren
|
|
||||||
cy.nodes().unselect();
|
|
||||||
node.select();
|
|
||||||
alert('Wählen Sie nun einen zweiten Knoten aus, um eine Verbindung zu erstellen');
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'delete':
|
|
||||||
if (confirm('Sind Sie sicher, dass Sie diesen Knoten löschen möchten?')) {
|
|
||||||
await del(`/api/mind_map_node/${nodeData.id}`);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menü schließen
|
|
||||||
contextMenu.style.display = 'none';
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Menü positionieren und anzeigen
|
|
||||||
contextMenu.style.left = menuX + 'px';
|
|
||||||
contextMenu.style.top = menuY + 'px';
|
|
||||||
contextMenu.style.display = 'block';
|
|
||||||
|
|
||||||
// Event-Listener zum Schließen des Menüs
|
|
||||||
const closeMenu = function() {
|
|
||||||
if (contextMenu) {
|
|
||||||
contextMenu.style.display = 'none';
|
|
||||||
}
|
|
||||||
document.removeEventListener('click', closeMenu);
|
|
||||||
};
|
|
||||||
|
|
||||||
// Verzögerung, um den aktuellen Click nicht zu erfassen
|
|
||||||
setTimeout(() => {
|
|
||||||
document.addEventListener('click', closeMenu);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// Kontextmenü aktivieren (optional)
|
|
||||||
// setupContextMenu();
|
|
||||||
|
|
||||||
/* 9. Export-Funktion (optional) */
|
|
||||||
const btnExport = document.getElementById('exportMindmap');
|
const btnExport = document.getElementById('exportMindmap');
|
||||||
if (btnExport) {
|
if (btnExport) {
|
||||||
btnExport.addEventListener('click', () => {
|
btnExport.addEventListener('click', () => {
|
||||||
|
|||||||
@@ -26,105 +26,216 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
function initMindmapPage() {
|
function initMindmapPage() {
|
||||||
console.log('Mindmap-Seite wird initialisiert...');
|
console.log('Mindmap-Seite wird initialisiert...');
|
||||||
|
|
||||||
// Hauptcontainer für die Mindmap
|
// Warte auf die Cytoscape-Instanz
|
||||||
const cyContainer = document.getElementById('cy');
|
document.addEventListener('mindmap-loaded', function() {
|
||||||
if (!cyContainer) {
|
const cy = window.cy;
|
||||||
console.error('Mindmap-Container #cy nicht gefunden!');
|
if (!cy) return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info-Panel für Knotendetails
|
// Event-Listener für Knoten-Klicks
|
||||||
const nodeInfoPanel = document.getElementById('node-info-panel');
|
cy.on('tap', 'node', function(evt) {
|
||||||
const nodeDescription = document.getElementById('node-description');
|
const node = evt.target;
|
||||||
const connectedNodes = document.getElementById('connected-nodes');
|
|
||||||
|
|
||||||
// Toolbar-Buttons
|
// Alle vorherigen Hervorhebungen zurücksetzen
|
||||||
const fitButton = document.getElementById('fit-btn');
|
cy.nodes().forEach(n => {
|
||||||
const resetButton = document.getElementById('reset-btn');
|
n.removeStyle();
|
||||||
const toggleLabelsButton = document.getElementById('toggle-labels-btn');
|
n.connectedEdges().removeStyle();
|
||||||
|
|
||||||
// Mindmap-Instanz
|
|
||||||
let mindmap = null;
|
|
||||||
|
|
||||||
// Cytoscape.js für die Visualisierung initialisieren
|
|
||||||
try {
|
|
||||||
// Cytoscape.js-Bibliothek überprüfen
|
|
||||||
if (typeof cytoscape === 'undefined') {
|
|
||||||
loadExternalScript('https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.26.0/cytoscape.min.js')
|
|
||||||
.then(() => {
|
|
||||||
initCytoscape();
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Fehler beim Laden von Cytoscape.js:', error);
|
|
||||||
showErrorMessage(cyContainer, 'Cytoscape.js konnte nicht geladen werden.');
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
initCytoscape();
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Fehler bei der Initialisierung der Mindmap:', error);
|
|
||||||
showErrorMessage(cyContainer, 'Die Mindmap konnte nicht initialisiert werden: ' + error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// Speichere ausgewählten Knoten
|
||||||
* Lädt ein externes Script asynchron
|
window.mindmapInstance.selectedNode = node;
|
||||||
*/
|
|
||||||
function loadExternalScript(url) {
|
// Aktiviere leuchtenden Effekt statt Umkreisung
|
||||||
return new Promise((resolve, reject) => {
|
node.style({
|
||||||
const script = document.createElement('script');
|
'background-opacity': 1,
|
||||||
script.src = url;
|
'background-color': node.data('color'),
|
||||||
script.onload = resolve;
|
'shadow-color': node.data('color'),
|
||||||
script.onerror = reject;
|
'shadow-opacity': 1,
|
||||||
document.head.appendChild(script);
|
'shadow-blur': 15,
|
||||||
|
'shadow-offset-x': 0,
|
||||||
|
'shadow-offset-y': 0
|
||||||
|
});
|
||||||
|
|
||||||
|
// Verbundene Kanten und Knoten hervorheben
|
||||||
|
const connectedEdges = node.connectedEdges();
|
||||||
|
const connectedNodes = node.neighborhood('node');
|
||||||
|
|
||||||
|
connectedEdges.style({
|
||||||
|
'line-color': '#a78bfa',
|
||||||
|
'target-arrow-color': '#a78bfa',
|
||||||
|
'source-arrow-color': '#a78bfa',
|
||||||
|
'line-opacity': 0.8,
|
||||||
|
'width': 2
|
||||||
|
});
|
||||||
|
|
||||||
|
connectedNodes.style({
|
||||||
|
'shadow-opacity': 0.7,
|
||||||
|
'shadow-blur': 10,
|
||||||
|
'shadow-color': '#a78bfa'
|
||||||
|
});
|
||||||
|
|
||||||
|
// Info-Panel aktualisieren
|
||||||
|
updateInfoPanel(node);
|
||||||
|
|
||||||
|
// Seitenleiste aktualisieren
|
||||||
|
updateSidebar(node);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Klick auf Hintergrund - Auswahl zurücksetzen
|
||||||
|
cy.on('tap', function(evt) {
|
||||||
|
if (evt.target === cy) {
|
||||||
|
resetSelection(cy);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Zoom-Controls
|
||||||
|
document.getElementById('zoomIn')?.addEventListener('click', () => {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() * 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('zoomOut')?.addEventListener('click', () => {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() / 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
document.getElementById('resetView')?.addEventListener('click', () => {
|
||||||
|
cy.fit();
|
||||||
|
resetSelection(cy);
|
||||||
|
});
|
||||||
|
|
||||||
|
// Legend-Toggle
|
||||||
|
document.getElementById('toggleLegend')?.addEventListener('click', () => {
|
||||||
|
const legend = document.getElementById('categoryLegend');
|
||||||
|
if (legend) {
|
||||||
|
isLegendVisible = !isLegendVisible;
|
||||||
|
legend.style.display = isLegendVisible ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Keyboard-Controls
|
||||||
|
document.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === '+' || e.key === '=') {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() * 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
} else if (e.key === '-' || e.key === '_') {
|
||||||
|
cy.zoom({
|
||||||
|
level: cy.zoom() / 1.2,
|
||||||
|
renderedPosition: { x: cy.width() / 2, y: cy.height() / 2 }
|
||||||
|
});
|
||||||
|
} else if (e.key === 'Escape') {
|
||||||
|
resetSelection(cy);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Zeigt eine Fehlermeldung im Container an
|
* Aktualisiert das Info-Panel mit Knoteninformationen
|
||||||
|
* @param {Object} node - Der ausgewählte Knoten
|
||||||
*/
|
*/
|
||||||
function showErrorMessage(container, message) {
|
function updateInfoPanel(node) {
|
||||||
container.innerHTML = `
|
const infoPanel = document.getElementById('infoPanel');
|
||||||
<div class="p-8 text-center bg-red-50 dark:bg-red-900/20 rounded-lg">
|
if (!infoPanel) return;
|
||||||
<i class="fa-solid fa-triangle-exclamation text-4xl text-red-500 mb-4"></i>
|
|
||||||
<p class="text-lg text-red-600 dark:text-red-400">${message}</p>
|
const data = node.data();
|
||||||
<p class="mt-2 text-sm text-gray-600 dark:text-gray-400">Bitte laden Sie die Seite neu oder kontaktieren Sie den Support.</p>
|
const connectedNodes = node.neighborhood('node');
|
||||||
</div>
|
|
||||||
|
let html = `
|
||||||
|
<h3>${data.label || data.name}</h3>
|
||||||
|
<p class="category">${data.category || 'Keine Kategorie'}</p>
|
||||||
|
${data.description ? `<p class="description">${data.description}</p>` : ''}
|
||||||
|
<div class="connections">
|
||||||
|
<h4>Verbindungen (${connectedNodes.length})</h4>
|
||||||
|
<ul>
|
||||||
`;
|
`;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
connectedNodes.forEach(connectedNode => {
|
||||||
* Initialisiert Cytoscape mit den Mindmap-Daten
|
const connectedData = connectedNode.data();
|
||||||
*/
|
html += `
|
||||||
function initCytoscape() {
|
<li style="color: ${connectedData.color || '#60a5fa'}">
|
||||||
console.log('Cytoscape.js wird initialisiert...');
|
${connectedData.label || connectedData.name}
|
||||||
|
</li>
|
||||||
|
`;
|
||||||
|
});
|
||||||
|
|
||||||
// Zeige Ladeanimation
|
html += `
|
||||||
cyContainer.innerHTML = `
|
</ul>
|
||||||
<div class="flex justify-center items-center h-full">
|
|
||||||
<div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-purple-500"></div>
|
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
// Lade Daten vom Backend
|
infoPanel.innerHTML = html;
|
||||||
fetch('/api/mindmap')
|
infoPanel.style.display = 'block';
|
||||||
.then(response => {
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Netzwerkfehler beim Laden der Mindmap-Daten');
|
|
||||||
}
|
}
|
||||||
return response.json();
|
|
||||||
})
|
|
||||||
.then(data => {
|
|
||||||
console.log('Mindmap-Daten erfolgreich geladen');
|
|
||||||
renderMindmap(data);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('Fehler beim Laden der Mindmap-Daten:', error);
|
|
||||||
|
|
||||||
// Verwende Standarddaten als Fallback
|
/**
|
||||||
console.log('Verwende Standarddaten als Fallback...');
|
* Aktualisiert die Seitenleiste mit Knoteninformationen
|
||||||
const defaultData = generateDefaultData();
|
* @param {Object} node - Der ausgewählte Knoten
|
||||||
renderMindmap(defaultData);
|
*/
|
||||||
|
function updateSidebar(node) {
|
||||||
|
const sidebar = document.getElementById('sidebar');
|
||||||
|
if (!sidebar) return;
|
||||||
|
|
||||||
|
const data = node.data();
|
||||||
|
const connectedNodes = node.neighborhood('node');
|
||||||
|
|
||||||
|
let html = `
|
||||||
|
<div class="node-details">
|
||||||
|
<h3>${data.label || data.name}</h3>
|
||||||
|
<p class="category">${data.category || 'Keine Kategorie'}</p>
|
||||||
|
${data.description ? `<p class="description">${data.description}</p>` : ''}
|
||||||
|
<div class="connections">
|
||||||
|
<h4>Verbindungen (${connectedNodes.length})</h4>
|
||||||
|
<ul>
|
||||||
|
`;
|
||||||
|
|
||||||
|
connectedNodes.forEach(connectedNode => {
|
||||||
|
const connectedData = connectedNode.data();
|
||||||
|
html += `
|
||||||
|
<li style="color: ${connectedData.color || '#60a5fa'}">
|
||||||
|
${connectedData.label || connectedData.name}
|
||||||
|
</li>
|
||||||
|
`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
html += `
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
|
||||||
|
sidebar.innerHTML = html;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setzt die Auswahl zurück
|
||||||
|
* @param {Object} cy - Cytoscape-Instanz
|
||||||
|
*/
|
||||||
|
function resetSelection(cy) {
|
||||||
|
window.mindmapInstance.selectedNode = null;
|
||||||
|
|
||||||
|
// Alle Hervorhebungen zurücksetzen
|
||||||
|
cy.nodes().forEach(node => {
|
||||||
|
node.removeStyle();
|
||||||
|
node.connectedEdges().removeStyle();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Info-Panel ausblenden
|
||||||
|
const infoPanel = document.getElementById('infoPanel');
|
||||||
|
if (infoPanel) {
|
||||||
|
infoPanel.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Seitenleiste leeren
|
||||||
|
const sidebar = document.getElementById('sidebar');
|
||||||
|
if (sidebar) {
|
||||||
|
sidebar.innerHTML = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -435,4 +546,6 @@ function initMindmapPage() {
|
|||||||
];
|
];
|
||||||
return colors[Math.floor(Math.random() * colors.length)];
|
return colors[Math.floor(Math.random() * colors.length)];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Initialisiere die Mindmap-Seite
|
||||||
|
initMindmapPage();
|
||||||
@@ -6,19 +6,83 @@
|
|||||||
|
|
||||||
// Warte bis DOM geladen ist
|
// Warte bis DOM geladen ist
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Prüfe, ob wir auf der Mindmap-Seite sind
|
console.log('DOMContentLoaded Event ausgelöst');
|
||||||
|
|
||||||
|
// Prüfe, ob der Container existiert
|
||||||
const cyContainer = document.getElementById('cy');
|
const cyContainer = document.getElementById('cy');
|
||||||
|
console.log('Container gefunden:', cyContainer);
|
||||||
|
|
||||||
if (!cyContainer) {
|
if (!cyContainer) {
|
||||||
console.log('Kein Mindmap-Container gefunden, überspringe Initialisierung.');
|
console.error('Mindmap-Container #cy nicht gefunden!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Auf das Laden der Mindmap warten
|
// Prüfe, ob Cytoscape verfügbar ist
|
||||||
document.addEventListener('mindmap-loaded', function() {
|
if (typeof cytoscape === 'undefined') {
|
||||||
console.log('Mindmap geladen, wende neuronales Netzwerk-Design an...');
|
console.error('Cytoscape ist nicht definiert!');
|
||||||
updateMindmap();
|
return;
|
||||||
|
}
|
||||||
|
console.log('Cytoscape ist verfügbar');
|
||||||
|
|
||||||
|
// Beispiel-Daten (kannst du später ersetzen)
|
||||||
|
const elements = [
|
||||||
|
{ data: { id: 'a', label: 'Neuron A' } },
|
||||||
|
{ data: { id: 'b', label: 'Neuron B' } },
|
||||||
|
{ data: { id: 'c', label: 'Neuron C' } },
|
||||||
|
{ data: { source: 'a', target: 'b' } },
|
||||||
|
{ data: { source: 'a', target: 'c' } }
|
||||||
|
];
|
||||||
|
|
||||||
|
console.log('Initialisiere Cytoscape...');
|
||||||
|
|
||||||
|
// Initialisiere Cytoscape
|
||||||
|
window.cy = cytoscape({
|
||||||
|
container: cyContainer,
|
||||||
|
elements: elements,
|
||||||
|
style: [
|
||||||
|
{
|
||||||
|
selector: 'node',
|
||||||
|
style: {
|
||||||
|
'background-color': '#60a5fa',
|
||||||
|
'label': 'data(label)',
|
||||||
|
'color': '#fff',
|
||||||
|
'text-background-color': '#222a',
|
||||||
|
'text-background-opacity': 0.7,
|
||||||
|
'text-background-padding': '4px',
|
||||||
|
'text-valign': 'center',
|
||||||
|
'text-halign': 'center',
|
||||||
|
'font-size': 18,
|
||||||
|
'width': 40,
|
||||||
|
'height': 40,
|
||||||
|
'border-width': 4,
|
||||||
|
'border-color': '#a78bfa',
|
||||||
|
'shadow-blur': 20,
|
||||||
|
'shadow-color': '#a78bfa',
|
||||||
|
'shadow-opacity': 0.7,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: 'edge',
|
||||||
|
style: {
|
||||||
|
'width': 4,
|
||||||
|
'line-color': '#a78bfa',
|
||||||
|
'target-arrow-color': '#a78bfa',
|
||||||
|
'target-arrow-shape': 'triangle',
|
||||||
|
'curve-style': 'bezier'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
layout: {
|
||||||
|
name: 'cose',
|
||||||
|
animate: true
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log('Cytoscape initialisiert');
|
||||||
|
|
||||||
|
// Event auslösen, damit andere Scripte reagieren können
|
||||||
|
document.dispatchEvent(new Event('mindmap-loaded'));
|
||||||
|
console.log('mindmap-loaded Event ausgelöst');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Mindmap-Daten
|
// Mindmap-Daten
|
||||||
@@ -158,6 +222,15 @@ const mindmapData = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Kategorie-Farben definieren
|
||||||
|
const categoryColors = {
|
||||||
|
'Philosophie': '#60a5fa',
|
||||||
|
'Wissenschaft': '#8b5cf6',
|
||||||
|
'Technologie': '#10b981',
|
||||||
|
'Künste': '#f59e0b',
|
||||||
|
'Psychologie': '#ef4444'
|
||||||
|
};
|
||||||
|
|
||||||
// Mindmap aktualisieren
|
// Mindmap aktualisieren
|
||||||
function updateMindmap() {
|
function updateMindmap() {
|
||||||
if (!cy) return;
|
if (!cy) return;
|
||||||
@@ -173,7 +246,13 @@ function updateMindmap() {
|
|||||||
id: node.id,
|
id: node.id,
|
||||||
label: node.label,
|
label: node.label,
|
||||||
category: node.category,
|
category: node.category,
|
||||||
description: node.description
|
description: node.description,
|
||||||
|
color: categoryColors[node.category] || '#60a5fa',
|
||||||
|
neuronSize: Math.floor(Math.random() * 8) + 3,
|
||||||
|
neuronActivity: Math.random() * 0.7 + 0.3,
|
||||||
|
pulseFrequency: Math.random() * 4 + 2,
|
||||||
|
refractionPeriod: Math.random() * 300 + 700,
|
||||||
|
threshold: Math.random() * 0.3 + 0.6
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -185,30 +264,126 @@ function updateMindmap() {
|
|||||||
data: {
|
data: {
|
||||||
source: edge.source,
|
source: edge.source,
|
||||||
target: edge.target,
|
target: edge.target,
|
||||||
label: edge.label
|
label: edge.label,
|
||||||
|
strength: Math.random() * 0.6 + 0.2,
|
||||||
|
conductionVelocity: Math.random() * 0.5 + 0.3,
|
||||||
|
latency: Math.random() * 100 + 50
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Neuronales Netzwerk-Styling anwenden
|
||||||
|
cy.style([
|
||||||
|
{
|
||||||
|
selector: 'node',
|
||||||
|
style: {
|
||||||
|
'label': 'data(label)',
|
||||||
|
'text-valign': 'center',
|
||||||
|
'text-halign': 'center',
|
||||||
|
'text-wrap': 'wrap',
|
||||||
|
'text-max-width': '100px',
|
||||||
|
'font-size': '14px',
|
||||||
|
'color': '#ffffff',
|
||||||
|
'text-outline-color': '#0a0e19',
|
||||||
|
'text-outline-width': 1.5,
|
||||||
|
'text-outline-opacity': 0.9,
|
||||||
|
'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,
|
||||||
|
'text-background-color': 'rgba(24, 28, 45, 0.7)',
|
||||||
|
'text-background-opacity': 0.8,
|
||||||
|
'text-background-shape': 'roundrectangle',
|
||||||
|
'text-background-padding': '4px',
|
||||||
|
'transition-property': 'background-color, shadow-blur, shadow-opacity, background-opacity',
|
||||||
|
'transition-duration': '0.5s'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
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%',
|
||||||
|
'transition-property': 'line-color, width, line-style, line-opacity',
|
||||||
|
'transition-duration': '0.4s'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: ':selected',
|
||||||
|
style: {
|
||||||
|
'background-color': '#f59e0b',
|
||||||
|
'shadow-blur': 32,
|
||||||
|
'shadow-color': '#f59e0b',
|
||||||
|
'shadow-opacity': 1,
|
||||||
|
'border-width': 4,
|
||||||
|
'border-color': '#fff'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
selector: '.highlighted',
|
||||||
|
style: {
|
||||||
|
'background-color': '#10b981',
|
||||||
|
'shadow-blur': 28,
|
||||||
|
'shadow-color': '#10b981',
|
||||||
|
'shadow-opacity': 1,
|
||||||
|
'line-color': '#10b981',
|
||||||
|
'target-arrow-color': '#10b981',
|
||||||
|
'transition-property': 'background-color, shadow-blur, shadow-opacity, line-color',
|
||||||
|
'transition-duration': '0.3s'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
// Layout anwenden
|
// Layout anwenden
|
||||||
cy.layout({
|
cy.layout({
|
||||||
name: 'cose',
|
name: 'cose',
|
||||||
idealEdgeLength: 100,
|
animate: true,
|
||||||
nodeOverlap: 20,
|
animationDuration: 1800,
|
||||||
refresh: 20,
|
nodeDimensionsIncludeLabels: true,
|
||||||
fit: true,
|
padding: 100,
|
||||||
padding: 30,
|
spacingFactor: 1.8,
|
||||||
randomize: false,
|
randomize: false,
|
||||||
|
fit: true,
|
||||||
componentSpacing: 100,
|
componentSpacing: 100,
|
||||||
nodeRepulsion: 400000,
|
nodeRepulsion: 8000,
|
||||||
edgeElasticity: 100,
|
edgeElasticity: 100,
|
||||||
nestingFactor: 5,
|
nestingFactor: 1.2,
|
||||||
gravity: 80,
|
gravity: 80
|
||||||
numIter: 1000,
|
|
||||||
initialTemp: 200,
|
|
||||||
coolingFactor: 0.95,
|
|
||||||
minTemp: 1.0
|
|
||||||
}).run();
|
}).run();
|
||||||
|
|
||||||
|
// Pulsierende Soma-Effekte starten
|
||||||
|
if (window.pulseInterval) clearInterval(window.pulseInterval);
|
||||||
|
window.pulseInterval = setInterval(() => {
|
||||||
|
cy.nodes().forEach(node => {
|
||||||
|
const baseBlur = 18;
|
||||||
|
const pulse = 0.7 + 0.3 * Math.sin(Date.now() / 400 + node.id().charCodeAt(0));
|
||||||
|
node.style('shadow-blur', baseBlur * pulse);
|
||||||
|
node.style('shadow-opacity', 0.6 + 0.3 * pulse);
|
||||||
|
node.style('background-opacity', 0.85 + 0.1 * pulse);
|
||||||
|
});
|
||||||
|
}, 80);
|
||||||
|
|
||||||
|
// Neuronale Aktivität simulieren
|
||||||
|
startNeuralActivitySimulation(cy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -358,160 +533,91 @@ function applyNeuralNetworkStyle(cy) {
|
|||||||
* @param {Object} cy - Cytoscape-Instanz
|
* @param {Object} cy - Cytoscape-Instanz
|
||||||
*/
|
*/
|
||||||
function startNeuralActivitySimulation(cy) {
|
function startNeuralActivitySimulation(cy) {
|
||||||
// Neuronen-Zustand für die Simulation
|
if (window.neuralInterval) clearInterval(window.neuralInterval);
|
||||||
const neuronStates = new Map();
|
|
||||||
|
|
||||||
// Initialisieren aller Neuronen-Zustände
|
const nodes = cy.nodes();
|
||||||
cy.nodes().forEach(node => {
|
const edges = cy.edges();
|
||||||
neuronStates.set(node.id(), {
|
let currentTime = Date.now();
|
||||||
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
|
// Neuronale Aktivität simulieren
|
||||||
function simulateNeuralActivity() {
|
function simulateNeuralActivity() {
|
||||||
const currentTime = Date.now();
|
currentTime = Date.now();
|
||||||
const nodes = cy.nodes().toArray();
|
|
||||||
|
|
||||||
// Zufällige Stimulation eines Neurons
|
// Zufällige Neuronen "feuern" lassen
|
||||||
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 => {
|
nodes.forEach(node => {
|
||||||
const nodeId = node.id();
|
const data = node.data();
|
||||||
const state = neuronStates.get(nodeId);
|
const lastFired = data.lastFired || 0;
|
||||||
const threshold = node.data('threshold') || 0.7;
|
const timeSinceLastFire = currentTime - lastFired;
|
||||||
const refractoryPeriod = node.data('refractionPeriod') || 1000;
|
|
||||||
|
|
||||||
// Überprüfen, ob die Refraktärphase beendet ist
|
// Prüfen ob Neuron feuern kann (Refraktionsperiode)
|
||||||
if (state.isRefractory && currentTime >= state.refractoryUntil) {
|
if (timeSinceLastFire > data.refractionPeriod) {
|
||||||
state.isRefractory = false;
|
// Zufälliges Feuern basierend auf Aktivität
|
||||||
state.potential = 0.1; // Ruhepotential nach Refraktärphase
|
if (Math.random() < data.neuronActivity * 0.1) {
|
||||||
|
fireNeuron(node, true, currentTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
// Neuron feuern lassen
|
||||||
function fireNeuron(node, state, currentTime) {
|
function fireNeuron(node, state, currentTime) {
|
||||||
// Neuron aktivieren
|
const data = node.data();
|
||||||
node.animate({
|
data.lastFired = currentTime;
|
||||||
style: {
|
|
||||||
|
// Visuelles Feedback
|
||||||
|
node.style({
|
||||||
'background-opacity': 1,
|
'background-opacity': 1,
|
||||||
'shadow-opacity': 1,
|
'shadow-blur': 25,
|
||||||
'shadow-blur': 25
|
'shadow-opacity': 0.9
|
||||||
},
|
});
|
||||||
duration: 300,
|
|
||||||
easing: 'ease-in-cubic',
|
// Nach kurzer Zeit zurück zum Normalzustand
|
||||||
complete: function() {
|
setTimeout(() => {
|
||||||
// Zurück zum normalen Zustand
|
node.style({
|
||||||
node.animate({
|
|
||||||
style: {
|
|
||||||
'background-opacity': 0.85,
|
'background-opacity': 0.85,
|
||||||
'shadow-opacity': 0.6,
|
'shadow-blur': 18,
|
||||||
'shadow-blur': 'mapData(neuronActivity, 0.3, 1, 5, 15)'
|
'shadow-opacity': 0.6
|
||||||
},
|
|
||||||
duration: 600,
|
|
||||||
easing: 'ease-out-cubic'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
}, 200);
|
||||||
|
|
||||||
// Refraktärphase setzen
|
// Signal weiterleiten
|
||||||
state.isRefractory = true;
|
if (state) {
|
||||||
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);
|
propagateSignal(node, currentTime);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Signal über Synapsen propagieren
|
// Signal über Kanten weiterleiten
|
||||||
function propagateSignal(sourceNode, currentTime) {
|
function propagateSignal(sourceNode, currentTime) {
|
||||||
// Verbundene Kanten auswählen
|
const outgoingEdges = sourceNode.connectedEdges('out');
|
||||||
const edges = sourceNode.connectedEdges().filter(edge =>
|
|
||||||
edge.source().id() === sourceNode.id() // Nur ausgehende Kanten
|
|
||||||
);
|
|
||||||
|
|
||||||
// Durch alle Kanten iterieren
|
outgoingEdges.forEach(edge => {
|
||||||
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 targetNode = edge.target();
|
||||||
const targetState = neuronStates.get(targetNode.id());
|
const edgeData = edge.data();
|
||||||
|
const latency = edgeData.latency;
|
||||||
|
|
||||||
if (targetState && !targetState.isRefractory) {
|
// Signal mit Verzögerung weiterleiten
|
||||||
// Potentialzunahme basierend auf synaptischer Stärke
|
setTimeout(() => {
|
||||||
targetState.potential += strength * 0.4;
|
const targetData = targetNode.data();
|
||||||
|
const timeSinceLastFire = currentTime - (targetData.lastFired || 0);
|
||||||
|
|
||||||
// Subtile Anzeige der Potenzialänderung
|
// Prüfen ob Zielneuron feuern kann
|
||||||
targetNode.animate({
|
if (timeSinceLastFire > targetData.refractionPeriod) {
|
||||||
style: {
|
// Signalstärke berechnen
|
||||||
'background-opacity': Math.min(1, 0.85 + (strength * 0.2)),
|
const signalStrength = edgeData.strength *
|
||||||
'shadow-opacity': Math.min(1, 0.6 + (strength * 0.3)),
|
edgeData.conductionVelocity *
|
||||||
'shadow-blur': Math.min(25, 10 + (strength * 15))
|
sourceNode.data('neuronActivity');
|
||||||
},
|
|
||||||
duration: 300,
|
// Neuron feuern lassen wenn Signal stark genug
|
||||||
easing: 'ease-in-out'
|
if (signalStrength > targetData.threshold) {
|
||||||
});
|
fireNeuron(targetNode, true, currentTime + latency);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
|
||||||
}, latency);
|
}, latency);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starte die Simulation
|
// Simulation starten
|
||||||
simulateNeuralActivity();
|
window.neuralInterval = setInterval(simulateNeuralActivity, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hilfe-Funktion zum Hinzufügen eines Flash-Hinweises
|
// Hilfe-Funktion zum Hinzufügen eines Flash-Hinweises
|
||||||
|
|||||||
@@ -112,12 +112,6 @@
|
|||||||
<!-- ChatGPT Assistant -->
|
<!-- ChatGPT Assistant -->
|
||||||
<script src="{{ url_for('static', filename='js/modules/chatgpt-assistant.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/modules/chatgpt-assistant.js') }}"></script>
|
||||||
|
|
||||||
<!-- MindMap Visualization Module -->
|
|
||||||
<script src="{{ url_for('static', filename='js/modules/mindmap.js') }}"></script>
|
|
||||||
|
|
||||||
<!-- MindMap Page Module -->
|
|
||||||
<script src="{{ url_for('static', filename='js/modules/mindmap-page.js') }}"></script>
|
|
||||||
|
|
||||||
<!-- Neural Network Background Script -->
|
<!-- Neural Network Background Script -->
|
||||||
<script src="{{ url_for('static', filename='neural-network-background.js') }}"></script>
|
<script src="{{ url_for('static', filename='neural-network-background.js') }}"></script>
|
||||||
|
|
||||||
@@ -741,9 +735,10 @@
|
|||||||
<!-- Hilfsscripts -->
|
<!-- Hilfsscripts -->
|
||||||
{% block scripts %}{% endblock %}
|
{% block scripts %}{% endblock %}
|
||||||
|
|
||||||
<!-- KI-Chat Initialisierung -->
|
<!-- ChatGPT Initialisierung -->
|
||||||
<script>
|
<script>
|
||||||
// ChatGPT-Assistent Klasse
|
// Prüfe, ob ChatGPTAssistant bereits existiert
|
||||||
|
if (typeof ChatGPTAssistant === 'undefined') {
|
||||||
class ChatGPTAssistant {
|
class ChatGPTAssistant {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.chatContainer = null;
|
this.chatContainer = null;
|
||||||
@@ -923,8 +918,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialisiere den ChatGPT-Assistenten direkt, um sicherzustellen,
|
// Initialisiere den ChatGPT-Assistenten direkt
|
||||||
// dass er auf jeder Seite verfügbar ist, selbst wenn MindMap nicht geladen ist
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
// Prüfen, ob der Assistent bereits durch MindMap initialisiert wurde
|
// Prüfen, ob der Assistent bereits durch MindMap initialisiert wurde
|
||||||
if (!window.MindMap || !window.MindMap.assistant) {
|
if (!window.MindMap || !window.MindMap.assistant) {
|
||||||
@@ -939,6 +933,7 @@
|
|||||||
window.MindMap.assistant = assistant;
|
window.MindMap.assistant = assistant;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<!-- Dark/Light-Mode vereinheitlicht -->
|
<!-- Dark/Light-Mode vereinheitlicht -->
|
||||||
|
|||||||
@@ -172,57 +172,61 @@
|
|||||||
|
|
||||||
<!-- Kontrollpanel -->
|
<!-- Kontrollpanel -->
|
||||||
<div class="control-panel">
|
<div class="control-panel">
|
||||||
<button class="control-button" id="zoom-in">
|
<button id="zoomIn" class="control-button">
|
||||||
<i class="fas fa-search-plus"></i> Einzoomen
|
<i class="fas fa-search-plus"></i>
|
||||||
|
<span>Vergrößern</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="control-button" id="zoom-out">
|
<button id="zoomOut" class="control-button">
|
||||||
<i class="fas fa-search-minus"></i> Auszoomen
|
<i class="fas fa-search-minus"></i>
|
||||||
|
<span>Verkleinern</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="control-button" id="reset-view">
|
<button id="resetView" class="control-button">
|
||||||
<i class="fas fa-compress-arrows-alt"></i> Ansicht zurücksetzen
|
<i class="fas fa-sync"></i>
|
||||||
|
<span>Zurücksetzen</span>
|
||||||
</button>
|
</button>
|
||||||
<button class="control-button" id="toggle-legend">
|
<button id="toggleLegend" class="control-button">
|
||||||
<i class="fas fa-layer-group"></i> Legende ein/aus
|
<i class="fas fa-layer-group"></i>
|
||||||
|
<span>Legende</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Info-Panel -->
|
<!-- Info-Panel -->
|
||||||
<div class="info-panel" id="node-info">
|
<div id="infoPanel" class="info-panel">
|
||||||
<h3 class="info-title">Knoteninformationen</h3>
|
<h3 class="info-title">Knotendetails</h3>
|
||||||
<div class="info-content">
|
<div class="info-content"></div>
|
||||||
<p>Wählen Sie einen Knoten aus, um Details anzuzeigen.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Kategorie-Legende -->
|
<!-- Kategorie-Legende -->
|
||||||
<div class="category-legend">
|
<div id="categoryLegend" class="category-legend">
|
||||||
<div class="category-item">
|
<div class="category-item">
|
||||||
<span class="category-color" style="background: #60a5fa;"></span>
|
<div class="category-color" style="background-color: #60a5fa;"></div>
|
||||||
Philosophie
|
<span>Philosophie</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="category-item">
|
<div class="category-item">
|
||||||
<span class="category-color" style="background: #8b5cf6;"></span>
|
<div class="category-color" style="background-color: #8b5cf6;"></div>
|
||||||
Wissenschaft
|
<span>Wissenschaft</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="category-item">
|
<div class="category-item">
|
||||||
<span class="category-color" style="background: #10b981;"></span>
|
<div class="category-color" style="background-color: #10b981;"></div>
|
||||||
Technologie
|
<span>Technologie</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="category-item">
|
<div class="category-item">
|
||||||
<span class="category-color" style="background: #f59e0b;"></span>
|
<div class="category-color" style="background-color: #f59e0b;"></div>
|
||||||
Künste
|
<span>Künste</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="category-item">
|
<div class="category-item">
|
||||||
<span class="category-color" style="background: #ef4444;"></span>
|
<div class="category-color" style="background-color: #ef4444;"></div>
|
||||||
Psychologie
|
<span>Psychologie</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
{% block extra_js %}
|
||||||
<script src="{{ url_for('static', filename='js/cytoscape.min.js') }}"></script>
|
<!-- Cytoscape und Erweiterungen -->
|
||||||
<script src="{{ url_for('static', filename='js/mindmap-init.js') }}"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape/3.26.0/cytoscape.min.js"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/cytoscape-cose-bilkent/4.1.0/cytoscape-cose-bilkent.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Unsere JavaScript-Dateien -->
|
||||||
<script src="{{ url_for('static', filename='js/update_mindmap.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/update_mindmap.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/mindmap-interaction.js') }}"></script>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user