87 lines
4.2 KiB
HTML
87 lines
4.2 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>zig-p2p Browser Demo</title>
|
|
<style>
|
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
body { font-family: system-ui, sans-serif; max-width: 720px; margin: 2rem auto; padding: 0 1rem; }
|
|
h1 { margin-bottom: 1rem; }
|
|
.section { margin-bottom: 1.5rem; }
|
|
label { font-weight: 600; display: block; margin-bottom: .25rem; }
|
|
input, button { font-size: .95rem; padding: .4rem .6rem; }
|
|
input[type="text"] { width: 100%; margin-bottom: .5rem; }
|
|
button { cursor: pointer; margin-right: .5rem; }
|
|
#status { padding: .5rem; border-radius: 4px; background: #f0f0f0; font-family: monospace; font-size: .85rem; }
|
|
#log { height: 300px; overflow-y: auto; border: 1px solid #ccc; border-radius: 4px; padding: .5rem; font-family: monospace; font-size: .82rem; background: #fafafa; }
|
|
.log-entry { padding: 2px 0; border-bottom: 1px solid #eee; }
|
|
.log-entry.sent { color: #0066cc; }
|
|
.log-entry.recv { color: #009900; }
|
|
.log-entry.info { color: #666; }
|
|
.log-entry.error { color: #cc0000; }
|
|
#transferList { margin-top: .75rem; }
|
|
.transfer-entry { border: 1px solid #ddd; border-radius: 6px; padding: .6rem .8rem; margin-bottom: .5rem; background: #fafafa; }
|
|
.transfer-entry .te-header { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; margin-bottom: .25rem; }
|
|
.transfer-entry .te-header .te-label { font-weight: 600; }
|
|
.transfer-entry .te-header .te-status { color: #e67e00; font-weight: 600; }
|
|
.transfer-entry .te-info { font-family: monospace; font-size: .82rem; color: #555; margin-bottom: .3rem; }
|
|
.progress-bar { height: 14px; background: #e0e0e0; border-radius: 7px; overflow: hidden; }
|
|
.progress-fill { height: 100%; background: #4caf50; border-radius: 7px; transition: width .15s; }
|
|
.progress-fill.paused { background: #e67e00; }
|
|
.progress-fill.completed { background: #2196f3; }
|
|
.transfer-controls { margin-top: .35rem; }
|
|
.transfer-controls button { font-size: .8rem; padding: .2rem .5rem; margin-right: .3rem; cursor: pointer; }
|
|
.cancel-btn { color: #cc0000; border-color: #cc0000; }
|
|
.transfer-entry.completed { background: #f0f8f0; border-color: #a0d0a0; }
|
|
.transfer-entry.completed a { color: #0066cc; font-weight: 600; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>zig-p2p Browser Demo</h1>
|
|
|
|
<div class="section" id="status">
|
|
Status: <span id="statusText">Not connected</span> |
|
|
Peer ID: <span id="peerId">—</span> |
|
|
Channels: <span id="channels">0</span>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<label>Signaling Server</label>
|
|
<input type="text" id="signalingUrl" value="ws://localhost:8080">
|
|
<button id="connectBtn" onclick="doConnect()">Connect</button>
|
|
<button id="disconnectBtn" onclick="doDisconnect()" disabled>Disconnect</button>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<label>Connect to Peer</label>
|
|
<input type="text" id="remotePeerId" placeholder="Enter remote peer ID">
|
|
<button id="peerBtn" onclick="doConnectPeer()" disabled>Connect to Peer</button>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<label>Send Message</label>
|
|
<input type="text" id="msgInput" placeholder="Type a message..." onkeydown="if(event.key==='Enter')doSend()">
|
|
<button id="sendBtn" onclick="doSend()" disabled>Send</button>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<label>File Transfer</label>
|
|
<input type="file" id="fileInput">
|
|
<button id="shareBtn" onclick="doShareFile()" disabled>Share File</button>
|
|
<div id="fileStatus" style="margin-top:.5rem;font-family:monospace;font-size:.85rem"></div>
|
|
<div id="fileOffers" style="margin-top:.5rem"></div>
|
|
<div id="transferList"></div>
|
|
</div>
|
|
|
|
<div class="section">
|
|
<label>Log</label>
|
|
<div id="log"></div>
|
|
<button onclick="document.getElementById('log').innerHTML=''" style="margin-top:.5rem">Clear</button>
|
|
<button onclick="navigator.clipboard.writeText(document.getElementById('log').innerText).then(()=>{this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)})" style="margin-top:.5rem">Copy</button>
|
|
</div>
|
|
|
|
<script type="module" src="demo.js"></script>
|
|
</body>
|
|
</html>
|