Skip to content

Commit 979f911

Browse files
Update script.js
1 parent 5421103 commit 979f911

1 file changed

Lines changed: 20 additions & 22 deletions

File tree

script.js

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,36 @@
1-
// Lógica do Tema Claro/Escuro
1+
// CONTROLE DE TEMA
22
const themeButton = document.getElementById('theme-button');
3-
const currentTheme = localStorage.getItem('theme');
3+
const storedTheme = localStorage.getItem('theme') || 'dark';
44

5-
if (currentTheme) {
6-
document.documentElement.setAttribute('data-theme', currentTheme);
7-
}
5+
document.documentElement.setAttribute('data-theme', storedTheme);
86

97
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');
17-
}
8+
let currentTheme = document.documentElement.getAttribute('data-theme');
9+
let newTheme = currentTheme === 'light' ? 'dark' : 'light';
10+
11+
document.documentElement.setAttribute('data-theme', newTheme);
12+
localStorage.setItem('theme', newTheme);
1813
});
1914

20-
// Lógica das Práticas (Exemplo simplificado para funcionar em praticas.html)
15+
// SISTEMA DE PRÁTICAS
2116
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!');" }
17+
1: { titulo: "Variáveis", codigo: "let aluno = 'Bernardo';\nconsole.log('Bem-vindo, ' + aluno);" },
18+
2: { titulo: "Funções", codigo: "function tchau(){ return 'Até logo!'; }\nconsole.log(tchau());" }
2519
};
2620

2721
function verAula(id) {
2822
const area = document.getElementById('tutorial-texto');
2923
const aula = aulasConteudo[id];
3024
if(!area) return;
25+
3126
area.innerHTML = `
32-
<div class="card">
33-
<h2>${aula.titulo}</h2>
27+
<div class="card" style="background: var(--bg-color); color: var(--text-color);">
28+
<h2 style="color: var(--accent)">Editando: ${aula.titulo}</h2>
3429
<textarea id="codigo-editor">${aula.codigo}</textarea>
35-
<button onclick="executar()" class="btn-primary">Executar</button>
36-
<div id="console-output">> Aguardando...</div>
30+
<button onclick="executar()" class="btn-primary">RODAR CÓDIGO</button>
31+
<div id="console-output">> Resultado aparecerá aqui...</div>
3732
</div>`;
33+
window.scrollTo({top: 0, behavior: 'smooth'});
3834
}
3935

4036
function executar() {
@@ -46,5 +42,7 @@ function executar() {
4642
console.log = (m) => { out.innerHTML += "> " + m + "<br>"; };
4743
eval(cod);
4844
console.log = log;
49-
} catch (e) { out.innerHTML = "Erro: " + e.message; }
45+
} catch (e) {
46+
out.innerHTML = "<span style='color:red;'>Erro: " + e.message + "</span>";
47+
}
5048
}

0 commit comments

Comments
 (0)