// Main application script
document.addEventListener('DOMContentLoaded', function() {
// Initialize tooltips
const tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
const tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
// Copy to clipboard functionality
function copyToClipboard(text) {
navigator.clipboard.writeText(text).then(function() {
// Show success message
showNotification('Copied to clipboard!', 'success');
}).catch(function(err) {
console.error('Failed to copy: ', err);
showNotification('Failed to copy to clipboard', 'error');
});
}
// Notification system
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.className = `fixed top-4 right-4 z-50 p-4 rounded-lg shadow-lg transform transition-all duration-300 ${
type === 'success' ? 'bg-green-600' :
type === 'error' ? 'bg-red-600' : 'bg-blue-600'
}`;
notification.innerHTML = `
${message}
`;
document.body.appendChild(notification);
feather.replace();
setTimeout(() => {
notification.remove();
}, 3000);
}
// Export functionality
window.exportAdData = function() {
const adData = {
adId: '7739201',
adName: 'Auto Insurance December Campaign',
status: 'Active',
finalUrl: 'https://example.com/auto-insurance?utm_source=quora&utm_campaign=auto_insurance_dec&utm_content=ad_7739201'
};
const blob = new Blob([JSON.stringify(adData, null, 2)], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `ad-data-${adData.adId}.json`;
a.click();
URL.revokeObjectURL(url);
showNotification('Ad data exported successfully!', 'success');
};
// Share functionality
window.shareAd = function() {
if (navigator.share) {
navigator.share({
title: 'Quora Ad Details',
text: 'Check out this Quora ad campaign',
url: window.location.href
}).then(() => {
showNotification('Shared successfully!', 'success');
}).catch(console.error);
} else {
copyToClipboard(window.location.href);
}
};
// Theme toggle (though we're sticking with dark mode)
window.toggleTheme = function() {
const html = document.documentElement;
html.classList.toggle('dark');
showNotification(`Theme switched to ${html.classList.contains('dark') ? 'dark' : 'light'} mode`);
};
// Initialize animations
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('fade-in');
}
});
}, observerOptions);
// Observe all cards for animation
document.querySelectorAll('.card-hover').forEach(card => {
observer.observe(card);
});
});