Skip to content

Commit 375d25d

Browse files
Update script.js
1 parent 1f3ed65 commit 375d25d

1 file changed

Lines changed: 33 additions & 26 deletions

File tree

script.js

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,43 @@
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}"
1+
// Lógica do Tema Claro/Escuro
2+
const themeButton = document.getElementById('theme-button');
3+
const currentTheme = localStorage.getItem('theme');
4+
5+
if (currentTheme) {
6+
document.documentElement.setAttribute('data-theme', currentTheme);
7+
}
8+
9+
themeButton.addEventListener('click', () => {
10+
let theme = document.documentElement.getAttribute('data-theme');
11+
if (theme === 'light') {
12+
document.documentElement.setAttribute('data-theme', 'dark');
13+
localStorage.setItem('theme', 'dark');
14+
} else {
15+
document.documentElement.setAttribute('data-theme', 'light');
16+
localStorage.setItem('theme', 'light');
1317
}
18+
});
19+
20+
// Lógica das Práticas (Exemplo simplificado para funcionar em praticas.html)
21+
const aulasConteudo = {
22+
1: { titulo: "Variáveis", codigo: "let nome = 'Bernardo';\nconsole.log('Olá, ' + nome);" },
23+
2: { titulo: "Funções", codigo: "function soma(a,b){ return a+b; }\nconsole.log(soma(10,5));" },
24+
3: { titulo: "Lógica", codigo: "let pontos = 100;\nif(pontos > 50) console.log('Aprovado!');" }
1425
};
1526

1627
function verAula(id) {
1728
const area = document.getElementById('tutorial-texto');
1829
const aula = aulasConteudo[id];
19-
30+
if(!area) return;
2031
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-
`;
28-
window.scrollTo({top: 0, behavior: 'smooth'});
32+
<div class="card">
33+
<h2>${aula.titulo}</h2>
34+
<textarea id="codigo-editor">${aula.codigo}</textarea>
35+
<button onclick="executar()" class="btn-primary">Executar</button>
36+
<div id="console-output">> Aguardando...</div>
37+
</div>`;
2938
}
3039

31-
function executarCodigo() {
40+
function executar() {
3241
const cod = document.getElementById('codigo-editor').value;
3342
const out = document.getElementById('console-output');
3443
out.innerHTML = "";
@@ -37,7 +46,5 @@ function executarCodigo() {
3746
console.log = (m) => { out.innerHTML += "> " + m + "<br>"; };
3847
eval(cod);
3948
console.log = log;
40-
} catch (e) {
41-
out.innerHTML = "<span style='color:red;'>Erro: " + e.message + "</span>";
42-
}
43-
}
49+
} catch (e) { out.innerHTML = "Erro: " + e.message; }
50+
}

0 commit comments

Comments
 (0)