File size: 3,174 Bytes
07ce319
887b497
 
 
 
 
00f919a
887b497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
00f919a
887b497
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07ce319
887b497
 
 
 
 
 
 
 
 
 
07ce319
887b497
 
 
 
 
 
 
 
 
 
 
 
07ce319
887b497
 
 
 
 
 
 
07ce319
887b497
 
07ce319
887b497
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102

// Modern ES6+ JavaScript with User Detection
import { detect } from 'detect-browser';
import anime from 'animejs/lib/anime.es.js';
import AOS from 'aos';
import 'aos/dist/aos.css';

// Initialize AOS (Animate On Scroll)
AOS.init({
  duration: 800,
  easing: 'ease-in-out-quart',
  once: true
});

// Detect user's browser, OS and device
const browser = detect();
const userLanguage = navigator.language || navigator.userLanguage;

// Set RTL/LTR based on language
if (['fa', 'ar', 'he'].includes(userLanguage.substring(0,2))) {
  document.documentElement.setAttribute('dir', 'rtl');
  document.documentElement.lang = 'fa';
} else {
  document.documentElement.setAttribute('dir', 'ltr');
  document.documentElement.lang = 'en';
}

// Modern Animations with Anime.js
document.addEventListener('DOMContentLoaded', () => {
  // Hero section animation
  anime.timeline({
    easing: 'easeOutExpo'
  })
  .add({
    targets: '.hero-title',
    opacity: [0, 1],
    translateY: [50, 0],
    duration: 800
  })
  .add({
    targets: '.hero-subtitle',
    opacity: [0, 1],
    translateY: [30, 0],
    duration: 600
  }, '-=400')
  .add({
    targets: '.feature-card',
    opacity: [0, 1],
    translateY: [40, 0],
    duration: 800,
    delay: anime.stagger(150)
  }, '-=400');

  // Floating animation for cards
  anime({
    targets: '.feature-card',
    translateY: ['-10px', '10px'],
    easing: 'easeInOutSine',
    duration: 3000,
    direction: 'alternate',
    loop: true,
    delay: anime.stagger(200)
  });

  // Gradient border animation
  const gradientBorder = document.querySelectorAll('.gradient-border');
  gradientBorder.forEach(el => {
    anime({
      targets: el,
      backgroundPosition: ['0% 50%', '100% 50%'],
      easing: 'linear',
      duration: 8000,
      loop: true
    });
  });
});

// Service Worker for PWA
if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker.register('/sw.js').then(registration => {
      console.log('SW registered: ', registration);
    }).catch(registrationError => {
      console.log('SW registration failed: ', registrationError);
    });
  });
}

// Modern console log
console.log(`
%c Persian Optimizer %c v2.0 %c
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•— β–ˆβ–ˆβ•—β–ˆβ–ˆβ–ˆβ•—   β–ˆβ–ˆβ•—
β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β•β•β•β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘β–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•”β•β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•”β–ˆβ–ˆβ•— β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•”β•β•β•β• β–ˆβ–ˆβ•”β•β•β•  β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•—β–ˆβ–ˆβ•”β•β•β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β•šβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘
β–ˆβ–ˆβ•‘     β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ•—β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘  β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘β–ˆβ–ˆβ•‘ β•šβ–ˆβ–ˆβ–ˆβ–ˆβ•‘
β•šβ•β•     β•šβ•β•β•β•β•β•β•β•šβ•β•  β•šβ•β•β•šβ•β•  β•šβ•β•β•šβ•β•β•šβ•β•  β•šβ•β•β•β•
`, 
'background: linear-gradient(45deg, #6366f1, #8b5cf6); color: white; padding: 5px 0; border-radius: 3px 0 0 3px;',
'background: #0f172a; color: white; padding: 5px 0; border-radius: 0 3px 3px 0;',
'');