dymic's picture
Loved it but i want more advanced and bugs free website at looking so redesign it
d7b43d8 verified
Raw History Blame Contribute Delete
13.4 kB
// Enhanced Typewriter Effect with multiple phrases
const typewriterPhrases = [
"12 Years of Technical Excellence",
"Enterprise-Grade Solutions",
"Cutting-Edge Digital Architectures"
];
const typewriterElement = document.getElementById('typewriter');
let phraseIndex = 0;
let charIndex = 0;
let isDeleting = false;
let typingSpeed = 100;
function typeWriter() {
const currentPhrase = typewriterPhrases[phraseIndex];
if (isDeleting) {
typewriterElement.innerHTML = currentPhrase.substring(0, charIndex - 1);
charIndex--;
typingSpeed = 50;
} else {
typewriterElement.innerHTML = currentPhrase.substring(0, charIndex + 1);
charIndex++;
typingSpeed = 100;
}
if (!isDeleting && charIndex === currentPhrase.length) {
typingSpeed = 1500;
isDeleting = true;
} else if (isDeleting && charIndex === 0) {
isDeleting = false;
phraseIndex = (phraseIndex + 1) % typewriterPhrases.length;
typingSpeed = 500;
}
setTimeout(typeWriter, typingSpeed);
}
// Initialize with error handling
document.addEventListener('DOMContentLoaded', async () => {
try {
typeWriter();
await Promise.all([
loadProjects(),
loadOrders(),
loadBlogPosts()
]);
setupIntersectionObservers();
setupAdminAccess();
} catch (error) {
console.error('Initialization error:', error);
showErrorToast('Failed to load page content');
}
});
// Fetch projects from API with caching
async function fetchProjects() {
const cacheKey = 'projectsCache';
const cacheTime = 3600000; // 1 hour
try {
// Check cache first
const cached = localStorage.getItem(cacheKey);
if (cached) {
const { data, timestamp } = JSON.parse(cached);
if (Date.now() - timestamp < cacheTime) {
return data;
}
}
// Fetch from API (mock API for demonstration)
const response = await fetch('https://api.mocki.io/v2/1a1f1d1a/projects');
if (!response.ok) throw new Error('Failed to fetch projects');
const data = await response.json();
// Cache the response
localStorage.setItem(cacheKey, JSON.stringify({
data,
timestamp: Date.now()
}));
return data;
} catch (error) {
console.error('Project fetch error:', error);
// Fallback to local data
return [
{
title: "Enterprise Cloud Migration",
description: "Seamless transition to AWS for Fortune 500 company",
image: "http://static.photos/technology/640x360/1",
tags: ["AWS", "Migration", "DevOps"]
},
{
title: "AI-Powered Analytics",
description: "Machine learning platform for real-time business insights",
image: "http://static.photos/abstract/640x360/2",
tags: ["AI", "Machine Learning", "Data"]
},
{
title: "Blockchain Security",
description: "Decentralized identity verification system",
image: "http://static.photos/minimal/640x360/3",
tags: ["Blockchain", "Security", "Web3"]
},
{
title: "IoT Fleet Management",
description: "Connected vehicle platform with predictive maintenance",
image: "http://static.photos/technology/640x360/4",
tags: ["IoT", "Automotive", "Predictive"]
},
{
title: "Digital Banking Platform",
description: "Next-gen mobile banking with biometric auth",
image: "http://static.photos/finance/640x360/5",
tags: ["Fintech", "Banking", "Mobile"]
},
{
title: "Healthcare Data Hub",
description: "HIPAA-compliant patient data management system",
image: "http://static.photos/medical/640x360/6",
tags: ["Healthcare", "HIPAA", "Data"]
}
];
}
}
// Load Projects with Intersection Observer
async function loadProjects() {
try {
const container = document.getElementById('projects-container');
container.innerHTML = '<div class="col-span-1 md:col-span-2 lg:col-span-3 flex justify-center py-12"><div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-accent"></div></div>';
const projects = await fetchProjects();
container.innerHTML = '';
projects.forEach((project, index) => {
const projectElement = document.createElement('div');
projectElement.className = 'project-card opacity-0 transform translate-y-10 transition-all duration-500 ease-out bg-secondary/50 rounded-xl overflow-hidden border border-gray-700/50 hover:border-accent/50 hover:shadow-lg hover:shadow-accent/10';
projectElement.dataset.index = index;
projectElement.innerHTML = `
<div class="relative overflow-hidden h-48 group">
<img src="${project.image}" alt="${project.title}"
class="w-full h-full object-cover transition-transform duration-700 group-hover:scale-110"
loading="lazy">
<div class="absolute inset-0 bg-gradient-to-t from-black/90 via-transparent to-transparent flex items-end p-6">
<div>
<h3 class="text-xl font-bold">${project.title}</h3>
<p class="text-gray-300 mb-2">${project.description}</p>
<div class="flex flex-wrap gap-2 mt-2">
${project.tags.map(tag => `<span class="text-xs bg-primary/50 text-accent px-2 py-1 rounded">${tag}</span>`).join('')}
</div>
</div>
</div>
<div class="absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity duration-300 bg-black/50">
<button class="bg-accent text-white px-4 py-2 rounded-lg font-medium hover:bg-blue-600 transition-colors">
View Case Study
</button>
</div>
</div>
`;
container.appendChild(projectElement);
});
} catch (error) {
console.error('Error loading projects:', error);
showErrorToast('Failed to load projects');
}
}
// Intersection Observers for animations
function setupIntersectionObservers() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -100px 0px'
};
// Project cards observer
const projectObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
const delay = parseInt(entry.target.dataset.index) * 100;
setTimeout(() => {
entry.target.classList.remove('opacity-0', 'translate-y-10');
}, delay);
projectObserver.unobserve(entry.target);
}
});
}, observerOptions);
document.querySelectorAll('.project-card').forEach(card => {
projectObserver.observe(card);
});
// Other section observers
const sectionObserver = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('animate-fadeInUp');
sectionObserver.unobserve(entry.target);
}
});
}, { threshold: 0.1 });
document.querySelectorAll('section').forEach(section => {
sectionObserver.observe(section);
});
}
// Toast notifications
function showToast(message, type = 'success') {
const toast = document.createElement('div');
toast.className = `fixed bottom-6 left-1/2 transform -translate-x-1/2 px-6 py-3 rounded-lg shadow-lg ${
type === 'success' ? 'bg-green-600' : 'bg-red-600'
} text-white font-medium z-50 animate-fadeInUp`;
toast.textContent = message;
document.body.appendChild(toast);
setTimeout(() => {
toast.classList.replace('animate-fadeInUp', 'animate-fadeOutDown');
setTimeout(() => toast.remove(), 500);
}, 3000);
}
function showErrorToast(message) {
showToast(message, 'error');
}
// Orders Data (Initial)
let orders = JSON.parse(localStorage.getItem('orders')) || [
{ id: 1, service: "Enterprise Web Development", description: "Custom web applications with React/Node.js stack", price: "$25,000+" },
{ id: 2, service: "Cloud Architecture", description: "AWS/GCP/Azure infrastructure design & implementation", price: "$15,000+" },
{ id: 3, service: "Cybersecurity Audit", description: "Comprehensive security assessment & hardening", price: "$8,000+" },
{ id: 4, service: "AI Integration", description: "Machine learning model development & deployment", price: "$30,000+" }
];
// Load Orders Table
function loadOrders() {
const tableBody = document.getElementById('orders-table');
tableBody.innerHTML = '';
orders.forEach(order => {
const row = document.createElement('tr');
row.className = 'border-b border-gray-700 hover:bg-secondary/30 transition-colors';
row.innerHTML = `
<td class="px-6 py-4">${order.service}</td>
<td class="px-6 py-4 text-gray-400">${order.description}</td>
<td class="px-6 py-4 font-medium">${order.price}</td>
<td class="px-6 py-4">
<button onclick="deleteOrder(${order.id})" class="text-red-400 hover:text-red-300 transition-colors">
<i data-feather="trash-2" class="w-5 h-5"></i>
</button>
</td>
`;
tableBody.appendChild(row);
});
feather.replace();
}
// Add New Order
function addOrder(service, description, price) {
const newId = orders.length > 0 ? Math.max(...orders.map(o => o.id)) + 1 : 1;
const newOrder = {
id: newId,
service,
description,
price
};
orders.push(newOrder);
localStorage.setItem('orders', JSON.stringify(orders));
loadOrders();
}
// Delete Order
function deleteOrder(id) {
orders = orders.filter(order => order.id !== id);
localStorage.setItem('orders', JSON.stringify(orders));
loadOrders();
}
// Blog Posts Data
let blogPosts = JSON.parse(localStorage.getItem('blogPosts')) || [
{
id: 1,
title: "The Future of Cloud Computing in 2023",
content: "Exploring the latest trends in cloud architecture and how businesses can leverage them for competitive advantage.",
date: "May 15, 2023"
},
{
id: 2,
title: "Securing Your Digital Assets",
content: "Best practices for enterprise cybersecurity in an increasingly complex threat landscape.",
date: "April 28, 2023"
},
{
id: 3,
title: "AI Integration Strategies",
content: "How to successfully implement AI solutions without disrupting existing workflows.",
date: "March 10, 2023"
}
];
// Load Blog Posts
function loadBlogPosts() {
const container = document.getElementById('blog-container');
container.innerHTML = '';
blogPosts.forEach(post => {
const postElement = document.createElement('div');
postElement.className = 'bg-secondary/50 backdrop-blur-lg rounded-xl p-6 border border-gray-700/50 hover:border-accent/50 transition-all duration-300';
postElement.innerHTML = `
<h3 class="text-xl font-bold mb-3">${post.title}</h3>
<p class="text-gray-400 mb-4">${post.content.substring(0, 150)}...</p>
<div class="flex justify-between items-center text-sm text-gray-500">
<span>${post.date}</span>
<button onclick="deleteBlogPost(${post.id})" class="text-red-400 hover:text-red-300 transition-colors">
<i data-feather="trash-2" class="w-4 h-4"></i>
</button>
</div>
`;
container.appendChild(postElement);
});
feather.replace();
}
// Add New Blog Post
function addBlogPost(title, content) {
const newId = blogPosts.length > 0 ? Math.max(...blogPosts.map(p => p.id)) + 1 : 1;
const newPost = {
id: newId,
title,
content,
date: new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' })
};
blogPosts.push(newPost);
localStorage.setItem('blogPosts', JSON.stringify(blogPosts));
loadBlogPosts();
}
// Delete Blog Post
function deleteBlogPost(id) {
blogPosts = blogPosts.filter(post => post.id !== id);
localStorage.setItem('blogPosts', JSON.stringify(blogPosts));
loadBlogPosts();
}
// Admin Controls (Now moved to admin.html)
function setupAdminAccess() {
// This function is now handled by the admin login modal
// All admin functionality moved to admin.html
}
// Make functions available globally
window.deleteOrder = deleteOrder;
window.deleteBlogPost = deleteBlogPost;