-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIndex.html
More file actions
241 lines (222 loc) · 10.1 KB
/
Index.html
File metadata and controls
241 lines (222 loc) · 10.1 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
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DarkPy - Aprenda Python</title>
<style>
body { margin:0; font-family: 'Consolas', monospace; background:#121212; color:#e0e0e0; }
.container { padding:20px; max-width:600px; margin:auto; position:relative; }
input, button, textarea { width:100%; padding:10px; margin:10px 0; border:none; border-radius:5px; font-size:16px; }
input { background:#1e1e1e; color:#e0e0e0; }
button { background:#39ff14; color:#121212; font-weight:bold; cursor:pointer; transition:0.2s; }
button:hover { box-shadow:0 0 10px #39ff14; }
textarea { background:#1e1e1e; color:#e0e0e0; height:150px; resize:none; font-family: 'Consolas', monospace;}
nav { display:flex; justify-content:space-around; margin-bottom:20px; }
nav button { width:auto; padding:10px 20px; }
.hidden { display:none; }
.neon { color:#39ff14; text-shadow:0 0 5px #39ff14; }
#saida, #explicacao { background:#1e1e1e; padding:10px; border-radius:5px; white-space:pre-wrap; margin-top:10px;}
#criador { position:absolute; top:10px; right:10px; color:#39ff14; font-weight:bold; }
</style>
</head>
<body>
<!-- Nome do criador -->
<div id="criador">MITNICK</div>
<!-- Tela Cadastro -->
<div id="cadastro" class="container">
<h1 class="neon">DarkPy - Cadastro</h1>
<input type="text" id="nome" placeholder="Nome">
<input type="number" id="idade" placeholder="Idade">
<input type="email" id="email" placeholder="Email">
<input type="tel" id="telefone" placeholder="Número de telefone">
<button onclick="cadastrar()">Prosseguir</button>
</div>
<!-- Tela App -->
<div id="app" class="container hidden">
<h1 class="neon">DarkPy - Aprenda Python</h1>
<nav>
<button onclick="showSection('tarefas')">Tarefas</button>
<button onclick="showSection('estudo')">Central de Estudo</button>
</nav>
<!-- Tarefas -->
<div id="tarefas">
<h2>Tarefas Python</h2>
<p id="descricao"></p>
<textarea id="codigo"></textarea>
<button onclick="rodarCodigo()">Rodar Código</button>
<pre id="saida">(Saída aparecerá aqui)</pre>
<button onclick="testarTarefa()">Verificar Tarefa</button>
<p class="neon">XP: <span id="xp">0</span></p>
<button onclick="proximaTarefa()">Próxima Tarefa</button>
<pre id="explicacao">(Explicação aparecerá aqui)</pre>
</div>
<!-- Central de Estudo -->
<div id="estudo" class="hidden">
<h2>Central de Estudo</h2>
<ul>
<li><a href="https://www.youtube.com/@CoreySchafer" target="_blank">Corey Schafer - YouTube</a></li>
<li><a href="https://www.youtube.com/@ProgrammingwithMosh" target="_blank">Programming with Mosh - YouTube</a></li>
<li><a href="https://www.w3schools.com/python/" target="_blank">W3Schools Python</a></li>
<li><a href="https://www.geeksforgeeks.org/python-programming-language/" target="_blank">GeeksforGeeks Python</a></li>
</ul>
</div>
</div>
<script src="https://cdn.jsdelivr.net/pyodide/v0.23.4/full/pyodide.js"></script>
<script>
let pyodideReady=false, pyodide=null;
async function loadPyodideAndPackages(){
pyodide = await loadPyodide();
pyodideReady=true;
}
loadPyodideAndPackages();
/* --- Cadastro --- */
function validarEmail(email){ return /\S+@\S+\.\S+/.test(email); }
function validarTelefone(tel){ return /^\d{10,}$/.test(tel); }
function cadastrar(){
const nome = document.getElementById('nome').value.trim();
const idade = document.getElementById('idade').value.trim();
const email = document.getElementById('email').value.trim();
const telefone = document.getElementById('telefone').value.trim();
if(!nome || !idade || !email || !telefone){ alert("Preencha todos os campos!"); return; }
if(!validarEmail(email)){ alert("Email inválido!"); return; }
if(!validarTelefone(telefone)){ alert("Telefone inválido! Use pelo menos 10 números."); return; }
const usuarios = JSON.parse(localStorage.getItem('usuarios')||"[]");
let idx = usuarios.findIndex(u=>u.email===email);
if(idx>=0){ usuarios[idx]={nome, idade, email, telefone}; }
else{ usuarios.push({nome, idade, email, telefone}); }
localStorage.setItem('usuarios', JSON.stringify(usuarios));
localStorage.setItem('usuarioAtual', email);
document.getElementById('cadastro').classList.add('hidden');
document.getElementById('app').classList.remove('hidden');
carregarProgresso();
iniciarTarefas();
}
/* --- Navegação --- */
function showSection(sec){
['tarefas','estudo'].forEach(id=>document.getElementById(id).classList.add('hidden'));
document.getElementById(sec).classList.remove('hidden');
}
/* --- Botão Secreto Mitnick --- */
let contadorClique=0;
document.body.addEventListener('click', e=>{
if(e.clientX>window.innerWidth*0.8 && e.clientY<window.innerHeight*0.2){
contadorClique++;
if(contadorClique>=5){ contadorClique=0; acessarMitnick(); }
}
});
function acessarMitnick(){
const senha = prompt("Senha Mitnick:");
if(senha==="404"){
const usuarios = JSON.parse(localStorage.getItem('usuarios')||"[]");
let lista="<h3>Usuários cadastrados:</h3><ul>";
usuarios.forEach(u=>{ lista+=`<li>${u.nome} | ${u.idade} | ${u.email} | ${u.telefone}</li>`; });
lista+="</ul>";
const div=document.createElement('div');
div.style.background="#1e1e1e"; div.style.padding="10px"; div.style.margin="10px 0"; div.style.borderRadius="5px";
div.innerHTML=lista;
document.body.appendChild(div);
}else{ alert("Acesso negado!"); }
}
/* --- Tarefas --- */
const tarefas=[
{descricao:'Escreva "Olá Mundo" usando print()', validar:c=>c.includes('print("Olá Mundo")'), explicacao:"Objetivo: Exibir 'Olá Mundo'."},
{descricao:'Crie a=5 e b=3 e some, mostre resultado', validar:c=>c.includes("a+b"), explicacao:"Objetivo: Somar a+b e mostrar."},
{descricao:"Verifique se idade >=18 e mostre 'Maior de idade'", validar:c=>c.includes("if") && c.includes("Maior de idade"), explicacao:"Objetivo: Usar if/else para idade."}
];
let tarefaAtual=0, xp=0, codigosSalvos={};
/* --- Progresso --- */
function salvarProgresso(){
const email = localStorage.getItem('usuarioAtual');
if(!email) return;
const data={tarefaAtual,xp,codigosSalvos};
localStorage.setItem("progresso_"+email, JSON.stringify(data));
}
function carregarProgresso(){
const email=localStorage.getItem('usuarioAtual');
if(!email) return;
const data=JSON.parse(localStorage.getItem("progresso_"+email)||"{}");
if(data.tarefaAtual!==undefined) tarefaAtual=data.tarefaAtual;
if(data.xp!==undefined) xp=data.xp;
if(data.codigosSalvos) codigosSalvos=data.codigosSalvos;
document.getElementById('xp').innerText=xp;
}
/* --- Tarefas --- */
function iniciarTarefas(){ mostrarTarefa(); }
function mostrarTarefa(){
document.getElementById('descricao').innerText=tarefas[tarefaAtual].descricao;
document.getElementById('codigo').value = codigosSalvos[tarefaAtual] || "";
document.getElementById('saida').innerText="(Saída aparecerá aqui)";
document.getElementById('explicacao').innerText="(Explicação aparecerá aqui)";
}
/* --- Rodar Código --- */
async function rodarCodigo(){
if(!pyodideReady){ alert("Carregando Python..."); return; }
const codigo=document.getElementById('codigo').value;
codigosSalvos[tarefaAtual]=codigo;
salvarProgresso();
try{
await pyodide.runPythonAsync(`
import sys
class Captura:
def __init__(self):
self.text=""
def write(self, txt): self.text+=txt
def flush(self): pass
captura=Captura()
sys.stdout=captura
sys.stderr=captura
`);
await pyodide.runPythonAsync(codigo);
const output=pyodide.runPython("captura.text");
document.getElementById('saida').innerText=output||"(Sem saída)";
}catch(err){ document.getElementById('saida').innerText="Erro:\n"+err; }
}
/* --- Explicação linha por linha --- */
function explicaCodigo(codigo){
const linhas = codigo.split("\n");
let explicacao = "";
linhas.forEach((linha, idx)=>{
const l = linha.trim();
if(l.startsWith("print(")){
explicacao += `Linha ${idx+1}: print() → Exibe o conteúdo na tela.\n`;
} else if(l.includes("=") && !l.includes("==")){
const varName = l.split("=")[0].trim();
explicacao += `Linha ${idx+1}: ${varName} = ... → Cria uma variável '${varName}' com valor.\n`;
} else if(l.startsWith("if ")){
explicacao += `Linha ${idx+1}: if → Verifica uma condição. Se verdadeira, executa o bloco.\n`;
} else if(l.startsWith("else")) {
explicacao += `Linha ${idx+1}: else → Executa se a condição do if anterior for falsa.\n`;
} else if(l.includes("+") || l.includes("-") || l.includes("*") || l.includes("/")){
explicacao += `Linha ${idx+1}: Operação matemática → Calcula o valor usando operadores.\n`;
} else if(l === ""){
explicacao += `Linha ${idx+1}: Linha em branco (sem efeito).\n`;
} else {
explicacao += `Linha ${idx+1}: Comando: ${l}\n`;
}
});
return explicacao;
}
/* --- Testar tarefa --- */
function testarTarefa(){
const codigo = document.getElementById('codigo').value;
codigosSalvos[tarefaAtual] = codigo;
salvarProgresso();
const explicacaoDetalhada = explicaCodigo(codigo);
if(tarefas[tarefaAtual].validar(codigo)){
alert("Parabéns! Tarefa concluída ✅");
xp += 10;
document.getElementById('xp').innerText = xp;
document.getElementById('explicacao').innerText = tarefas[tarefaAtual].explicacao + "\n\nExplicação detalhada do código:\n" + explicacaoDetalhada;
} else {
document.getElementById('explicacao').innerText = "Ops! Tente novamente.\nDica: " + tarefas[tarefaAtual].explicacao + "\n\nExplicação detalhada do código:\n" + explicacaoDetalhada;
}
}
/* --- Próxima tarefa --- */
function proximaTarefa(){
if(tarefaAtual<tarefas.length-1){ tarefaAtual++; mostrarTarefa(); salvarProgresso(); }
else{ alert("Você concluiu todas as tarefas do módulo!"); }
}
</script>
</body>
</html>