`;
feather.replace();
}
}
// Load Features from Public API
async function loadFeatures() {
const featuresContainer = document.querySelector('.features-section .grid');
if (!featuresContainer) return;
try {
// Using NASA APOD API for demonstration
const response = await fetch('https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&count=6');
const features = await response.json();
featuresContainer.innerHTML = features.map((feature, index) => `
`);
// Simulate AI response after delay
setTimeout(() => {
document.querySelector('.typing-indicator')?.remove();
// Using public AI API (example with DeepAI)
fetchAIResponse(message).then(response => {
chatInterface.insertAdjacentHTML('beforeend', `
${response}
`);
// Scroll to bottom
chatInterface.scrollTop = chatInterface.scrollHeight;
});
}, 1500);
}
async function fetchAIResponse(message) {
try {
// Using OpenAI-like API (example)
const response = await fetch('https://api.deepai.org/api/text-generator', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'api-key': 'quickstart-QUdJIGlzIGNvbWluZy4uLi4K',
},
body: JSON.stringify({
text: message,
model: 'gpt-3'
})
});
const data = await response.json();
return data.output || "I'm processing your request. Please try again.";
} catch (error) {
return "I apologize, but I'm having trouble processing your request right now.";
}
}
// Utility Functions
function getRandomIcon() {
const icons = ['star', 'moon', 'sun', 'cloud', 'compass', 'zap', 'heart', 'cpu', 'globe', 'eye'];
return icons[Math.floor(Math.random() * icons.length)];
}
function openFeatureModal(index) {
const modal = document.createElement('div');
modal.className = 'fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm';
modal.innerHTML = `