diff --git a/achievements.js b/achievements.js deleted file mode 100644 index 2d09200..0000000 --- a/achievements.js +++ /dev/null @@ -1,403 +0,0 @@ -// Cookie utilities -function setCookie(name, value, days) { - const date = new Date(); - date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); - const expires = "expires=" + date.toUTCString(); - document.cookie = name + "=" + value + ";" + expires + ";path=/"; -} - -function getCookie(name) { - const nameEQ = name + "="; - const ca = document.cookie.split(';'); - for (let i = 0; i < ca.length; i++) { - let c = ca[i]; - while (c.charAt(0) === ' ') c = c.substring(1, c.length); - if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length); - } - return null; -} - -// Achievement system -const ACHIEVEMENTS = { - "first_visit": { - name: "Nováček", - description: "První návštěva na portálu", - icon: "fa-star", - color: "text-yellow-500", - theme: { - backgroundColor: "bg-yellow-50", - textColor: "text-yellow-700", - borderColor: "border-yellow-200", - hoverColor: "hover:bg-yellow-100" - } - }, - "mobile_master": { - name: "Mobilní Master", - description: "10 návštěv z mobilního zařízení za měsíc", - icon: "fa-mobile-alt", - color: "text-green-500", - threshold: 10, - period: "monthly", - device: "mobile", - theme: { - backgroundColor: "bg-green-50", - textColor: "text-green-700", - borderColor: "border-green-200", - hoverColor: "hover:bg-green-100" - } - }, - "desktop_guru": { - name: "Desktop Guru", - description: "20 návštěv z počítače za měsíc", - icon: "fa-desktop", - color: "text-blue-500", - threshold: 20, - period: "monthly", - device: "desktop", - theme: { - backgroundColor: "bg-blue-50", - textColor: "text-blue-700", - borderColor: "border-blue-200", - hoverColor: "hover:bg-blue-100" - } - }, - "frequent_visitor": { - name: "Pravidelný návštěvník", - description: "10 návštěv za měsíc", - icon: "fa-clock-rotate-left", - color: "text-blue-500", - threshold: 10, - period: "monthly", - theme: { - backgroundColor: "bg-blue-50", - textColor: "text-blue-700", - borderColor: "border-blue-200", - hoverColor: "hover:bg-blue-100" - } - }, - "power_user": { - name: "Power User", - description: "50 návštěv za měsíc", - icon: "fa-rocket", - color: "text-purple-500", - threshold: 50, - period: "monthly", - theme: { - backgroundColor: "bg-purple-50", - textColor: "text-purple-700", - borderColor: "border-purple-200", - hoverColor: "hover:bg-purple-100" - } - }, - "super_fan": { - name: "Super Fan", - description: "100 návštěv za měsíc", - icon: "fa-award", - color: "text-gold", - threshold: 100, - period: "monthly", - theme: { - backgroundColor: "bg-yellow-50", - textColor: "text-yellow-700", - borderColor: "border-yellow-200", - hoverColor: "hover:bg-yellow-100" - } - } -}; - -// Device categories -const DEVICE_CATEGORIES = { - mobile: [ - "iPhone", - "iPad", - "Android Phone", - "Android Tablet", - "Windows Phone" - ], - desktop: [ - "Windows PC", - "Mac", - "Linux PC" - ] -}; - -// Get device category -function getDeviceCategory(device) { - for (const [category, devices] of Object.entries(DEVICE_CATEGORIES)) { - if (devices.includes(device)) { - return category; - } - } - return "unknown"; -} - -// Track unlocked achievements -let unlockedAchievements = new Set(); - -// Store current theme -let currentTheme = { - backgroundColor: "bg-white", - textColor: "text-gray-800", - borderColor: "border-gray-200", - hoverColor: "hover:bg-gray-50" -}; - -// Apply theme to all cards -function applyTheme() { - const cards = document.querySelectorAll('.card'); - cards.forEach(card => { - card.className = card.className.split(' ').filter(cls => !cls.startsWith('bg-') && !cls.startsWith('text-') && !cls.startsWith('border-') && !cls.startsWith('hover:')).join(' '); - card.className += ` ${currentTheme.backgroundColor} ${currentTheme.textColor} ${currentTheme.borderColor} ${currentTheme.hoverColor}`; - }); -} - -let achievementsEnabled = false; - -// Hidden toggle for achievements -function toggleAchievements() { - achievementsEnabled = !achievementsEnabled; - localStorage.setItem('achievementsEnabled', achievementsEnabled); - - if (achievementsEnabled) { - checkAchievements(); - showAchievements(); - } else { - hideAchievements(); - } -} - -// Check if user has earned achievements -async function checkAchievements() { - try { - const response = await fetch('/api/visitor-stats'); - const stats = await response.json(); - const visitorId = getCookie('visitor_id'); - - // First visit achievement - if (!localStorage.getItem('first_visit_' + visitorId)) { - unlockAchievement('first_visit'); - localStorage.setItem('first_visit_' + visitorId, 'true'); - } - - // Get visitor's stats - const visitor = stats.unique_visitors[visitorId]; - if (!visitor) return; - - // Device-specific achievements - const deviceCategory = getDeviceCategory(visitor.Device); - - // Mobile Master achievement - if (deviceCategory === 'mobile' && - visitor.Visits >= ACHIEVEMENTS.mobile_master.threshold && - !localStorage.getItem('mobile_master_' + visitorId)) { - unlockAchievement('mobile_master'); - localStorage.setItem('mobile_master_' + visitorId, 'true'); - } - - // Desktop Guru achievement - if (deviceCategory === 'desktop' && - visitor.Visits >= ACHIEVEMENTS.desktop_guru.threshold && - !localStorage.getItem('desktop_guru_' + visitorId)) { - unlockAchievement('desktop_guru'); - localStorage.setItem('desktop_guru_' + visitorId, 'true'); - } - - // Monthly achievements - const monthlyVisits = stats.monthly_visits; - if (monthlyVisits >= ACHIEVEMENTS.frequent_visitor.threshold && - !localStorage.getItem('frequent_visitor_' + visitorId)) { - unlockAchievement('frequent_visitor'); - localStorage.setItem('frequent_visitor_' + visitorId, 'true'); - } - - if (monthlyVisits >= ACHIEVEMENTS.power_user.threshold && - !localStorage.getItem('power_user_' + visitorId)) { - unlockAchievement('power_user'); - localStorage.setItem('power_user_' + visitorId, 'true'); - } - - if (monthlyVisits >= ACHIEVEMENTS.super_fan.threshold && - !localStorage.getItem('super_fan_' + visitorId)) { - unlockAchievement('super_fan'); - localStorage.setItem('super_fan_' + visitorId, 'true'); - } - } catch (error) { - console.error('Error checking achievements:', error); - } -} - -// Unlock achievement and show toast -function unlockAchievement(achievement) { - unlockedAchievements.add(achievement); - showAchievementToast(achievement); - showAchievements(); -} - -// Show achievement toast -function showAchievementToast(achievement) { - const toast = document.createElement('div'); - toast.className = 'fixed bottom-4 right-4 bg-white rounded-lg shadow-lg p-4 w-64 flex items-center text-green-500'; - toast.innerHTML = ` -
${ACHIEVEMENTS[achievement].name}
-"IDKFA" cheat code activated
-První návštěva na portálu
-10 návštěv za měsíc
-50 návštěv za měsíc
-100 návštěv za měsíc
-