-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrack.html
More file actions
243 lines (230 loc) · 9.77 KB
/
track.html
File metadata and controls
243 lines (230 loc) · 9.77 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Midget Custom - Track URL Clicks</title>
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
},
extend: {
colors: {
primary: '#6366f1',
secondary: '#8b5cf6',
dark: '#0f172a',
light: '#f8fafc',
},
animation: {
'fade-in': 'fadeIn 0.5s ease-out',
'slide-up': 'slideUp 0.8s cubic-bezier(0.16, 1, 0.3, 1)'
},
keyframes: {
fadeIn: {
'0%': { opacity: 0 },
'100%': { opacity: 1 },
},
slideUp: {
'0%': { transform: 'translateY(20px)', opacity: 0 },
'100%': { transform: 'translateY(0)', opacity: 1 },
},
},
},
},
};
</script>
<!-- Font Awesome & Google Fonts -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet" />
</head>
<body class="bg-light flex flex-col min-h-screen">
<!-- Navigation -->
<nav class="bg-white/80 backdrop-blur-md shadow-sm fixed w-full z-50">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between items-center h-16">
<div class="flex items-center space-x-2">
<a href="index.html">
<div class="p-2 bg-primary rounded-lg shadow-lg">
<i class="fas fa-link text-white text-xl"></i>
</div>
</a>
<a href="index.html">
<span class="text-2xl font-bold text-dark">Midget</span>
</a>
</div>
<!-- Desktop Menu -->
<div class="hidden md:flex items-center space-x-8">
<a href="index.html" class="text-slate-600 hover:text-primary transition-colors">Home</a>
<a href="index.html" class="text-slate-600 hover:text-primary transition-colors">Features</a>
<a href="index.html" class="text-slate-600 hover:text-primary transition-colors">Contact</a>
</div>
<!-- Mobile Menu Button -->
<button id="mobile-menu" class="md:hidden p-2 rounded-lg hover:bg-slate-100" aria-expanded="false" aria-controls="mobile-menu-links">
<i class="fas fa-bars text-slate-600 text-xl"></i>
</button>
</div>
</div>
<!-- Mobile Menu Links -->
<div id="mobile-menu-links" class="hidden md:hidden bg-white shadow-sm">
<ul class="px-4 py-2">
<li class="py-2">
<a href="index.html" class="block text-slate-600 hover:text-primary transition-colors">Home</a>
</li>
<li class="py-2">
<a href="index.html" class="block text-slate-600 hover:text-primary transition-colors">Features</a>
</li>
<li class="py-2">
<a href="index.html" class="block text-slate-600 hover:text-primary transition-colors">Contact</a>
</li>
</ul>
</div>
</nav>
<script>
// Toggle mobile menu for accessibility
document.getElementById('mobile-menu').addEventListener('click', function () {
const menu = document.getElementById('mobile-menu-links');
menu.classList.toggle('hidden');
const expanded = this.getAttribute('aria-expanded') === 'true';
this.setAttribute('aria-expanded', !expanded);
});
</script>
<!-- Main Content -->
<main class="flex-grow container mx-auto px-4 py-32">
<div class="max-w-lg mx-auto bg-white rounded-xl shadow-lg p-8 animate-slide-up">
<h1 class="text-3xl font-bold text-dark mb-6 text-center">Track URL Clicks</h1>
<div class="mb-4">
<label for="shortUrlInput" class="block text-sm font-medium text-dark">
Enter your shortened URL
</label>
<input
type="text"
id="shortUrlInput"
placeholder="e.g., midget.pro/youralias"
class="mt-1 block w-full px-4 py-3 border border-primary/20 rounded-xl focus:ring-2 focus:ring-primary focus:outline-none text-dark"
/>
</div>
<button
id="trackButton"
class="w-full bg-primary text-white font-bold py-3 rounded hover:bg-secondary transition-all"
>
Track Clicks
</button>
<div id="result" class="mt-6 p-4 bg-green-100 text-green-800 rounded-lg hidden">
<p>
Total Click Count:
<span id="clickCount" class="font-bold"></span>
</p>
</div>
</div>
</main>
<!-- Footer -->
<footer class="bg-dark text-slate-300">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-12">
<div class="grid md:grid-cols-4 gap-8">
<!-- Brand Column -->
<div class="space-y-4">
<div class="flex items-center gap-3">
<div class="p-2 bg-primary rounded-lg">
<i class="fas fa-link text-white text-xl"></i>
</div>
<span class="text-2xl font-bold text-white">Midget</span>
</div>
<p class="text-sm">Modern URL Shortener that tracks your clicks effortlessly.</p>
<div class="flex gap-4">
<a href="#" class="hover:text-primary transition-colors">
<i class="fab fa-twitter text-xl"></i>
</a>
<a href="#" class="hover:text-primary transition-colors">
<i class="fab fa-github text-xl"></i>
</a>
<a href="#" class="hover:text-primary transition-colors">
<i class="fab fa-linkedin text-xl"></i>
</a>
</div>
</div>
<!-- Product Column -->
<div>
<h4 class="text-white font-semibold mb-4">Product</h4>
<ul class="space-y-2 text-sm">
<li><a href="#" class="hover:text-primary transition-colors">Features</a></li>
<li><a href="https://midget.pro" class="hover:text-primary transition-colors">Main Site</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Custom API</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Integrations</a></li>
</ul>
</div>
<!-- Resources Column -->
<div>
<h4 class="text-white font-semibold mb-4">Resources</h4>
<ul class="space-y-2 text-sm">
<li><a href="#" class="hover:text-primary transition-colors">Documentation</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Blog</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Help Center</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Status</a></li>
</ul>
</div>
<!-- Legal Column -->
<div>
<h4 class="text-white font-semibold mb-4">Legal</h4>
<ul class="space-y-2 text-sm">
<li><a href="#" class="hover:text-primary transition-colors">Privacy Policy</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Terms of Service</a></li>
<li><a href="#" class="hover:text-primary transition-colors">Cookie Policy</a></li>
<li><a href="#" class="hover:text-primary transition-colors">GDPR</a></li>
</ul>
</div>
</div>
<div class="border-t border-slate-800 mt-8 pt-8 text-center text-sm text-slate-400">
<p>© 2025 Midget. All rights reserved.</p>
</div>
</div>
</footer>
<!-- Supabase and Tracking Logic -->
<script type="module">
import { createClient } from 'https://cdn.jsdelivr.net/npm/@supabase/supabase-js/+esm';
// Replace with your actual Supabase URL and Anon Key for the custom site
const SUPABASE_URL = 'https://nauwlyivjdzbuqarrxmf.supabase.co';
const SUPABASE_ANON_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Im5hdXdseWl2amR6YnVxYXJyeG1mIiwicm9sZSI6ImFub24iLCJpYXQiOjE3Mzg2NjI2OTUsImV4cCI6MjA1NDIzODY5NX0.YxqnVIauv2LWUIEWtBi7lSluUqTy6P2BwereAYNHgF8';
const supabase = createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
const trackButton = document.getElementById('trackButton');
const resultDiv = document.getElementById('result');
const clickCountSpan = document.getElementById('clickCount');
trackButton.addEventListener('click', async () => {
const shortUrlInput = document.getElementById('shortUrlInput').value.trim();
if (!shortUrlInput) {
alert('Please enter a shortened URL.');
return;
}
// Extract the alias from the URL (assumes format: domain/alias)
const urlParts = shortUrlInput.split('/');
const alias = urlParts[urlParts.length - 1];
// Query the custom_urls table for click count
const { data: customData, error: customError } = await supabase
.from('custom_urls')
.select('click_count')
.eq('custom_alias', alias)
.single();
// Query the main_urls table for click count
const { data: mainData, error: mainError } = await supabase
.from('main_urls')
.select('click_count')
.eq('short_url', alias)
.single();
// Handle errors (if both queries return errors, treat as not found)
if ((customError && !customData) && (mainError && !mainData)) {
alert('URL not found or an error occurred.');
resultDiv.classList.add('hidden');
return;
}
const customClicks = customData ? customData.click_count : 0;
const mainClicks = mainData ? mainData.click_count : 0;
const totalClicks = customClicks + mainClicks;
clickCountSpan.textContent = totalClicks;
resultDiv.classList.remove('hidden');
});
</script>
</body>
</html>