-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
826 lines (686 loc) · 26.3 KB
/
Copy pathscript.js
File metadata and controls
826 lines (686 loc) · 26.3 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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
const resume = {
about: "Desenvolvedor Web e Engenheiro de Soluções. Especializado em criar aplicações web performáticas (HTML, CSS, JavaScript) e automações inteligentes com Python. Transformo dados dispersos em insights acionáveis através de cruzamento e integração de dados. Minha abordagem combina lógica sistêmica e resolução avançada de problemas (troubleshooting) para entregar código limpo, escalável e soluções robustas. Sou um entusiasta do código aberto, contribuindo ativamente para a comunidade, e mantenho-me em constante evolução através do aprendizado autodidata e proativo.",
skills: {
engineering: [
"Projetos civis: detalhamento executivo, quantitativos, compatibilização e documentação técnica.",
"Projetos elétricos: dimensionamento, diagramas, memorial e detalhamento de pranchas."
],
cadBim: [
"AutoCAD: plantas, detalhes construtivos, revisão e padronização de desenhos 2D.",
"Revit/BIM: modelagem, compatibilização interdisciplinar e organização para entrega."
],
excel: [
"Planilhas avançadas para orçamento, quantitativos e acompanhamento técnico.",
"Dashboards e automações para reduzir retrabalho e melhorar leitura de indicadores."
],
programming: [
"HTML, CSS e JavaScript para interfaces web objetivas e responsivas.",
"Python para automações, tratamento de dados e scripts utilitários."
]
},
education: [
"Minha trajetória combina <strong>Engenharia Civil (FMU-SP, 2014-2020)</strong> e <strong>Administração de Empresas (FMU-SP, 2009-2012)</strong>.",
"",
"Esta dupla formação me proporciona uma visão única: a precisão técnica e metodológica do engenheiro aliada à perspectiva estratégica e de negócios do administrador.",
"Aplico esse conjunto no desenvolvimento de soluções que são tanto tecnicamente sólidas quanto alinhadas com objetivos organizacionais."
],
projects: {
engineering: [],
programming: [],
programmingOnDemand: []
},
social: {
github: "https://github.com/jsinatro",
linkedin: "https://linkedin.com/in/jsinatro",
email: "sinatro@msn.com",
whatsapp: "5511996495465",
familysearch_user: "@sinatro",
familysearch: "https://www.familysearch.org/pt/",
endogamia: "http://www.endogamiabarbalhense.com.br"
}
};
const CONTACT = {
email: 'sinatro@msn.com',
emailHref: 'mailto:sinatro@msn.com?subject=Contato%20-%20Portf%C3%B3lio&body=Ol%C3%A1%20Sinatro!%20',
whatsappDigits: '5511996495465',
whatsappDisplay: '+55 11 99649-5465',
whatsappHref: 'https://wa.me/5511996495465?text=Ol%C3%A1%20Sinatro!%20Vim%20pelo%20seu%20portf%C3%B3lio.',
github: 'https://github.com/jsinatro',
linkedin: 'https://linkedin.com/in/jsinatro'
};
const inputField = document.getElementById('command-input');
const outputDiv = document.getElementById('output');
const terminalBody = document.getElementById('terminal-body');
const promptText = "visitante@sinatro: ~$";
const copyEmailBtn = document.getElementById('copy-email');
const copyWhatsappBtn = document.getElementById('copy-whatsapp');
const contactFeedback = document.getElementById('contact-feedback');
const commandHistory = [];
const MAX_HISTORY = 30;
let historyIndex = 0;
let projectsCache = null;
let projectsLoadPromise = null;
const MAX_OUTPUT_LINES = 200;
const outputQueue = [];
let flushScheduled = false;
const commandAliases = {
ajuda: 'help',
sobre: 'about',
habilidades: 'skills',
projetos: 'projects',
contato: 'contact',
curriculo: 'curriculo',
resume: 'curriculo',
engenharia: 'engineering',
autocad: 'cad',
bim: 'revit',
planilhas: 'excel',
servicos: 'services',
resumo: 'pitch'
};
function printLine(text, { className = '', isInput = false } = {}) {
if (!outputDiv) return;
const pre = document.createElement('pre');
if (className) pre.className = className;
if (isInput) {
const promptSpan = document.createElement('span');
promptSpan.className = 'prompt';
promptSpan.textContent = promptText;
pre.appendChild(promptSpan);
pre.append(` ${text}`);
} else {
pre.textContent = text;
}
queueOutputNode(pre);
}
function printHTMLSafe(containerBuilderFn) {
if (!outputDiv || typeof containerBuilderFn !== 'function') return;
const pre = document.createElement('pre');
containerBuilderFn(pre);
queueOutputNode(pre);
}
function printTrustedHTML(html) {
printHTMLSafe((container) => {
container.innerHTML = html;
});
}
function queueOutputNode(node) {
if (!outputDiv || !node) return;
outputQueue.push(node);
if (flushScheduled) return;
flushScheduled = true;
requestAnimationFrame(() => {
flushOutputQueue();
});
}
function flushOutputQueue() {
if (!outputDiv || !outputQueue.length) {
flushScheduled = false;
return;
}
const fragment = document.createDocumentFragment();
outputQueue.splice(0).forEach((node) => fragment.appendChild(node));
outputDiv.appendChild(fragment);
trimOutputLines();
scrollToBottom();
flushScheduled = false;
}
function trimOutputLines() {
if (!outputDiv) return;
while (outputDiv.childElementCount > MAX_OUTPUT_LINES) {
outputDiv.firstElementChild?.remove();
}
}
function focusInput() {
if (!inputField || inputField.disabled) return;
inputField.focus();
}
function scrollToBottom() {
if (!terminalBody) return;
terminalBody.scrollTop = terminalBody.scrollHeight;
}
function pushHistory(command) {
if (!command) {
historyIndex = commandHistory.length;
return;
}
commandHistory.push(command);
if (commandHistory.length > MAX_HISTORY) {
commandHistory.shift();
}
historyIndex = commandHistory.length;
}
function clearTerminalOutput({ showMessage = false } = {}) {
if (outputDiv) {
outputDiv.textContent = '';
}
outputQueue.length = 0;
if (showMessage) {
printLine('(limpo)', { className: 'desc' });
}
}
function copyOutputToClipboard() {
if (!outputDiv) return;
const outputText = outputDiv.innerText;
if (!navigator.clipboard) {
printLine('Clipboard indisponível neste navegador.', { className: 'error' });
return;
}
navigator.clipboard.writeText(outputText)
.then(() => {
printLine('✓ Texto copiado para a área de transferência!', { className: 'success' });
})
.catch(() => {
printLine('✗ Erro ao copiar texto.', { className: 'error' });
});
}
window.onload = async function() {
if (!inputField || !outputDiv || !terminalBody) return;
outputDiv.textContent = '';
inputField.disabled = true;
await typeText('Inicializando kernel...', 50);
await typeText('Carregando módulos de interface...', 30);
await typeText('Montando sistema de arquivos...', 30);
await delay(500);
outputDiv.textContent = '';
printLine('João Sinatro v2.1.4 - Conectado como visitante');
printLine('Bem-vindo ao portfólio interativo.');
printLine('');
showPitch();
printLine('');
printLine('Atalhos acima do input. Digite `help`.');
printLine('');
inputField.disabled = false;
initContactBlock();
focusInput();
};
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function typeText(text, speed) {
if (!outputDiv) return;
const pre = document.createElement('pre');
outputDiv.appendChild(pre);
trimOutputLines();
for (let i = 0; i < text.length; i++) {
pre.textContent += text.charAt(i);
scrollToBottom();
await delay(speed);
}
}
function showPitch() {
printTrustedHTML("<span class='header pitch-headline'>João Sinatro — Engenheiro Civil e Programador</span>");
printLine('- Projetos civis e elétricos • documentação e detalhamento');
printLine('- CAD/Revit (BIM) • pranchas, compatibilização e quantitativos');
printLine('- Automação com Excel e Python • planilhas, scripts e produtividade');
printLine('CV: digite `cv` (PDF) ou `curriculo` (HTML)');
printLine('Contato: digite `contact` ou role até a seção Contato');
}
function showHelp() {
const commands = [
{ cmd: 'help', desc: 'Lista de comandos disponíveis' },
{ cmd: 'about', desc: 'Resumo profissional' },
{ cmd: 'pitch / resumo', desc: 'Apresentação rápida com CTAs' },
{ cmd: 'skills', desc: 'Habilidades por área' },
{ cmd: 'projects', desc: 'Lista de projetos (carregada de projects.json)' },
{ cmd: 'project <id>', desc: 'Detalhes de um projeto específico' },
{ cmd: 'engineering / engenharia', desc: 'Serviços de engenharia (civil/elétrica)' },
{ cmd: 'cad / autocad', desc: 'Serviços CAD 2D' },
{ cmd: 'revit / bim', desc: 'Serviços Revit/BIM' },
{ cmd: 'excel / planilhas', desc: 'Planilhas, dashboards e automações' },
{ cmd: 'cv', desc: 'Abrir currículo em PDF' },
{ cmd: 'curriculo / resume', desc: 'Abrir currículo web (curriculo.html)' },
{ cmd: 'open <id|url>', desc: 'Abrir link de projeto por id ou URL' },
{ cmd: 'contact', desc: 'Canais de contato' }
];
printTrustedHTML("<span class='header'>== COMANDOS ==</span>");
commands.forEach((commandItem) => {
printHTMLSafe((line) => {
const command = document.createElement('span');
command.className = 'cmd';
command.textContent = commandItem.cmd.padEnd(24);
const description = document.createElement('span');
description.className = 'desc';
description.textContent = ` - ${commandItem.desc}`;
line.appendChild(command);
line.appendChild(description);
});
});
printLine('Dica: use os atalhos acima do campo de comando.');
}
function showAbout() {
printTrustedHTML("<span class='header'>--- SOBRE MIM ---</span>");
printTrustedHTML(resume.about);
}
function showSkills() {
printTrustedHTML("<span class='header'>== SKILLS ==</span>");
printTrustedHTML("<span class='header'>== Engenharia (Civil/Elétrica) ==</span>");
resume.skills.engineering.forEach(item => printTrustedHTML(`- ${item}`));
printLine('');
printTrustedHTML("<span class='header'>== CAD / BIM ==</span>");
printLine('- AutoCAD: plantas, detalhes, pranchas e padronização 2D.');
printLine('- Revit: modelagem, compatibilização e organização para entrega.');
printLine('');
printTrustedHTML("<span class='header'>== Excel ==</span>");
resume.skills.excel.forEach(item => printTrustedHTML(`- ${item}`));
printLine('');
printTrustedHTML("<span class='header'>== Programação ==</span>");
printLine('- HTML, CSS e JavaScript para interfaces web objetivas.');
printLine('- Python para automações e tratamento de dados.');
}
function showEducation() {
printTrustedHTML("<span class='header'>--- FORMAÇÃO ---</span>");
resume.education.forEach(edu => printTrustedHTML(`- ${edu}`));
}
async function loadProjects() {
if (Array.isArray(projectsCache)) {
return projectsCache;
}
if (projectsLoadPromise) {
return projectsLoadPromise;
}
projectsLoadPromise = fetch('./data/projects.json')
.then((response) => {
if (!response.ok) {
throw new Error('Falha ao carregar projects.json');
}
return response.json();
})
.then((data) => {
if (!Array.isArray(data)) {
throw new Error('Formato inválido de projects.json');
}
projectsCache = data;
return projectsCache;
})
.catch(() => {
printLine('Não foi possível carregar projects.json localmente. Verifique o caminho e o deploy.', { className: 'error' });
projectsCache = [];
return projectsCache;
})
.finally(() => {
projectsLoadPromise = null;
});
return projectsLoadPromise;
}
function formatProjectSummary(project) {
const tools = Array.isArray(project.ferramentas) && project.ferramentas.length
? project.ferramentas.join(', ')
: 'sem ferramentas definidas';
const exampleTag = project.status === 'exemplo' ? ' (exemplo — substitua por projeto real)' : '';
return `[${project.id}] ${project.titulo} — ${tools}${exampleTag}`;
}
async function showProjects() {
const projects = await loadProjects();
if (!projects.length) return;
const engineering = projects.filter((project) => project.tipo === 'engenharia');
const programming = projects.filter((project) => project.tipo === 'programacao');
printTrustedHTML("<span class='header'>== PROJETOS ==</span>");
printTrustedHTML("<span class='header'>== Engenharia ==</span>");
if (!engineering.length) {
printLine('- Nenhum projeto cadastrado nesta categoria.');
} else {
engineering.forEach((project) => printLine(formatProjectSummary(project)));
}
printLine('');
printTrustedHTML("<span class='header'>== Programação ==</span>");
if (!programming.length) {
printLine('- Nenhum projeto cadastrado nesta categoria.');
} else {
programming.forEach((project) => printLine(formatProjectSummary(project)));
}
printLine('');
printLine('Para detalhes: digite project <id>');
}
async function showProjectDetails(projectId) {
const id = (projectId || '').trim().toLowerCase();
if (!id) {
printLine('Uso: project <id>', { className: 'error' });
return;
}
const projects = await loadProjects();
if (!projects.length) return;
const project = projects.find((item) => String(item.id || '').toLowerCase() === id);
if (!project) {
printLine(`Projeto '${projectId}' não encontrado. Digite 'projects' para listar.`, { className: 'error' });
return;
}
printTrustedHTML("<span class='header'>== DETALHES DO PROJETO ==</span>");
printLine(`Título: ${project.titulo || 'não informado'}`);
printLine(`Tipo: ${project.tipo || 'não informado'}`);
printLine(`Descrição: ${project.descricao || 'não informada'}`);
printLine(`Ferramentas: ${(project.ferramentas || []).join(', ') || 'não informadas'}`);
printLine(`Entregáveis: ${(project.entregaveis || []).join(', ') || 'não informados'}`);
if (project.link) {
printLine(`Link: ${project.link}`);
printLine(`Digite open ${project.id} para abrir.`);
}
}
async function openProjectLink(projectOrUrl) {
const raw = (projectOrUrl || '').trim();
if (!raw) {
printLine('Uso: open <id|url>', { className: 'error' });
return;
}
const projects = await loadProjects();
const byId = projects.find((item) => String(item.id || '').toLowerCase() === raw.toLowerCase());
if (byId) {
if (!byId.link) {
printLine(`O projeto '${byId.id}' não possui link cadastrado.`, { className: 'error' });
return;
}
window.open(byId.link, '_blank', 'noopener,noreferrer');
return;
}
window.open(raw, '_blank', 'noopener,noreferrer');
}
function showEngineering() {
printTrustedHTML("<span class='header'>== ENGENHARIA ==</span>");
printLine('Serviços em engenharia civil e elétrica com foco em documentação clara e execução segura.');
printLine('');
printTrustedHTML("<span class='header'>== Entregas ==</span>");
printLine('- Projetos civis com detalhamento e quantitativos.');
printLine('- Projetos elétricos com dimensionamento e diagramas.');
printLine('- Pranchas e documentação técnica para obra/execução.');
printLine('');
printTrustedHTML("<span class='header'>== Ferramentas ==</span>");
printLine('- CAD: AutoCAD para desenhos 2D e padronização.');
printLine('- BIM: Revit para modelagem e compatibilização.');
printLine('- Excel: planilhas, indicadores e acompanhamento técnico.');
printLine('Digite `contact` para falar comigo.');
}
function showCad() {
printTrustedHTML("<span class='header'>== CAD ==</span>");
printLine('- Desenvolvimento de plantas técnicas e detalhes construtivos.');
printLine('- Montagem de pranchas com padronização de layers e escalas.');
printLine('- Compatibilização 2D entre disciplinas para reduzir conflitos.');
printLine('- Revisões e ajustes para emissão final de documentação.');
}
function showRevit() {
printTrustedHTML("<span class='header'>== REVIT / BIM ==</span>");
printLine('- Modelagem BIM para representação técnica do projeto.');
printLine('- Compatibilização entre arquitetura, estrutura e instalações.');
printLine('- Extração de vistas e pranchas organizadas para entrega.');
printLine('- Organização de famílias e padrões para consistência do modelo.');
}
function showExcel() {
printTrustedHTML("<span class='header'>== EXCEL ==</span>");
printLine('- Planilhas para orçamento e controle de custos.');
printLine('- Quantitativos, cronogramas e acompanhamento de etapas.');
printLine('- Dashboards para leitura rápida de indicadores.');
printLine('- Automações para reduzir retrabalho operacional.');
}
function showServices() {
printTrustedHTML("<span class='header'>== SERVICES ==</span>");
printLine('- Engenharia civil e elétrica com foco em entregáveis objetivos.');
printLine('- CAD/Revit para documentação, compatibilização e emissão de pranchas.');
printLine('- Excel para controle técnico, quantitativos e dashboards.');
printLine('- Desenvolvimento web com HTML, CSS e JavaScript.');
printLine('- Python para automações e tratamento de dados.');
printLine('- Projetos sob demanda: digite `contact` para alinharmos escopo e prazo.');
}
function showContact() {
printTrustedHTML("<span class='header'>--- CONTATO (contact) ---</span>");
printLine('Canais principais:');
printTrustedHTML(` > E-mail: <a href="${CONTACT.emailHref}">${CONTACT.email}</a>`);
printTrustedHTML(` > WhatsApp: <a href="${CONTACT.whatsappHref}" target="_blank" rel="noopener noreferrer">${CONTACT.whatsappDisplay}</a>`);
printTrustedHTML(` > GitHub: <a href="${CONTACT.github}" target="_blank" rel="noopener noreferrer">${CONTACT.github}</a>`);
printTrustedHTML(` > LinkedIn: <a href="${CONTACT.linkedin}" target="_blank" rel="noopener noreferrer">${CONTACT.linkedin}</a>`);
printLine('Dica: role até #contato para botões de copiar.');
}
function showContactFeedback(message, isError = false) {
if (!contactFeedback) return;
contactFeedback.textContent = message;
contactFeedback.className = isError ? 'error' : 'success';
}
async function copyText(text) {
if (!text) return false;
if (navigator.clipboard && window.isSecureContext) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch {
// fallback below
}
}
const tempArea = document.createElement('textarea');
tempArea.value = text;
tempArea.setAttribute('readonly', '');
tempArea.style.position = 'fixed';
tempArea.style.left = '-9999px';
document.body.appendChild(tempArea);
tempArea.select();
let copied = false;
try {
copied = document.execCommand('copy');
} finally {
document.body.removeChild(tempArea);
}
return copied;
}
async function handleCopyAction(valueToCopy, successMessage) {
const copied = await copyText(valueToCopy);
if (copied) {
showContactFeedback(successMessage);
printLine(`Copiado: ${valueToCopy}`, { className: 'success' });
} else {
const failMessage = 'Não foi possível copiar automaticamente.';
showContactFeedback(failMessage, true);
printLine(failMessage, { className: 'error' });
}
focusInput();
}
function initContactBlock() {
const emailLink = document.getElementById('contact-email-link');
const whatsappLink = document.getElementById('contact-whatsapp-link');
const githubLink = document.getElementById('contact-github-link');
const linkedinLink = document.getElementById('contact-linkedin-link');
if (emailLink) emailLink.href = CONTACT.emailHref;
if (whatsappLink) whatsappLink.href = CONTACT.whatsappHref;
if (githubLink) githubLink.href = CONTACT.github;
if (linkedinLink) linkedinLink.href = CONTACT.linkedin;
if (copyEmailBtn) {
copyEmailBtn.addEventListener('click', () => {
handleCopyAction(CONTACT.email, `Copiado: ${CONTACT.email}`);
});
}
if (copyWhatsappBtn) {
copyWhatsappBtn.addEventListener('click', () => {
handleCopyAction(CONTACT.whatsappDisplay, `Copiado: ${CONTACT.whatsappDisplay}`);
});
}
}
function openCvPdf() {
const cvPath = './joao_sinatro_cv.pdf';
fetch(cvPath, { method: 'HEAD' })
.then((response) => {
if (!response.ok) {
throw new Error('CV indisponível');
}
window.open(cvPath, '_blank', 'noopener');
})
.catch(() => {
printLine("PDF indisponível no momento. Use 'curriculo' para abrir a versão web.", { className: 'error' });
});
}
function openCurriculoPage() {
window.open('./curriculo.html', '_blank', 'noopener');
}
function showAll() {
showAbout();
printLine('');
showSkills();
printLine('');
showEducation();
printLine('');
showContact();
}
async function executeCommand(command) {
const cmdRaw = typeof command === 'string' ? command : '';
const cmd = cmdRaw.trim();
const cmdLower = cmd.toLowerCase();
if (!cmd) {
focusInput();
return;
}
printLine(cmd, { isInput: true });
const [cmdBase, ...args] = cmdLower.split(/\s+/);
const normalizedCommand = commandAliases[cmdBase] || cmdBase;
switch (normalizedCommand) {
case 'copy':
copyOutputToClipboard();
break;
case 'help':
case '?':
case 'ls':
showHelp();
break;
case 'clear':
clearTerminalOutput();
break;
case 'tudo':
case 'all':
showAll();
break;
case 'about':
showAbout();
break;
case 'pitch':
showPitch();
break;
case 'skills':
showSkills();
break;
case 'educacao':
case 'education':
showEducation();
break;
case 'projects':
await showProjects();
break;
case 'project':
await showProjectDetails(args.join(' '));
break;
case 'contact':
showContact();
break;
case 'github':
window.open(CONTACT.github, '_blank', 'noopener,noreferrer');
break;
case 'engineering':
showEngineering();
break;
case 'cad':
showCad();
break;
case 'revit':
showRevit();
break;
case 'excel':
showExcel();
break;
case 'services':
showServices();
break;
case 'open':
await openProjectLink(args.join(' '));
break;
case 'cv':
printLine('Abrindo: João Sinatro - CV.pdf...');
openCvPdf();
break;
case 'curriculo':
printLine('Abrindo currículo web...');
openCurriculoPage();
break;
case '':
break;
default:
printLine(`Comando '${cmd}' inválido. Digite 'help' ou clique nos atalhos.`, { className: 'error' });
}
focusInput();
}
window.executeCommand = executeCommand;
if (inputField) {
inputField.addEventListener('keydown', (e) => {
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'l') {
e.preventDefault();
clearTerminalOutput({ showMessage: true });
focusInput();
return;
}
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 'k') {
e.preventDefault();
inputField.value = '';
focusInput();
return;
}
if (e.key === 'Escape') {
e.preventDefault();
focusInput();
return;
}
if (e.key === 'Enter') {
const cmd = inputField.value;
inputField.value = '';
pushHistory(cmd.trim());
executeCommand(cmd);
return;
}
if (e.key === 'ArrowUp') {
if (!commandHistory.length) return;
e.preventDefault();
historyIndex = Math.max(0, historyIndex - 1);
inputField.value = commandHistory[historyIndex] || '';
return;
}
if (e.key === 'ArrowDown') {
if (!commandHistory.length) return;
e.preventDefault();
historyIndex = Math.min(commandHistory.length, historyIndex + 1);
inputField.value = commandHistory[historyIndex] || '';
return;
}
if (e.ctrlKey && e.key === 'c') {
return;
}
});
}
document.querySelectorAll('.chip').forEach((chip) => {
chip.addEventListener('click', () => {
const cmd = chip.dataset.command;
executeCommand(cmd);
focusInput();
});
});
if (terminalBody) {
terminalBody.addEventListener('click', (e) => {
if (!(e.target instanceof Element)) {
focusInput();
return;
}
const isInteractive = e.target.closest('a, button, input');
if (!isInteractive) {
focusInput();
}
});
}
document.addEventListener('keydown', (event) => {
if (event.target === inputField) return;
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'l') {
event.preventDefault();
clearTerminalOutput({ showMessage: true });
focusInput();
return;
}
if ((event.ctrlKey || event.metaKey) && event.key.toLowerCase() === 'k') {
if (!inputField) return;
event.preventDefault();
inputField.value = '';
focusInput();
return;
}
if (event.key === 'Escape') {
focusInput();
}
});