Skip to content

Commit aaa9bc9

Browse files
Add files via upload
1 parent d3929ac commit aaa9bc9

3 files changed

Lines changed: 142 additions & 179 deletions

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,4 @@ <h3>Comunidade</h3>
6969
<script src="script.js"></script>
7070

7171
</body>
72-
</html>
72+
</html>

script.js

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,43 @@
1-
// CONTROLE DO TEMA
2-
const themeBtn = document.getElementById('theme-button');
3-
themeBtn.addEventListener('click', () => {
4-
const html = document.documentElement;
5-
const isLight = html.getAttribute('data-theme') === 'light';
6-
html.setAttribute('data-theme', isLight ? 'dark' : 'light');
7-
themeBtn.textContent = isLight ? "Modo Claro" : "Modo Escuro";
8-
});
9-
10-
// CONTEÚDO DAS PRÁTICAS
11-
const aulas = {
12-
1: { t: "Variáveis", c: "let mestre = 'Bernardo';\nconsole.log('Professor: ' + mestre);" },
13-
2: { t: "Funções", c: "function acao(){ return 'Codando...'; }\nconsole.log(acao());" },
14-
3: { t: "Lógica", c: "let nota = 10;\nif(nota >= 7) console.log('Aprovado!');" }
1+
const aulasConteudo = {
2+
1: {
3+
titulo: "Praticando Variáveis",
4+
codigo: "let curso = 'JS Master';\nconsole.log('Bem-vindo ao ' + curso);"
5+
},
6+
2: {
7+
titulo: "Praticando Funções",
8+
codigo: "function saudacao(nome) {\n return 'Olá ' + nome;\n}\nconsole.log(saudacao('Bernardo'));"
9+
},
10+
3: {
11+
titulo: "Praticando Lógica",
12+
codigo: "let pontos = 80;\nif(pontos >= 50) {\n console.log('Aprovado!');\n} else {\n console.log('Reprovado');\n}"
13+
}
1514
};
1615

1716
function verAula(id) {
18-
const local = document.getElementById('tutorial-texto');
19-
const item = aulas[id];
20-
local.innerHTML = `
21-
<div class="card">
22-
<h3>Desafio: ${item.t}</h3>
23-
<textarea id="codigo-editor">${item.c}</textarea>
24-
<button onclick="rodar()" class="btn-primary" style="margin-top:10px;">Executar Código</button>
25-
<div id="console-output">> Aguardando...</div>
26-
</div>`;
17+
const area = document.getElementById('tutorial-texto');
18+
const aula = aulasConteudo[id];
19+
20+
area.innerHTML = `
21+
<div style="background: #1e293b; padding: 20px; border-radius: 12px; border: 2px solid #f7df1e; margin-bottom: 30px;">
22+
<h2 style="color: #f7df1e; font-family: 'Playwrite IE Sj', cursive;">${aula.titulo}</h2>
23+
<textarea id="codigo-editor" style="width:100%; height:100px; background:#000; color:#4ade80; font-family:monospace; padding:10px; margin:10px 0;">${aula.codigo}</textarea>
24+
<button onclick="executarCodigo()" class="btn-primary">▶ Executar</button>
25+
<div id="console-output" style="background:#000; color:#fff; padding:10px; margin-top:10px; border-radius:5px; font-family:monospace;">> Aguardando...</div>
26+
</div>
27+
`;
2728
window.scrollTo({top: 0, behavior: 'smooth'});
2829
}
2930

30-
function rodar() {
31+
function executarCodigo() {
3132
const cod = document.getElementById('codigo-editor').value;
3233
const out = document.getElementById('console-output');
3334
out.innerHTML = "";
3435
try {
35-
const originalLog = console.log;
36+
const log = console.log;
3637
console.log = (m) => { out.innerHTML += "> " + m + "<br>"; };
3738
eval(cod);
38-
console.log = originalLog;
39-
} catch(e) { out.innerHTML = "Erro: " + e.message; }
40-
}
39+
console.log = log;
40+
} catch (e) {
41+
out.innerHTML = "<span style='color:red;'>Erro: " + e.message + "</span>";
42+
}
43+
}

0 commit comments

Comments
 (0)