-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
116 lines (101 loc) · 2.76 KB
/
index.html
File metadata and controls
116 lines (101 loc) · 2.76 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
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Pitugues Script</title>
<style>
:root {
--fundo: linear-gradient(135deg, #e8f8f5, #fef9e7);
--papel: #ffffff;
--texto: #1b2631;
--primaria: #0f766e;
--primaria-escura: #115e59;
--borda: #d5dbdb;
}
body {
margin: 0;
padding: 24px;
font-family: "Trebuchet MS", "Fira Sans", sans-serif;
background: var(--fundo);
color: var(--texto);
}
main {
max-width: 920px;
margin: 0 auto;
background: var(--papel);
border-radius: 14px;
box-shadow: 0 16px 36px rgba(17, 24, 39, 0.12);
padding: 24px;
}
h1 {
margin: 0 0 8px;
}
p {
margin-top: 0;
}
button {
border: none;
border-radius: 10px;
background: var(--primaria);
color: #fff;
padding: 10px 16px;
cursor: pointer;
transition: background 0.2s ease;
}
button:hover {
background: var(--primaria-escura);
}
pre {
background: #111827;
color: #d1fae5;
border: 1px solid var(--borda);
border-radius: 10px;
min-height: 120px;
margin-top: 16px;
padding: 14px;
overflow: auto;
white-space: pre-wrap;
}
</style>
</head>
<body>
<main>
<h1>Pitugues em script tags</h1>
<p>Este exemplo usa o runtime em TypeScript para executar Pitugues no navegador.</p>
<button id="botao-alerta">Clique para testar bind() + alert()</button>
<pre id="saida"></pre>
</main>
<script type="text/pitugues" id="exemplo-principal">
importar { bind, document, alert } de dom
imprima("Ola do Pitugues Script!")
valores = [1, 2, 3, 4, 5]
funcao quadrado(n):
retorna n ** 2
imprima(valores.mapear(quadrado))
funcao ao_clicar(evento):
alert("Evento de DOM acionado por Pitugues!")
bind("#botao-alerta", "click", ao_clicar)
</script>
<script src="./node_modules/@designliquido/delegua/umd/delegua.js"></script>
<script src="./dist/pitugues-script.js"></script>
<script>
const saida = document.getElementById('saida');
window
.pitugues({
ids: ['exemplo-principal'],
autoIniciar: false,
saida: (texto) => {
if (!saida) return;
saida.textContent += texto + '\n';
},
})
.then((resultados) => {
const falhas = resultados.filter((r) => !r.sucesso);
if (falhas.length > 0) {
console.error('Falhas Pitugues:', falhas);
}
});
</script>
</body>
</html>