d07005bde3
Addresses two Major findings from PR review: - Auth lockout no longer griefable: the throttle key is namespaced per path and includes the client IP (web:<session>:<ip> vs desktop:<session>:<ip>), so a flood of bad web-client auths can neither lock other clients of the same session nor block the desktop from (re)authenticating. Per-socket failure close and brute-force lockout are preserved. - Relay web client XSS eliminated: app.html tab/macro rendering rebuilt with createElement/textContent (no macro/tab value reaches innerHTML); inline scripts/handlers externalized to /static/app.js and /static/login.js so the helmet CSP now uses script-src 'self' (dropped 'unsafe-inline' for scripts). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
283 lines
8.1 KiB
HTML
283 lines
8.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, viewport-fit=cover">
|
|
<meta name="theme-color" content="#007acc">
|
|
<meta name="description" content="Remote macro control for your desktop">
|
|
|
|
<!-- PWA / iOS specific -->
|
|
<meta name="mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
|
<meta name="apple-mobile-web-app-title" content="MacroPad">
|
|
|
|
<title>MacroPad</title>
|
|
|
|
<!-- PWA manifest will be dynamically set -->
|
|
<link rel="manifest" id="manifest-link">
|
|
<link rel="icon" type="image/png" href="/static/icons/favicon.png">
|
|
<link rel="icon" type="image/png" sizes="192x192" href="/static/icons/icon-192.png">
|
|
<link rel="apple-touch-icon" href="/static/icons/icon-192.png">
|
|
|
|
<style>
|
|
:root {
|
|
--bg-color: #2e2e2e;
|
|
--fg-color: #ffffff;
|
|
--highlight-color: #3e3e3e;
|
|
--accent-color: #007acc;
|
|
--button-bg: #505050;
|
|
--button-hover: #606060;
|
|
--tab-bg: #404040;
|
|
--tab-selected: #007acc;
|
|
--danger-color: #dc3545;
|
|
--success-color: #28a745;
|
|
}
|
|
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
background-color: var(--bg-color);
|
|
color: var(--fg-color);
|
|
min-height: 100vh;
|
|
min-height: 100dvh;
|
|
}
|
|
|
|
.header {
|
|
background-color: var(--highlight-color);
|
|
padding: 1rem;
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
position: sticky;
|
|
top: 0;
|
|
z-index: 100;
|
|
}
|
|
|
|
.header h1 { font-size: 1.5rem; }
|
|
|
|
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
|
|
|
|
.connection-status {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
font-size: 0.8rem;
|
|
color: #aaa;
|
|
}
|
|
|
|
.status-dot {
|
|
width: 8px;
|
|
height: 8px;
|
|
border-radius: 50%;
|
|
background: var(--danger-color);
|
|
}
|
|
|
|
.status-dot.connected { background: var(--success-color); }
|
|
|
|
.header-btn {
|
|
background: var(--button-bg);
|
|
color: white;
|
|
border: none;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.header-btn:hover { background: var(--button-hover); }
|
|
|
|
.header-btn.icon-btn {
|
|
padding: 0.5rem 0.75rem;
|
|
font-size: 1.2rem;
|
|
}
|
|
|
|
.wake-lock-status {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0.25rem 0.5rem;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
transition: background 0.2s;
|
|
}
|
|
|
|
.wake-lock-status:hover { background: var(--button-bg); }
|
|
.wake-lock-status.active .wake-icon { color: var(--success-color); }
|
|
.wake-lock-status.unsupported { opacity: 0.3; cursor: default; }
|
|
.wake-lock-status.unsupported .wake-icon { color: #888; text-decoration: line-through; }
|
|
|
|
.wake-icon {
|
|
font-size: 1.2rem;
|
|
color: #888;
|
|
transition: color 0.2s;
|
|
}
|
|
|
|
.tabs {
|
|
display: flex;
|
|
gap: 0.25rem;
|
|
padding: 0.5rem 1rem;
|
|
overflow-x: auto;
|
|
}
|
|
|
|
.tab {
|
|
background: var(--tab-bg);
|
|
color: var(--fg-color);
|
|
border: none;
|
|
padding: 0.5rem 1rem;
|
|
border-radius: 4px;
|
|
cursor: pointer;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.tab:hover { background: var(--button-hover); }
|
|
.tab.active { background: var(--tab-selected); }
|
|
|
|
.macro-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
|
gap: 1rem;
|
|
padding: 1rem;
|
|
}
|
|
|
|
.macro-card {
|
|
background: var(--button-bg);
|
|
border-radius: 8px;
|
|
padding: 1rem;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
cursor: pointer;
|
|
transition: transform 0.1s, background 0.2s;
|
|
min-height: 120px;
|
|
}
|
|
|
|
.macro-card:hover { background: var(--button-hover); transform: translateY(-2px); }
|
|
.macro-card:active { transform: translateY(0); }
|
|
|
|
.macro-card.executing {
|
|
animation: pulse 0.3s ease-in-out;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0% { transform: scale(1); }
|
|
50% { transform: scale(0.95); background: var(--accent-color); }
|
|
100% { transform: scale(1); }
|
|
}
|
|
|
|
.macro-image {
|
|
width: 64px;
|
|
height: 64px;
|
|
object-fit: contain;
|
|
margin-bottom: 0.5rem;
|
|
border-radius: 4px;
|
|
}
|
|
|
|
.macro-image-placeholder {
|
|
width: 64px;
|
|
height: 64px;
|
|
background: var(--highlight-color);
|
|
border-radius: 4px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 1.5rem;
|
|
}
|
|
|
|
.macro-name {
|
|
text-align: center;
|
|
font-size: 0.9rem;
|
|
word-break: break-word;
|
|
}
|
|
|
|
.empty-state {
|
|
text-align: center;
|
|
padding: 3rem 1rem;
|
|
color: #888;
|
|
grid-column: 1 / -1;
|
|
}
|
|
|
|
.toast-container {
|
|
position: fixed;
|
|
bottom: 1rem;
|
|
right: 1rem;
|
|
z-index: 300;
|
|
}
|
|
|
|
.toast {
|
|
background: var(--highlight-color);
|
|
padding: 0.75rem 1rem;
|
|
border-radius: 4px;
|
|
margin-top: 0.5rem;
|
|
animation: slideIn 0.3s ease-out;
|
|
}
|
|
|
|
.toast.success { border-left: 4px solid var(--success-color); }
|
|
.toast.error { border-left: 4px solid var(--danger-color); }
|
|
|
|
@keyframes slideIn {
|
|
from { transform: translateX(100%); opacity: 0; }
|
|
to { transform: translateX(0); opacity: 1; }
|
|
}
|
|
|
|
.loading {
|
|
display: flex;
|
|
justify-content: center;
|
|
padding: 2rem;
|
|
grid-column: 1 / -1;
|
|
}
|
|
|
|
.spinner {
|
|
width: 40px;
|
|
height: 40px;
|
|
border: 3px solid var(--button-bg);
|
|
border-top-color: var(--accent-color);
|
|
border-radius: 50%;
|
|
animation: spin 1s linear infinite;
|
|
}
|
|
|
|
@keyframes spin { to { transform: rotate(360deg); } }
|
|
|
|
.offline-banner {
|
|
background: var(--danger-color);
|
|
color: white;
|
|
text-align: center;
|
|
padding: 0.5rem;
|
|
display: none;
|
|
}
|
|
|
|
.offline-banner.visible { display: block; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="offline-banner" id="offline-banner">
|
|
Desktop is offline - waiting for reconnection...
|
|
</div>
|
|
|
|
<header class="header">
|
|
<h1>MacroPad</h1>
|
|
<div class="header-actions">
|
|
<div class="connection-status">
|
|
<div class="status-dot"></div>
|
|
<span>Connecting...</span>
|
|
</div>
|
|
<div class="wake-lock-status" id="wake-lock-status" title="Screen wake lock">
|
|
<span class="wake-icon">☀</span>
|
|
</div>
|
|
<button class="header-btn icon-btn" id="fullscreen-btn" title="Toggle fullscreen">⛶</button>
|
|
<button class="header-btn" id="refresh-btn">Refresh</button>
|
|
</div>
|
|
</header>
|
|
|
|
<nav class="tabs" id="tabs-container"></nav>
|
|
|
|
<main class="macro-grid" id="macro-grid">
|
|
<div class="loading"><div class="spinner"></div></div>
|
|
</main>
|
|
|
|
<div class="toast-container" id="toast-container"></div>
|
|
|
|
<script src="/static/app.js"></script>
|
|
</body>
|
|
</html>
|