-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
211 lines (177 loc) · 6.67 KB
/
Copy pathscript.js
File metadata and controls
211 lines (177 loc) · 6.67 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// Terminal-style Mini Projects JavaScript
(function () {
'use strict';
// Theme Management Removed
// class ThemeManager { ... }
// Terminal Animation Manager
class TerminalAnimator {
constructor() {
this.init();
}
init() {
this.animateTerminalOutput();
// this.setupCursor(); // Removed
this.setupProjectHovers();
}
animateTerminalOutput() {
const lines = document.querySelectorAll('.terminal-output .line');
lines.forEach((line, index) => {
line.style.opacity = '0';
line.style.transform = 'translateX(-20px)';
setTimeout(() => {
line.style.transition = 'all 0.3s ease';
line.style.opacity = '1';
line.style.transform = 'translateX(0)';
}, index * 100);
});
}
setupProjectHovers() {
const projectLinks = document.querySelectorAll('.project-link');
projectLinks.forEach(link => {
link.addEventListener('mouseenter', (e) => {
this.createHoverEffect(e.target);
});
link.addEventListener('mouseleave', (e) => {
this.removeHoverEffect(e.target);
});
});
}
createHoverEffect(element) {
const effect = document.createElement('div');
effect.className = 'hover-effect';
effect.style.cssText = `
position: absolute;
left: 0;
top: 0;
width: 3px;
height: 100%;
background: var(--accent-color);
opacity: 0;
transition: opacity 0.2s ease;
pointer-events: none;
`;
element.style.position = 'relative';
element.appendChild(effect);
requestAnimationFrame(() => {
effect.style.opacity = '1';
});
}
removeHoverEffect(element) {
const effect = element.querySelector('.hover-effect');
if (effect) {
effect.style.opacity = '0';
setTimeout(() => {
if (effect.parentNode) {
effect.parentNode.removeChild(effect);
}
}, 200);
}
}
}
// Keyboard Manager removed
// Terminal Window Controls Removed
// class TerminalControls { ... }
// Performance Monitor
class PerformanceMonitor {
constructor() {
this.startTime = performance.now();
this.init();
}
init() {
this.updateStatus();
setInterval(() => this.updateStatus(), 5000);
}
updateStatus() {
const statusItems = document.querySelectorAll('.status-item');
const uptime = Math.floor((performance.now() - this.startTime) / 1000);
const memory = this.getMemoryUsage();
statusItems.forEach(item => {
const type = item.dataset.type;
switch (type) {
case 'uptime':
item.textContent = `Uptime: ${this.formatTime(uptime)}`;
break;
case 'memory':
item.textContent = `Memory: ${memory}MB`;
break;
case 'projects':
const projectCount = document.querySelectorAll('.project-link').length;
item.textContent = `Projects: ${projectCount}`;
break;
}
});
}
formatTime(seconds) {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const secs = seconds % 60;
return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
}
getMemoryUsage() {
if (performance.memory) {
return Math.round(performance.memory.usedJSHeapSize / 1024 / 1024);
}
return Math.floor(Math.random() * 50) + 20; // Fallback for browsers without memory API
}
}
function init() {
new TerminalAnimator();
new PerformanceMonitor();
setTimeout(() => {
const output = document.querySelector('.terminal-output');
if (!output) return; // Guard clause
const newLine = document.createElement('div');
newLine.className = 'line';
newLine.innerHTML = `
<span class="prompt">ubednama@terminal:~$</span>
<span class="output">Terminal initialized successfully. Welcome!</span>
`;
output.appendChild(newLine);
}, 1000);
const startupMessages = [
'Loading project database...'
];
startupMessages.forEach((message, index) => {
setTimeout(() => {
const output = document.querySelector('.terminal-output');
const newLine = document.createElement('div');
newLine.className = 'line';
newLine.innerHTML = `
<span class="prompt">ubednama@terminal:~$</span>
<span class="output">${message}</span>
`;
output.appendChild(newLine);
}, (index + 2) * 500);
});
}
// Start when DOM is ready
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
// Handle visibility change for performance
document.addEventListener('visibilitychange', () => {
if (document.hidden) {
// Pause animations when tab is not visible
document.body.style.animationPlayState = 'paused';
} else {
// Resume animations when tab becomes visible
document.body.style.animationPlayState = 'running';
}
});
// Error handling
window.addEventListener('error', (e) => {
console.error('Terminal Error:', e.error);
const output = document.querySelector('.terminal-output');
if (output) {
const errorLine = document.createElement('div');
errorLine.className = 'line';
errorLine.innerHTML = `
<span class="prompt">ubednama@terminal:~$</span>
<span class="output" style="color: #ff5555;">Error: ${e.message}</span>
`;
output.appendChild(errorLine);
}
});
})();