Skip to content

Plan, apply and roll back changes to a production ontology, with a blast radius report and a proof an auditor can re-check.

9.8 KB
Raw Blame
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Open Ontologies — Image to RDF</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { font-family: system-ui, sans-serif; background: #1a1a2e; color: #e0e0e0; padding: 20px; }
        h1 { font-size: 1.4rem; margin-bottom: 10px; color: #7ecfff; }
        .controls { margin-bottom: 15px; display: flex; gap: 10px; align-items: center; }
        button { background: #2563eb; color: white; border: none; padding: 8px 16px; border-radius: 4px; cursor: pointer; font-size: 0.9rem; }
        button:hover { background: #1d4ed8; }
        #drop-zone {
            border: 2px dashed #444; border-radius: 8px; padding: 40px; text-align: center;
            color: #888; cursor: pointer; margin-bottom: 15px; transition: border-color 0.2s;
        }
        #drop-zone.active { border-color: #2563eb; color: #7ecfff; }
        #drop-zone.has-image { border-style: solid; border-color: #333; padding: 0; }
        canvas { display: block; max-width: 100%; border-radius: 6px; }
        #status { font-size: 0.85rem; color: #888; margin-top: 10px; }
        input[type="file"] { display: none; }
        .sample-btn { background: #374151; font-size: 0.8rem; padding: 6px 12px; }
        .sample-btn:hover { background: #4b5563; }
    </style>
</head>
<body>
    <h1>Open Ontologies — Image to RDF</h1>
    <div class="controls">
        <button onclick="document.getElementById('file-input').click()">Choose Image</button>
        <button class="sample-btn" onclick="loadSample('shapes')">Sample: Shapes</button>
        <button class="sample-btn" onclick="loadSample('network')">Sample: Network</button>
        <button class="sample-btn" onclick="loadSample('scene')">Sample: Scene</button>
    </div>
    <input type="file" id="file-input" accept="image/*">
    <div id="drop-zone">Drop an image here or click "Choose Image"</div>
    <canvas id="canvas"></canvas>
    <div id="status">Waiting for image...</div>

    <script>
        const canvas = document.getElementById('canvas');
        const ctx = canvas.getContext('2d');
        const dropZone = document.getElementById('drop-zone');
        const status = document.getElementById('status');
        const fileInput = document.getElementById('file-input');

        function renderImage(src) {
            const img = new Image();
            img.crossOrigin = 'anonymous';
            img.onload = () => {
                // Scale to fit within 900x600
                const maxW = 900, maxH = 600;
                let w = img.width, h = img.height;
                if (w > maxW) { h = h * maxW / w; w = maxW; }
                if (h > maxH) { w = w * maxH / h; h = maxH; }
                canvas.width = Math.round(w);
                canvas.height = Math.round(h);
                ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
                dropZone.style.display = 'none';
                canvas.style.display = 'block';
                status.textContent = `Image loaded: ${img.width}x${img.height} → canvas ${canvas.width}x${canvas.height}. Eyes MCP can now capture this.`;
                console.log(`[OO-Vision] Image loaded: ${canvas.width}x${canvas.height}`);
            };
            img.onerror = () => { status.textContent = 'Failed to load image.'; };
            img.src = src;
        }

        function handleFile(file) {
            if (!file || !file.type.startsWith('image/')) return;
            const reader = new FileReader();
            reader.onload = (e) => renderImage(e.target.result);
            reader.readAsDataURL(file);
        }

        // Drag & drop
        dropZone.addEventListener('dragover', (e) => { e.preventDefault(); dropZone.classList.add('active'); });
        dropZone.addEventListener('dragleave', () => dropZone.classList.remove('active'));
        dropZone.addEventListener('drop', (e) => {
            e.preventDefault();
            dropZone.classList.remove('active');
            handleFile(e.dataTransfer.files[0]);
        });
        dropZone.addEventListener('click', () => fileInput.click());
        fileInput.addEventListener('change', (e) => handleFile(e.target.files[0]));

        // Sample generators
        function loadSample(type) {
            canvas.width = 800;
            canvas.height = 500;
            ctx.fillStyle = '#f8f9fa';
            ctx.fillRect(0, 0, 800, 500);

            if (type === 'shapes') {
                // Geometric shapes with labels
                ctx.fillStyle = '#ef4444'; ctx.fillRect(50, 50, 150, 120);
                ctx.fillStyle = '#000'; ctx.font = '14px sans-serif'; ctx.fillText('Red Rectangle', 60, 200);

                ctx.fillStyle = '#3b82f6'; ctx.beginPath(); ctx.arc(350, 110, 70, 0, Math.PI * 2); ctx.fill();
                ctx.fillStyle = '#000'; ctx.fillText('Blue Circle', 310, 200);

                ctx.fillStyle = '#22c55e'; ctx.beginPath();
                ctx.moveTo(550, 50); ctx.lineTo(650, 170); ctx.lineTo(450, 170); ctx.closePath(); ctx.fill();
                ctx.fillStyle = '#000'; ctx.fillText('Green Triangle', 480, 200);

                ctx.fillStyle = '#f59e0b'; ctx.fillRect(100, 280, 200, 80);
                ctx.fillStyle = '#000'; ctx.fillText('Yellow Rectangle', 130, 390);

                ctx.fillStyle = '#8b5cf6'; ctx.beginPath(); ctx.arc(500, 320, 50, 0, Math.PI * 2); ctx.fill();
                ctx.fillStyle = '#000'; ctx.fillText('Purple Circle', 460, 400);

                // Relationships
                ctx.strokeStyle = '#666'; ctx.lineWidth = 2; ctx.setLineDash([5, 5]);
                ctx.beginPath(); ctx.moveTo(200, 110); ctx.lineTo(280, 110); ctx.stroke();
                ctx.fillStyle = '#666'; ctx.font = '12px sans-serif'; ctx.fillText('adjacent to', 210, 100);

                ctx.beginPath(); ctx.moveTo(350, 180); ctx.lineTo(350, 280); ctx.stroke();
                ctx.fillText('above', 355, 230);

                status.textContent = 'Sample: Geometric shapes with spatial relationships. Eyes MCP can now capture this.';
                console.log('[OO-Vision] Sample loaded: shapes');
            } else if (type === 'network') {
                // Network diagram
                const nodes = [
                    { x: 400, y: 80, label: 'Server', color: '#2563eb' },
                    { x: 200, y: 220, label: 'Database', color: '#dc2626' },
                    { x: 600, y: 220, label: 'Cache', color: '#16a34a' },
                    { x: 100, y: 380, label: 'Users DB', color: '#dc2626' },
                    { x: 300, y: 380, label: 'Orders DB', color: '#dc2626' },
                    { x: 500, y: 380, label: 'Redis', color: '#16a34a' },
                    { x: 700, y: 380, label: 'CDN', color: '#f59e0b' },
                ];
                const edges = [[0,1],[0,2],[1,3],[1,4],[2,5],[2,6]];

                ctx.strokeStyle = '#94a3b8'; ctx.lineWidth = 2; ctx.setLineDash([]);
                edges.forEach(([a, b]) => {
                    ctx.beginPath(); ctx.moveTo(nodes[a].x, nodes[a].y); ctx.lineTo(nodes[b].x, nodes[b].y); ctx.stroke();
                });

                nodes.forEach(n => {
                    ctx.fillStyle = n.color; ctx.beginPath(); ctx.arc(n.x, n.y, 30, 0, Math.PI * 2); ctx.fill();
                    ctx.fillStyle = '#000'; ctx.font = 'bold 13px sans-serif'; ctx.textAlign = 'center';
                    ctx.fillText(n.label, n.x, n.y + 50);
                });
                ctx.textAlign = 'start';

                status.textContent = 'Sample: Network topology diagram. Eyes MCP can now capture this.';
                console.log('[OO-Vision] Sample loaded: network');
            } else if (type === 'scene') {
                // Simple scene with objects
                // Sky
                ctx.fillStyle = '#87CEEB'; ctx.fillRect(0, 0, 800, 300);
                // Ground
                ctx.fillStyle = '#228B22'; ctx.fillRect(0, 300, 800, 200);
                // Sun
                ctx.fillStyle = '#FFD700'; ctx.beginPath(); ctx.arc(700, 80, 50, 0, Math.PI * 2); ctx.fill();
                // House
                ctx.fillStyle = '#8B4513'; ctx.fillRect(100, 200, 200, 150);
                ctx.fillStyle = '#DC143C';
                ctx.beginPath(); ctx.moveTo(80, 200); ctx.lineTo(200, 100); ctx.lineTo(320, 200); ctx.closePath(); ctx.fill();
                // Door
                ctx.fillStyle = '#4a2800'; ctx.fillRect(170, 280, 60, 70);
                // Window
                ctx.fillStyle = '#87CEEB'; ctx.fillRect(120, 240, 40, 40);
                ctx.fillStyle = '#87CEEB'; ctx.fillRect(240, 240, 40, 40);
                // Tree
                ctx.fillStyle = '#8B4513'; ctx.fillRect(480, 220, 30, 130);
                ctx.fillStyle = '#006400'; ctx.beginPath(); ctx.arc(495, 180, 70, 0, Math.PI * 2); ctx.fill();
                // Car
                ctx.fillStyle = '#4169E1'; ctx.fillRect(550, 320, 120, 40);
                ctx.fillStyle = '#4169E1';
                ctx.beginPath(); ctx.moveTo(570, 320); ctx.lineTo(590, 290); ctx.lineTo(650, 290); ctx.lineTo(670, 320); ctx.closePath(); ctx.fill();
                ctx.fillStyle = '#333'; ctx.beginPath(); ctx.arc(575, 365, 15, 0, Math.PI * 2); ctx.fill();
                ctx.beginPath(); ctx.arc(645, 365, 15, 0, Math.PI * 2); ctx.fill();
                // Labels
                ctx.fillStyle = '#000'; ctx.font = '13px sans-serif';
                ctx.fillText('House', 170, 380); ctx.fillText('Tree', 480, 380);
                ctx.fillText('Car', 595, 400); ctx.fillText('Sun', 685, 145);

                status.textContent = 'Sample: Scene with objects and spatial relationships. Eyes MCP can now capture this.';
                console.log('[OO-Vision] Sample loaded: scene');
            }

            dropZone.style.display = 'none';
            canvas.style.display = 'block';
        }
    </script>
    <script src="http://localhost:8869/eyes.js"></script>
</body>
</html>