-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
69 lines (62 loc) · 2.75 KB
/
index.html
File metadata and controls
69 lines (62 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>📱 Phone Name System</title>
<!-- TailwindCSS for styling -->
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet">
<style>
body { font-family: 'Inter', sans-serif; }
</style>
</head>
<body class="bg-gradient-to-br from-gray-100 to-blue-100 min-h-screen flex items-center justify-center">
<div class="bg-white shadow-2xl rounded-2xl p-10 max-w-md w-full text-center">
<h1 class="text-3xl font-bold mb-4 text-blue-600">📱 Phone Name System</h1>
<p class="text-gray-600 mb-6">Map phone numbers to human-readable names</p>
<div class="space-y-6">
<!-- Register -->
<div>
<h2 class="text-lg font-semibold text-gray-700">Register</h2>
<input id="handle" class="border rounded-lg w-full p-2 mt-2" placeholder="@username">
<input id="phone" class="border rounded-lg w-full p-2 mt-2" placeholder="+16175551234">
<button onclick="register()" class="bg-blue-600 text-white px-4 py-2 mt-3 rounded hover:bg-blue-700 w-full transition">Register</button>
</div>
<!-- Resolve -->
<div>
<h2 class="text-lg font-semibold text-gray-700">Resolve</h2>
<input id="number" class="border rounded-lg w-full p-2 mt-2" placeholder="+16175551234">
<button onclick="resolve()" class="bg-green-600 text-white px-4 py-2 mt-3 rounded hover:bg-green-700 w-full transition">Resolve</button>
</div>
</div>
<pre id="output" class="bg-gray-100 rounded-lg p-4 text-sm text-left mt-6 whitespace-pre-wrap"></pre>
</div>
<script>
const API_BASE = "https://pns-prototype.onrender.com";
async function register() {
const handle = document.getElementById('handle').value;
const phone = document.getElementById('phone').value;
try {
const res = await fetch(`${API_BASE}/register`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ handle, phone })
});
document.getElementById('output').innerText = await res.text();
} catch (err) {
document.getElementById('output').innerText = "❌ Connection error. Try again.";
}
}
async function resolve() {
const number = document.getElementById('number').value;
try {
const res = await fetch(`${API_BASE}/resolve?number=${number}`);
document.getElementById('output').innerText = await res.text();
} catch (err) {
document.getElementById('output').innerText = "❌ Connection error. Try again.";
}
}
</script>
</body>
</html>