-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
166 lines (130 loc) · 4.96 KB
/
script.js
File metadata and controls
166 lines (130 loc) · 4.96 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* StarlightDaemon Portfolio - Interactive Features
*/
/* --- STARGATE TERMINAL LOGIC --- */
const innerRing = document.getElementById('innerRing');
const horizon = document.getElementById('horizon');
const statusText = document.getElementById('sgStatus');
const chevrons = [1, 2, 3, 4, 5, 6, 7].map(i => document.getElementById('c' + i));
let isDialing = false;
let currentRotation = 0;
async function dialSequence() {
if (isDialing) return;
isDialing = true;
// Determine mode based on active element
// Check if we are in full mode (has status text) or mini mode
const isFullMode = !!document.querySelector('.sg-terminal:not(.mini-mode)');
// Reset
horizon.className = 'event-horizon';
chevrons.forEach(c => { if (c) c.classList.remove('locked') });
if (statusText) statusText.innerText = "DIALING...";
currentRotation = 0;
innerRing.style.transform = `rotate(0deg)`;
// Dial 7 Chevrons
for (let i = 0; i < 7; i++) {
// Spin Ring
// Slower spin for mini mode? User asked for "a bit slower"
// Let's make the spin duration dynamic
let spinDuration = isFullMode ? 1000 : 2000; // Slower on mini
let spinAmount = Math.floor(Math.random() * 60) + 60;
if (i % 2 === 0) currentRotation += spinAmount;
else currentRotation -= spinAmount;
innerRing.style.transition = `transform ${spinDuration / 1000}s cubic-bezier(0.5, 0, 0.5, 1)`;
innerRing.style.transform = `rotate(${currentRotation}deg)`;
if (statusText) statusText.innerText = `ENCODING CHEVRON ${i + 1}...`;
// Wait for spin
await new Promise(r => setTimeout(r, spinDuration));
// Lock Chevron
if (chevrons[i]) chevrons[i].classList.add('locked');
// Short pause
await new Promise(r => setTimeout(r, isFullMode ? 200 : 500));
}
// Engage
if (statusText) statusText.innerText = "WORMHOLE ACTIVE";
horizon.classList.add('kawoosh');
// Hold wormhole
await new Promise(r => setTimeout(r, 4000));
// Shut down if mini mode to loop, or keep open if full?
// User said "dialer automatically" for mini.
if (!isFullMode) {
horizon.classList.remove('kawoosh');
horizon.classList.remove('active');
chevrons.forEach(c => { if (c) c.classList.remove('locked') });
isDialing = false;
// Wait before next dialing
setTimeout(dialSequence, 3000);
return;
}
horizon.classList.remove('kawoosh');
horizon.classList.add('active');
isDialing = false;
}
// Auto-start if mini mode
document.addEventListener('DOMContentLoaded', () => {
if (document.querySelector('.sg-terminal.mini-mode')) {
setTimeout(dialSequence, 1000);
}
});
// Main Init
document.addEventListener('DOMContentLoaded', () => {
// Intersection Observer for scroll animations
initScrollAnimations();
// Dynamic year in footer
updateCopyrightYear();
// Terminal commands rotation
updateTerminalCommands();
});
/**
* Initialize scroll-triggered animations using Intersection Observer
*/
function initScrollAnimations() {
const observerOptions = {
threshold: 0.1,
rootMargin: '0px 0px -50px 0px'
};
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.classList.add('visible');
observer.unobserve(entry.target);
}
});
}, observerOptions);
// Observe project cards for staggered animation
document.querySelectorAll('.project-card').forEach((card, index) => {
card.style.opacity = '0';
card.style.transform = 'translateY(30px)';
card.style.transition = `opacity 0.5s ease ${index * 0.1}s, transform 0.5s ease ${index * 0.1}s`;
observer.observe(card);
});
// Observe skill categories
document.querySelectorAll('.skill-category').forEach((category, index) => {
category.style.opacity = '0';
category.style.transform = 'translateY(20px)';
category.style.transition = `opacity 0.4s ease ${index * 0.1}s, transform 0.4s ease ${index * 0.1}s`;
observer.observe(category);
});
}
// Add visible class styles
const style = document.createElement('style');
style.textContent = `
.project-card.visible,
.skill-category.visible {
opacity: 1 !important;
transform: translateY(0) !important;
}
`;
document.head.appendChild(style);
/**
* Update copyright year dynamically
*/
function updateCopyrightYear() {
const footer = document.querySelector('.footer p');
if (footer) {
const currentYear = new Date().getFullYear();
footer.innerHTML = footer.innerHTML.replace(/©\s*\d{4}/, `© ${currentYear}`);
}
}
/**
* Terminal commands rotation
*/