-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
92 lines (75 loc) Β· 3.04 KB
/
script.js
File metadata and controls
92 lines (75 loc) Β· 3.04 KB
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
// Generate particles
const particlesContainer = document.getElementById('particles');
for (let i = 0; i < 30; i++) {
const particle = document.createElement('div');
particle.className = 'particle';
particle.style.left = Math.random() * 100 + '%';
particle.style.top = Math.random() * 100 + '%';
particle.style.animationDelay = Math.random() * 15 + 's';
particle.style.animationDuration = (15 + Math.random() * 10) + 's';
particlesContainer.appendChild(particle);
}
// Theme functionality
const themeInput = document.getElementById('themeInput');
const applyBtn = document.getElementById('applyBtn');
const themeTags = document.querySelectorAll('.theme-tag');
const themeKeywords = {
'cyberpunk': ['cyber', 'futuristic', 'neon', 'tech', 'future', 'matrix', 'sci-fi'],
'nature': ['nature', 'green', 'forest', 'jungle', 'plant', 'earth', 'eco'],
'ocean': ['ocean', 'sea', 'water', 'blue', 'marine', 'beach', 'wave'],
'sunset': ['sunset', 'dusk', 'evening', 'orange', 'warm', 'twilight'],
'neon': ['neon', 'bright', 'vibrant', 'electric', 'glow', 'fluorescent']
};
function detectTheme(input) {
const lowerInput = input.toLowerCase();
for (const [theme, keywords] of Object.entries(themeKeywords)) {
if (keywords.some(keyword => lowerInput.includes(keyword))) {
return theme;
}
}
const themes = ['cyberpunk', 'nature', 'ocean', 'sunset', 'neon'];
return themes[Math.floor(Math.random() * themes.length)];
}
function showSuccess(themeName) {
const msg = document.createElement('div');
msg.className = 'success-msg';
msg.textContent = `β¨ ${themeName.charAt(0).toUpperCase() + themeName.slice(1)} theme applied!`;
document.body.appendChild(msg);
setTimeout(() => {
msg.style.animation = 'slideIn 0.5s ease reverse';
setTimeout(() => msg.remove(), 500);
}, 3000);
}
function applyTheme(input) {
if (!input.trim()) return;
applyBtn.disabled = true;
applyBtn.innerHTML = '<span class="loading">Processing...</span>';
setTimeout(() => {
const theme = detectTheme(input);
document.body.className = theme;
applyBtn.disabled = false;
applyBtn.innerHTML = '<span>π¨ Transform</span>';
themeInput.value = '';
themeInput.placeholder = `Current: ${theme} β¨`;
showSuccess(theme);
}, 1500);
}
applyBtn.addEventListener('click', () => applyTheme(themeInput.value));
themeInput.addEventListener('keypress', (e) => {
if (e.key === 'Enter') applyTheme(themeInput.value);
});
themeTags.forEach(tag => {
tag.addEventListener('click', function() {
const theme = this.dataset.theme;
applyTheme(theme);
});
});
// Animate gallery items on hover
document.querySelectorAll('.gallery-item').forEach((item, index) => {
item.style.animationDelay = (index * 0.1) + 's';
});
// Initial random theme
setTimeout(() => {
const themes = ['cyberpunk', 'ocean', 'sunset'];
applyTheme(themes[Math.floor(Math.random() * themes.length)]);
}, 800);