Spaces:
Runtime error
Runtime error
Update index.html
Browse files- index.html +89 -44
index.html
CHANGED
|
@@ -2,79 +2,109 @@
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
-
<
|
|
|
|
| 6 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 7 |
<script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
|
| 8 |
<style>
|
| 9 |
-
body { background: #06090e; color: #cbd5e1; font-family: monospace; }
|
| 10 |
-
.glass { background: rgba(15,23,42,0.
|
| 11 |
.force-pos { color: #4ade80; }
|
| 12 |
.force-neg { color: #f87171; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
</style>
|
| 14 |
</head>
|
| 15 |
-
<body class="flex
|
| 16 |
-
|
| 17 |
-
<
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
<div class="space-y-4 text-xs">
|
| 21 |
<section>
|
| 22 |
-
<label class="text-slate-500">PHASE</label>
|
| 23 |
-
<select id="mode" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-1">
|
| 24 |
<option value="inference">INFERENCE (Solving)</option>
|
| 25 |
<option value="training">TRAINING (Learning K)</option>
|
| 26 |
</select>
|
| 27 |
</section>
|
| 28 |
|
| 29 |
<section>
|
| 30 |
-
<label class="text-slate-500">CONSTRAINT LOGIC</label>
|
| 31 |
-
<select id="probType" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-1">
|
| 32 |
<option value="add">A + B = C</option>
|
| 33 |
<option value="mult">A * B = C</option>
|
| 34 |
</select>
|
| 35 |
</section>
|
| 36 |
|
| 37 |
<section class="border-t border-slate-800 pt-2">
|
| 38 |
-
<label class="text-green-400">TARGET C:</label>
|
| 39 |
-
<input type="number" id="singleVal" value="45" class="w-full bg-black border border-slate-700 p-
|
| 40 |
-
<button onclick="triggerSingle()" class="w-full bg-blue-700 mt-2 py-1 font-bold">ENGAGE SINGLE RUN</button>
|
| 41 |
</section>
|
| 42 |
|
| 43 |
-
<section class="bg-slate-900 p-2 rounded">
|
| 44 |
-
<label class="text-purple-400">BATCH TEST SETS:</label>
|
| 45 |
-
<input type="number" id="b_count" value="10" class="w-full bg-black border border-slate-700 p-
|
| 46 |
-
<button onclick="triggerBatch()" class="w-full bg-purple-700 py-1 font-bold">START BATCH RUN</button>
|
| 47 |
</section>
|
| 48 |
|
| 49 |
-
<button onclick="triggerHalt()" class="w-full border border-red-500 text-red-500 py-
|
| 50 |
</div>
|
| 51 |
|
| 52 |
-
<div class="mt-auto border-t border-slate-800 pt-4">
|
| 53 |
-
<h3 class="text-xs text-orange-400">
|
| 54 |
-
<div id="error-meter" class="text-2xl font-bold">0.000</div>
|
| 55 |
-
<div class="w-full bg-slate-800 h-
|
| 56 |
<div id="error-bar" class="bg-red-500 h-full transition-all" style="width: 0%"></div>
|
| 57 |
</div>
|
| 58 |
</div>
|
| 59 |
</aside>
|
| 60 |
|
| 61 |
-
<
|
| 62 |
-
|
| 63 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
<!-- Force Meters -->
|
| 65 |
-
<div id="force-tracker" class="w-1/2 p-
|
| 66 |
-
<h4 class="text-blue-300 mb-
|
| 67 |
-
<div id="node-details">Waiting...</div>
|
| 68 |
</div>
|
| 69 |
<!-- Event Log -->
|
| 70 |
-
<div id="logger" class="w-1/2 p-
|
| 71 |
-
<h4 class="text-slate-400 mb-
|
| 72 |
<div id="log-content">...</div>
|
| 73 |
</div>
|
| 74 |
</div>
|
| 75 |
</main>
|
| 76 |
|
| 77 |
<script>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
async function sendConfig() {
|
| 79 |
await fetch('/apply_config', {
|
| 80 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
@@ -112,39 +142,54 @@
|
|
| 112 |
const r = await fetch('/state');
|
| 113 |
const d = await r.json();
|
| 114 |
|
| 115 |
-
// 1.
|
| 116 |
const err = Math.abs(d.error);
|
| 117 |
document.getElementById('error-meter').innerText = d.error.toFixed(4);
|
| 118 |
document.getElementById('error-bar').style.width = Math.min(100, err * 2) + "%";
|
| 119 |
-
document.getElementById('error-meter').className = err < 0.1 ? "text-green-400 text-
|
| 120 |
|
| 121 |
-
// 2.
|
| 122 |
let forceHTML = "";
|
| 123 |
let px=[], py=[], pz=[], ids=[];
|
| 124 |
Object.keys(d.nodes).forEach(id => {
|
| 125 |
const n = d.nodes[id];
|
| 126 |
-
const
|
| 127 |
-
forceHTML += `<div>NODE ${id}: X=
|
| 128 |
px.push(n.x); py.push(n.y); pz.push(n.z); ids.push(id);
|
| 129 |
});
|
| 130 |
document.getElementById('node-details').innerHTML = forceHTML;
|
| 131 |
document.getElementById('log-content').innerHTML = d.logs.map(l => `<div>${l}</div>`).join('');
|
| 132 |
|
| 133 |
-
// 3.
|
| 134 |
const trace = {
|
| 135 |
type: 'scatter3d', mode: 'lines+markers+text',
|
| 136 |
x: px.concat([px[0]]), y: py.concat([py[0]]), z: pz.concat([pz[0]]),
|
| 137 |
-
text: ids.concat(['']),
|
|
|
|
|
|
|
| 138 |
};
|
| 139 |
const layout = {
|
| 140 |
-
margin: {l:0,r:0,t:0,b:0},
|
| 141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 142 |
};
|
| 143 |
-
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
|
| 146 |
} catch(e) {}
|
| 147 |
-
},
|
| 148 |
</script>
|
| 149 |
</body>
|
| 150 |
</html>
|
|
|
|
| 2 |
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
| 6 |
+
<title>Mesh Reasoner Lab Mobile</title>
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<script src="https://cdn.plot.ly/plotly-2.24.1.min.js"></script>
|
| 9 |
<style>
|
| 10 |
+
body { background: #06090e; color: #cbd5e1; font-family: monospace; overflow: hidden; }
|
| 11 |
+
.glass { background: rgba(15,23,42,0.95); border: 1px solid #334155; }
|
| 12 |
.force-pos { color: #4ade80; }
|
| 13 |
.force-neg { color: #f87171; }
|
| 14 |
+
/* Control Drawer for Mobile */
|
| 15 |
+
#drawer { transition: transform 0.3s ease-in-out; z-index: 50; }
|
| 16 |
+
.drawer-hidden { transform: translateY(100%); }
|
| 17 |
+
@media (min-width: 1024px) {
|
| 18 |
+
#drawer { transform: none !important; position: static; width: 24rem; height: 100%; }
|
| 19 |
+
#drawer-toggle { display: none; }
|
| 20 |
+
}
|
| 21 |
</style>
|
| 22 |
</head>
|
| 23 |
+
<body class="flex flex-col lg:flex-row h-screen">
|
| 24 |
+
|
| 25 |
+
<!-- Header for Mobile -->
|
| 26 |
+
<header class="lg:hidden glass p-3 flex justify-between items-center z-10">
|
| 27 |
+
<h1 class="text-blue-400 font-bold text-sm">MESH REASONER</h1>
|
| 28 |
+
<button onclick="toggleDrawer()" id="drawer-toggle" class="bg-blue-600 px-4 py-1 rounded text-white text-xs font-bold">⚙️ SETTINGS</button>
|
| 29 |
+
</header>
|
| 30 |
+
|
| 31 |
+
<!-- Controls Drawer / Sidebar -->
|
| 32 |
+
<aside id="drawer" class="fixed inset-x-0 bottom-0 lg:relative lg:translate-y-0 drawer-hidden glass p-4 flex flex-col gap-4 overflow-y-auto max-h-[80vh] lg:max-h-full">
|
| 33 |
+
<div class="flex justify-between items-center lg:hidden border-b border-slate-700 pb-2">
|
| 34 |
+
<span class="text-orange-400 font-bold">CONFIG DIALS</span>
|
| 35 |
+
<button onclick="toggleDrawer()" class="text-slate-400">CLOSE ✕</button>
|
| 36 |
+
</div>
|
| 37 |
|
| 38 |
+
<div class="space-y-4 text-sm lg:text-xs">
|
| 39 |
<section>
|
| 40 |
+
<label class="text-slate-500 block mb-1">PHASE</label>
|
| 41 |
+
<select id="mode" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2 lg:p-1 rounded">
|
| 42 |
<option value="inference">INFERENCE (Solving)</option>
|
| 43 |
<option value="training">TRAINING (Learning K)</option>
|
| 44 |
</select>
|
| 45 |
</section>
|
| 46 |
|
| 47 |
<section>
|
| 48 |
+
<label class="text-slate-500 block mb-1">CONSTRAINT LOGIC</label>
|
| 49 |
+
<select id="probType" onchange="sendConfig()" class="w-full bg-slate-900 border border-slate-700 p-2 lg:p-1 rounded">
|
| 50 |
<option value="add">A + B = C</option>
|
| 51 |
<option value="mult">A * B = C</option>
|
| 52 |
</select>
|
| 53 |
</section>
|
| 54 |
|
| 55 |
<section class="border-t border-slate-800 pt-2">
|
| 56 |
+
<label class="text-green-400 block mb-1">TARGET C:</label>
|
| 57 |
+
<input type="number" id="singleVal" value="45" class="w-full bg-black border border-slate-700 p-2 text-center text-lg lg:text-base font-bold">
|
| 58 |
+
<button onclick="triggerSingle(); toggleDrawer()" class="w-full bg-blue-700 mt-2 py-3 lg:py-1 font-bold rounded shadow-lg">ENGAGE SINGLE RUN</button>
|
| 59 |
</section>
|
| 60 |
|
| 61 |
+
<section class="bg-slate-900/50 p-2 rounded border border-slate-800">
|
| 62 |
+
<label class="text-purple-400 block mb-1">BATCH TEST SETS:</label>
|
| 63 |
+
<input type="number" id="b_count" value="10" class="w-full bg-black border border-slate-700 p-2 mb-1">
|
| 64 |
+
<button onclick="triggerBatch(); toggleDrawer()" class="w-full bg-purple-700 py-3 lg:py-1 font-bold rounded">START BATCH RUN</button>
|
| 65 |
</section>
|
| 66 |
|
| 67 |
+
<button onclick="triggerHalt(); toggleDrawer()" class="w-full border border-red-500 text-red-500 py-2 hover:bg-red-900 rounded">RESET ENGINE</button>
|
| 68 |
</div>
|
| 69 |
|
| 70 |
+
<div class="mt-auto border-t border-slate-800 pt-4 pb-6 lg:pb-0">
|
| 71 |
+
<h3 class="text-xs text-orange-400 uppercase tracking-widest">Live Error</h3>
|
| 72 |
+
<div id="error-meter" class="text-3xl lg:text-2xl font-bold">0.000</div>
|
| 73 |
+
<div class="w-full bg-slate-800 h-3 mt-1 rounded-full overflow-hidden">
|
| 74 |
<div id="error-bar" class="bg-red-500 h-full transition-all" style="width: 0%"></div>
|
| 75 |
</div>
|
| 76 |
</div>
|
| 77 |
</aside>
|
| 78 |
|
| 79 |
+
<!-- Main Viewport -->
|
| 80 |
+
<main class="flex-grow flex flex-col min-h-0">
|
| 81 |
+
<!-- 3D Plot Area -->
|
| 82 |
+
<div id="plot" class="flex-grow min-h-[40vh]"></div>
|
| 83 |
+
|
| 84 |
+
<!-- Live Data Feed Area -->
|
| 85 |
+
<div class="h-48 lg:h-64 border-t border-slate-700 flex flex-col lg:flex-row bg-black/80 backdrop-blur-md">
|
| 86 |
<!-- Force Meters -->
|
| 87 |
+
<div id="force-tracker" class="w-full lg:w-1/2 p-3 border-b lg:border-b-0 lg:border-r border-slate-800 text-[10px] lg:text-[11px] overflow-y-auto">
|
| 88 |
+
<h4 class="text-blue-300 mb-1 sticky top-0 bg-black/80">NODE FORCES (ADOPTION)</h4>
|
| 89 |
+
<div id="node-details" class="space-y-1">Waiting...</div>
|
| 90 |
</div>
|
| 91 |
<!-- Event Log -->
|
| 92 |
+
<div id="logger" class="hidden lg:block lg:w-1/2 p-3 text-[10px] text-slate-500 overflow-y-auto">
|
| 93 |
+
<h4 class="text-slate-400 mb-1">EVENT LOG</h4>
|
| 94 |
<div id="log-content">...</div>
|
| 95 |
</div>
|
| 96 |
</div>
|
| 97 |
</main>
|
| 98 |
|
| 99 |
<script>
|
| 100 |
+
let drawerOpen = false;
|
| 101 |
+
function toggleDrawer() {
|
| 102 |
+
const drawer = document.getElementById('drawer');
|
| 103 |
+
drawerOpen = !drawerOpen;
|
| 104 |
+
if (drawerOpen) drawer.classList.remove('drawer-hidden');
|
| 105 |
+
else drawer.classList.add('drawer-hidden');
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
async function sendConfig() {
|
| 109 |
await fetch('/apply_config', {
|
| 110 |
method: 'POST', headers: {'Content-Type': 'application/json'},
|
|
|
|
| 142 |
const r = await fetch('/state');
|
| 143 |
const d = await r.json();
|
| 144 |
|
| 145 |
+
// 1. Error Logic
|
| 146 |
const err = Math.abs(d.error);
|
| 147 |
document.getElementById('error-meter').innerText = d.error.toFixed(4);
|
| 148 |
document.getElementById('error-bar').style.width = Math.min(100, err * 2) + "%";
|
| 149 |
+
document.getElementById('error-meter').className = err < 0.1 ? "text-green-400 text-3xl font-bold" : "text-red-400 text-3xl font-bold";
|
| 150 |
|
| 151 |
+
// 2. Nodes/Forces Logic
|
| 152 |
let forceHTML = "";
|
| 153 |
let px=[], py=[], pz=[], ids=[];
|
| 154 |
Object.keys(d.nodes).forEach(id => {
|
| 155 |
const n = d.nodes[id];
|
| 156 |
+
const fColor = n.force > 0 ? "text-green-400" : "text-red-400";
|
| 157 |
+
forceHTML += `<div class="border-b border-slate-900 pb-1">NODE ${id}: <span class="text-white">X=${n.x.toFixed(2)}</span> | <span class="${fColor}">F=${n.force.toFixed(3)}</span> | K=${n.k.toFixed(3)}</div>`;
|
| 158 |
px.push(n.x); py.push(n.y); pz.push(n.z); ids.push(id);
|
| 159 |
});
|
| 160 |
document.getElementById('node-details').innerHTML = forceHTML;
|
| 161 |
document.getElementById('log-content').innerHTML = d.logs.map(l => `<div>${l}</div>`).join('');
|
| 162 |
|
| 163 |
+
// 3. Optimized Plotly Logic
|
| 164 |
const trace = {
|
| 165 |
type: 'scatter3d', mode: 'lines+markers+text',
|
| 166 |
x: px.concat([px[0]]), y: py.concat([py[0]]), z: pz.concat([pz[0]]),
|
| 167 |
+
text: ids.concat(['']),
|
| 168 |
+
marker: {size: 8, color: ['#fb923c','#c084fc','#38bdf8']},
|
| 169 |
+
line: {color: '#334155', width: 2}
|
| 170 |
};
|
| 171 |
const layout = {
|
| 172 |
+
margin: {l:0,r:0,t:0,b:0},
|
| 173 |
+
paper_bgcolor: 'transparent',
|
| 174 |
+
showlegend: false,
|
| 175 |
+
scene: {
|
| 176 |
+
xaxis: {range: [-5, 105], color: '#475569'},
|
| 177 |
+
yaxis: {range: [-3, 3], color: '#475569'},
|
| 178 |
+
zaxis: {range: [-3, 3], color: '#475569'},
|
| 179 |
+
camera: { eye: {x: 1.2, y: 1.2, z: 1.2} }
|
| 180 |
+
}
|
| 181 |
};
|
| 182 |
+
const config = { responsive: true, displayModeBar: false };
|
| 183 |
+
|
| 184 |
+
if(!window.plotted){
|
| 185 |
+
Plotly.newPlot('plot', [trace], layout, config);
|
| 186 |
+
window.plotted=true;
|
| 187 |
+
} else {
|
| 188 |
+
Plotly.react('plot', [trace], layout, config);
|
| 189 |
+
}
|
| 190 |
|
| 191 |
} catch(e) {}
|
| 192 |
+
}, 200);
|
| 193 |
</script>
|
| 194 |
</body>
|
| 195 |
</html>
|