|
|
|
(function() { |
|
console.log('Drag and Drop Debug Tool Loaded'); |
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
console.log('DOM Content Loaded - Attaching Debug Handlers'); |
|
setTimeout(setupDebugHandlers, 1000); |
|
}); |
|
|
|
function setupDebugHandlers() { |
|
console.log('Setting up drag-drop debug handlers'); |
|
|
|
|
|
const canvas = document.getElementById('network-canvas'); |
|
if (!canvas) { |
|
console.error('ERROR: Canvas element not found!'); |
|
return; |
|
} |
|
|
|
|
|
const existingNodes = document.querySelectorAll('.canvas-node'); |
|
console.log(`Found ${existingNodes.length} existing nodes on the canvas`); |
|
|
|
existingNodes.forEach((node, index) => { |
|
const nodeId = node.getAttribute('data-id') || `unknown-${index}`; |
|
const nodeType = node.getAttribute('data-type') || 'unknown'; |
|
console.log(`Node #${index}: ${nodeType} (${nodeId})`); |
|
|
|
|
|
node.addEventListener('mousedown', function(e) { |
|
console.log(`[DEBUG] Mousedown on node: ${nodeId}`); |
|
console.log(`Target element: ${e.target.className}`); |
|
console.log(`Target has controls? ${!!e.target.closest('.node-controls')}`); |
|
console.log(`Target has port? ${!!e.target.closest('.node-port')}`); |
|
}); |
|
}); |
|
|
|
|
|
canvas.addEventListener('mousemove', function(e) { |
|
|
|
if (Math.random() < 0.01) { |
|
const rect = canvas.getBoundingClientRect(); |
|
const x = e.clientX - rect.left; |
|
const y = e.clientY - rect.top; |
|
console.log(`[DEBUG] Mouse at (${Math.round(x)}, ${Math.round(y)})`); |
|
|
|
|
|
const dragInProgress = document.querySelector('.canvas-node.dragging'); |
|
if (dragInProgress) { |
|
console.log(`[DEBUG] Dragging node: ${dragInProgress.getAttribute('data-id')}`); |
|
} |
|
} |
|
}); |
|
|
|
|
|
if (window.startDrag) { |
|
const originalStartDrag = window.startDrag; |
|
window.startDrag = function(e) { |
|
console.log('[DEBUG] startDrag called', e.target); |
|
return originalStartDrag.apply(this, arguments); |
|
}; |
|
} |
|
|
|
if (window.dragNode) { |
|
const originalDragNode = window.dragNode; |
|
window.dragNode = function(e) { |
|
|
|
if (Math.random() < 0.05) { |
|
console.log('[DEBUG] dragNode called'); |
|
} |
|
return originalDragNode.apply(this, arguments); |
|
}; |
|
} |
|
|
|
|
|
setInterval(function() { |
|
console.log('Checking global drag variables:'); |
|
console.log('window.draggedNode:', window.draggedNode !== undefined); |
|
console.log('window.isDragging:', window.isDragging !== undefined); |
|
|
|
|
|
const draggingNodes = document.querySelectorAll('.canvas-node.dragging'); |
|
if (draggingNodes.length > 0) { |
|
console.log(`[WARNING] Found ${draggingNodes.length} nodes with dragging class, but no active drag`); |
|
} |
|
}, 5000); |
|
|
|
console.log('Debug handlers setup complete'); |
|
} |
|
})(); |