225 lines
6.5 KiB
HTML
225 lines
6.5 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">
|
|
<title>JARVIS</title>
|
|
<style>
|
|
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
|
:root {
|
|
--bg: #07090f;
|
|
--card: rgba(255,255,255,0.04);
|
|
--border: rgba(255,255,255,0.08);
|
|
--accent: #6366f1;
|
|
--adim: rgba(99,102,241,0.15);
|
|
--text: #dde3ed;
|
|
--muted: #5e6a7e;
|
|
}
|
|
html, body {
|
|
height: 100%;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
}
|
|
.card {
|
|
width: 340px;
|
|
padding: 44px 36px;
|
|
background: var(--card);
|
|
border: 1px solid var(--border);
|
|
border-radius: 22px;
|
|
text-align: center;
|
|
}
|
|
.logo {
|
|
font-size: 28px;
|
|
font-weight: 700;
|
|
letter-spacing: 10px;
|
|
margin-bottom: 6px;
|
|
}
|
|
.logo em { color: var(--accent); font-style: normal; }
|
|
.sub {
|
|
font-size: 11px;
|
|
color: var(--muted);
|
|
letter-spacing: 3px;
|
|
text-transform: uppercase;
|
|
margin-bottom: 10px;
|
|
}
|
|
.hint {
|
|
font-size: 12px;
|
|
color: var(--muted);
|
|
line-height: 1.55;
|
|
margin-bottom: 28px;
|
|
}
|
|
.key-wrap {
|
|
position: relative;
|
|
margin-bottom: 16px;
|
|
}
|
|
.key-input {
|
|
width: 100%;
|
|
padding: 18px 14px;
|
|
background: rgba(255,255,255,0.05);
|
|
border: 1.5px solid var(--border);
|
|
border-radius: 14px;
|
|
color: var(--text);
|
|
font-size: 30px;
|
|
font-weight: 700;
|
|
font-family: 'Courier New', monospace;
|
|
text-align: center;
|
|
letter-spacing: 10px;
|
|
text-transform: uppercase;
|
|
outline: none;
|
|
transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
|
|
caret-color: var(--accent);
|
|
}
|
|
.key-input::placeholder {
|
|
color: rgba(94,106,126,0.5);
|
|
letter-spacing: 6px;
|
|
font-size: 20px;
|
|
}
|
|
.key-input:focus {
|
|
border-color: var(--accent);
|
|
background: var(--adim);
|
|
box-shadow: 0 0 0 3px rgba(99,102,241,0.12);
|
|
}
|
|
.err {
|
|
font-size: 12px;
|
|
color: #f87171;
|
|
min-height: 18px;
|
|
margin-bottom: 14px;
|
|
}
|
|
.btn {
|
|
width: 100%;
|
|
padding: 14px;
|
|
background: var(--accent);
|
|
color: #fff;
|
|
font-size: 12px;
|
|
font-weight: 700;
|
|
letter-spacing: 3px;
|
|
border: none;
|
|
border-radius: 12px;
|
|
cursor: pointer;
|
|
transition: opacity 0.15s, transform 0.1s;
|
|
}
|
|
.btn:hover { opacity: 0.88; }
|
|
.btn:active { transform: scale(0.98); }
|
|
@keyframes shake {
|
|
0%,100% { transform: translateX(0); }
|
|
20%,60% { transform: translateX(-7px); }
|
|
40%,80% { transform: translateX(7px); }
|
|
}
|
|
.shake { animation: shake 0.35s ease; }
|
|
.voice-note {
|
|
font-size: 10px;
|
|
color: var(--muted);
|
|
margin-top: 20px;
|
|
line-height: 1.6;
|
|
text-align: left;
|
|
}
|
|
.voice-note code {
|
|
background: rgba(255,255,255,0.07);
|
|
padding: 1px 4px;
|
|
border-radius: 3px;
|
|
font-family: 'Courier New', monospace;
|
|
font-size: 9px;
|
|
}
|
|
#reconnecting {
|
|
display: none;
|
|
color: var(--muted);
|
|
font-size: 12px;
|
|
margin-bottom: 16px;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="card" id="card">
|
|
<div class="logo"><em>J</em>ARVIS</div>
|
|
<div class="sub">Remote Access</div>
|
|
<p id="reconnecting">Reconnecting…</p>
|
|
<p class="hint">Press <strong style="color:var(--text)">Remote Control</strong> in the JARVIS desktop app to get a QR code or session key.</p>
|
|
<div class="key-wrap">
|
|
<input class="key-input" id="key" type="text" maxlength="6"
|
|
autocomplete="off" autocorrect="off" spellcheck="false"
|
|
placeholder="· · · · · ·">
|
|
</div>
|
|
<div class="err" id="err"></div>
|
|
<button class="btn" onclick="doLogin()">CONNECT</button>
|
|
<p class="voice-note">
|
|
🎤 <strong style="color:var(--text)">Voice commands:</strong> open
|
|
<code>chrome://flags</code> on your phone, search
|
|
<code>Insecure origins treated as secure</code>, add your JARVIS URL, tap Relaunch.
|
|
</p>
|
|
</div>
|
|
|
|
<script>
|
|
// Try auto-reconnect with stored device token (set on first QR login)
|
|
(async function() {
|
|
const devTok = localStorage.getItem('jarvis_device_token');
|
|
if (!devTok) return;
|
|
document.getElementById('reconnecting').style.display = 'block';
|
|
try {
|
|
const r = await fetch('/api/device-login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ device_token: devTok }),
|
|
});
|
|
const d = await r.json();
|
|
if (d.ok && d.token) {
|
|
sessionStorage.setItem('jarvis_key', d.key);
|
|
sessionStorage.setItem('jarvis_token', d.token);
|
|
location.replace('/');
|
|
return;
|
|
}
|
|
} catch (_) {}
|
|
// Device token rejected (server restarted) — clear it and show normal form
|
|
localStorage.removeItem('jarvis_device_token');
|
|
document.getElementById('reconnecting').style.display = 'none';
|
|
})();
|
|
|
|
const inp = document.getElementById('key');
|
|
inp.focus();
|
|
|
|
inp.addEventListener('input', () => {
|
|
inp.value = inp.value.toUpperCase().replace(/[^A-Z2-9]/g, '');
|
|
if (inp.value.length === 6) doLogin();
|
|
});
|
|
inp.addEventListener('keydown', e => { if (e.key === 'Enter') doLogin(); });
|
|
|
|
async function doLogin() {
|
|
const key = inp.value.trim();
|
|
if (key.length < 6) { shake(); return; }
|
|
let data;
|
|
try {
|
|
const r = await fetch('/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ pin: key })
|
|
});
|
|
data = await r.json();
|
|
} catch (e) {
|
|
document.getElementById('err').textContent = 'Connection error';
|
|
shake(); return;
|
|
}
|
|
if (data.ok && data.token) {
|
|
sessionStorage.setItem('jarvis_key', key);
|
|
sessionStorage.setItem('jarvis_token', data.token);
|
|
location.href = '/';
|
|
} else {
|
|
inp.value = '';
|
|
inp.focus();
|
|
document.getElementById('err').textContent = 'Invalid or expired key';
|
|
shake();
|
|
}
|
|
}
|
|
|
|
function shake() {
|
|
const c = document.getElementById('card');
|
|
c.classList.remove('shake');
|
|
void c.offsetWidth;
|
|
c.classList.add('shake');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|