rmscript-demo / frontend /index.html
dlouapre's picture
dlouapre HF Staff
First commit
65da30d
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>RMScript Web Demo</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
padding: 20px;
}
.container {
max-width: 1400px;
margin: 0 auto;
background: white;
border-radius: 20px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
overflow: hidden;
display: grid;
grid-template-columns: 1fr 1fr;
gap: 0;
}
.panel {
padding: 30px;
}
.panel.editor-panel {
border-right: 1px solid #e0e0e0;
}
h1 {
color: #333;
margin-bottom: 10px;
font-size: 24px;
}
.subtitle {
color: #666;
margin-bottom: 20px;
font-size: 14px;
}
.status {
padding: 12px;
border-radius: 8px;
margin-bottom: 15px;
font-size: 14px;
display: flex;
justify-content: space-between;
align-items: center;
}
.status.idle {
background: #f5f5f5;
color: #666;
}
.status.success {
background: #d4edda;
color: #155724;
}
.status.error {
background: #f8d7da;
color: #721c24;
}
.status.connected {
background: #d4edda;
color: #155724;
}
.status.disconnected {
background: #f8d7da;
color: #721c24;
}
.status-dot {
width: 10px;
height: 10px;
border-radius: 50%;
margin-right: 8px;
display: inline-block;
}
.status-dot.green {
background: #28a745;
box-shadow: 0 0 10px #28a745;
}
.status-dot.red {
background: #dc3545;
}
.status-dot.gray {
background: #999;
}
.editor {
width: 100%;
min-height: 400px;
padding: 15px;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
font-size: 14px;
border: 2px solid #e0e0e0;
border-radius: 8px;
resize: vertical;
margin-bottom: 15px;
line-height: 1.5;
}
.editor:focus {
outline: none;
border-color: #667eea;
}
.button-group {
display: flex;
gap: 10px;
margin-bottom: 20px;
}
button {
background: #667eea;
color: white;
border: none;
padding: 12px 24px;
border-radius: 8px;
font-size: 14px;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
flex: 1;
}
button:hover:not(:disabled) {
background: #5568d3;
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}
button:active:not(:disabled) {
transform: translateY(0);
}
button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
button.secondary {
background: #6c757d;
}
button.secondary:hover:not(:disabled) {
background: #5a6268;
}
button.danger {
background: #dc3545;
}
button.danger:hover:not(:disabled) {
background: #c82333;
}
.console {
background: #1e1e1e;
color: #d4d4d4;
padding: 15px;
border-radius: 8px;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
font-size: 12px;
max-height: 300px;
overflow-y: auto;
line-height: 1.6;
}
.console-line {
margin-bottom: 4px;
}
.console-line.error {
color: #f48771;
}
.console-line.warning {
color: #dcdcaa;
}
.console-line.success {
color: #4ec9b0;
}
.console-line.info {
color: #9cdcfe;
}
.section-title {
font-size: 16px;
font-weight: 600;
color: #333;
margin-bottom: 10px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.example-buttons {
display: flex;
gap: 8px;
margin-bottom: 15px;
flex-wrap: wrap;
}
.example-buttons button {
flex: 0 1 auto;
padding: 8px 16px;
font-size: 12px;
}
.ir-display {
background: #f8f9fa;
padding: 15px;
border-radius: 8px;
max-height: 300px;
overflow-y: auto;
font-size: 13px;
margin-top: 15px;
}
.ir-action {
background: white;
padding: 10px;
margin-bottom: 8px;
border-radius: 4px;
border-left: 4px solid #667eea;
}
.ir-action-type {
font-weight: 600;
color: #667eea;
margin-bottom: 4px;
}
.ir-action-details {
font-size: 12px;
color: #666;
font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
}
</style>
</head>
<body>
<div class="container">
<!-- Left Panel: Editor -->
<div class="panel editor-panel">
<h1>🤖 RMScript Editor</h1>
<p class="subtitle">Write and test your rmscript code</p>
<div id="compileStatus" class="status idle">
<span><span class="status-dot gray"></span>Ready</span>
</div>
<div class="section-title">Examples</div>
<div class="example-buttons">
<button class="secondary" onclick="loadExample('basic')">Basic</button>
<button class="secondary" onclick="loadExample('complex')">Complex</button>
<button class="secondary" onclick="loadExample('repeat')">Repeat</button>
<button class="secondary" onclick="clearEditor()">Clear</button>
</div>
<textarea id="editor" class="editor" placeholder="DESCRIPTION My robot script
look left
wait 1s
look right"></textarea>
<div class="button-group">
<button onclick="verifyScript()">✓ Verify</button>
<button id="executeBtn" onclick="executeScript()" disabled>â–¶ Execute</button>
</div>
<div class="section-title">Console</div>
<div id="console" class="console">
<div class="console-line info">Ready. Write some rmscript and click Verify!</div>
</div>
</div>
<!-- Right Panel: Robot Control -->
<div class="panel">
<h1>🔗 Robot Connection</h1>
<p class="subtitle">Connect to Reachy Mini on localhost:8000</p>
<div id="robotStatus" class="status disconnected">
<span><span class="status-dot red"></span>Disconnected</span>
</div>
<div class="section-title">Compiled IR</div>
<div id="irDisplay" class="ir-display">
<div style="color: #999; text-align: center; padding: 20px;">
No IR yet. Verify a script first!
</div>
</div>
<div class="section-title" style="margin-top: 20px;">Execution Info</div>
<div id="executionInfo" class="console" style="max-height: 150px;">
<div class="console-line info">Ready to execute when robot is connected</div>
</div>
</div>
</div>
<!-- Load app.js with path that works both locally (file://) and on server -->
<script>
// Auto-detect correct path for app.js
const scriptSrc = window.location.protocol === 'file:'
? './app.js' // Local file access
: '/static/app.js'; // Served from web server
const script = document.createElement('script');
script.src = scriptSrc;
document.head.appendChild(script);
</script>
</body>
</html>