-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
70 lines (66 loc) · 3.29 KB
/
Copy pathindex.html
File metadata and controls
70 lines (66 loc) · 3.29 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
70
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Lishyy - URL Shortener</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body class="bg-slate-900 text-white min-h-screen">
<nav class="fixed top-0 w-full bg-slate-800 border-b border-slate-700 z-50">
<div class="max-w-4xl mx-auto px-4 py-3 flex justify-between items-center">
<a href="/" class="text-xl font-bold">Lishyy</a>
<button id="menuBtn" class="md:hidden">☰</button>
<div id="navLinks" class="hidden md:flex space-x-6 text-sm text-slate-300">
<a href="/about" class="hover:text-white">About</a>
<a href="/contact" class="hover:text-white">Contact</a>
<a href="/privacy" class="hover:text-white">Privacy</a>
<a href="/terms" class="hover:text-white">Terms</a>
</div>
</div>
<div id="mobileMenu" class="hidden md:hidden bg-slate-800 p-4 border-t border-slate-700 flex flex-col space-y-2">
<a href="/about">About</a>
<a href="/contact">Contact</a>
<a href="/privacy">Privacy</a>
<a href="/terms">Terms</a>
</div>
</nav>
<main class="pt-24 px-4 flex items-center justify-center">
<div class="bg-slate-800 p-8 rounded-xl shadow-2xl w-full max-w-md text-center">
<h1 class="text-2xl font-bold mb-6">Shorten your link</h1>
<input id="url" type="url" placeholder="Paste your long URL here..." class="w-full p-3 rounded bg-slate-700 border border-slate-600 mb-4 focus:outline-none focus:border-blue-500">
<input id="slug" type="text" placeholder="Custom slug (optional)" class="w-full p-3 rounded bg-slate-700 border border-slate-600 mb-4 focus:outline-none focus:border-blue-500">
<button id="btn" class="w-full bg-blue-500 hover:bg-blue-600 p-3 rounded font-bold transition">Shorten URL</button>
<div id="result" class="hidden mt-6 p-4 bg-slate-700 rounded break-words">
<p class="text-sm mb-2 text-slate-300">Your shortened link:</p>
<a id="link" target="_blank" class="text-blue-400 underline"></a>
</div>
</div>
</main>
<script>
// Toggle mobile menu
document.getElementById('menuBtn').onclick = () => {
document.getElementById('mobileMenu').classList.toggle('hidden');
};
// Shorten logic
document.getElementById('btn').onclick = async () => {
const url = document.getElementById('url').value;
const slug = document.getElementById('slug').value;
const res = await fetch('/api/shorten', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ url, slug })
});
const data = await res.json();
if (res.ok) {
const link = document.getElementById('link');
link.href = data.shortUrl;
link.innerText = data.shortUrl;
document.getElementById('result').classList.remove('hidden');
} else {
alert(data.error);
}
};
</script>
</body>
</html>