$(document).ready(function() {
// URL shortening functionality
$('#shortenBtn').click(function() {
const longUrl = $('#longUrl').val().trim();
if (!longUrl) {
alert('Please enter a URL to shorten');
return;
}
// In a real app, you would call your backend API here
// For demo purposes, we'll just create a fake short URL
const fakeShortUrl = `https://zip.ly/${Math.random().toString(36).substring(2, 8)}`;
$('#shortUrl').val(fakeShortUrl);
$('#resultContainer').show();
});
// Copy to clipboard functionality
$('#copyBtn').click(function() {
const shortUrl = $('#shortUrl');
shortUrl.select();
document.execCommand('copy');
// Show feedback
const originalTitle = $(this).attr('title');
$(this).attr('title', 'Copied!');
setTimeout(() => {
$(this).attr('title', originalTitle);
}, 2000);
});
});