File tree 4 files changed +58
-14
lines changed
4 files changed +58
-14
lines changed Original file line number Diff line number Diff line change @@ -142,12 +142,58 @@ function adicionar() {
142
142
function testar ( ) {
143
143
console . log ( "1" ) ;
144
144
let x = 0 ;
145
+ // executa função de forma assíncrona
145
146
setTimeout ( function ( ) {
146
147
x ++ ;
147
148
console . log ( "2" ) ;
148
149
} , 0 ) ;
149
150
console . log ( "3" ) ;
150
151
}
152
+ // criando como class
153
+ // class Pessoa {
154
+ // constructor() {
155
+ // this.cpf = "";
156
+ // this.nome = "";
157
+
158
+ // //arrow function
159
+ // const Outra = () => { // não usa a palavra function
160
+ // // function Outra() {
161
+ // this.printCpf();
162
+ // };
163
+
164
+ // Outra();
165
+ // }
166
+ // printCpf() {
167
+ // console.log("CPF: ", this.cpf); // this: objeto do contexto
168
+ // };
169
+ // }
170
+
171
+ // criando como function
172
+ function Pessoa ( ) {
173
+ this . cpf = "" ;
174
+ this . nome = "" ;
175
+ //arrow function
176
+ const Outra = ( ) => this . printCpf ( )
177
+
178
+ // não usa a palavra function
179
+ // function Outra() { }
180
+ Outra ( ) ;
181
+ }
182
+
183
+ Pessoa . prototype . printCpf = function ( ) {
184
+ console . log ( "CPF: " , this . cpf ) ; // this: objeto do contexto
185
+ } ;
186
+
187
+ Pessoa . prototype . printNome = function ( ) {
188
+ console . log ( "Nome: " , this . cpf ) ;
189
+ } ;
190
+
191
+ // metodo != função
192
+ function printPorLinha ( ) {
193
+ for ( let parametro of arguments ) {
194
+ console . log ( parametro ) ;
195
+ }
196
+ }
151
197
152
198
// HTTP : HyperText Transfer Protocol - protocolo de transferência de hypertexto
153
199
Original file line number Diff line number Diff line change 25
25
< a href ="# " onclick ="transitionTo(event, '/primo') "> Primo</ a >
26
26
< button onclick ="testar() " type ="button "> Testar</ button > < br >
27
27
< div id ="container " class ="content conteudo corpo-pagina etc-etc ">
28
+
28
29
</ div >
29
30
<!-- <div style="position:fixed;top:0;width:100%;height:100%">
30
31
LOADER
Original file line number Diff line number Diff line change 1
- Math . sqrt ( 9 ) ;
2
-
3
1
function carregarConteudo ( ) {
4
2
let path = window . location . pathname ;
5
3
let html = "" ;
6
- switch ( path ) {
4
+ switch ( path ) { // verifica qual é a rota
7
5
case "/" :
8
6
html = "formulario.html" ;
9
7
break ;
@@ -22,22 +20,21 @@ function carregarConteudo() {
22
20
// serializa para texto -> container.innerHTML = texto
23
21
if ( html != "" ) {
24
22
fetch ( html ) // Promise
25
- . then ( function ( resposta ) { // quando o servidor retornar a resposta HTTP
26
- return resposta . text ( ) ; // Segunda Promise
27
- } )
28
- . then ( function ( texto ) { // quando a resposta for transformada em string
29
- container . innerHTML = texto ;
23
+ . then (
24
+ // quando o servidor retornar a resposta HTTP
25
+ resposta => resposta . text ( ) // Segunda Promise
26
+ )
27
+ // quando a resposta for transformada em string
28
+ . then ( function ( texto ) {
29
+ container . innerHTML = texto
30
30
} ) ;
31
31
}
32
- console . log ( )
33
32
}
34
33
35
34
function transitionTo ( event , path ) {
36
35
event . preventDefault ( ) ; // impede que a tag "a" ao ser clicada redirecione a pagina
37
- window . history . pushState ( "" , "" , path ) ;
36
+ window . history . pushState ( "" , "" , path ) ; // troco apenas a url sem redirecionar
38
37
carregarConteudo ( ) ;
39
38
}
40
39
41
- window . addEventListener ( "load" , function ( ) {
42
- carregarConteudo ( ) ;
43
- } ) ;
40
+ window . addEventListener ( "load" , ( ) => carregarConteudo ( ) ) ;
Original file line number Diff line number Diff line change 3
3
PORT = 8000
4
4
class SimpleHandler (http .server .SimpleHTTPRequestHandler ):
5
5
def do_GET (self ):
6
- match = re .search ("\.(js|ico|html|png|css|map)$" , self .path )
6
+ match = re .search ("\.(js|ico|html|png|css|map)$" , self .path ) # self é o this em python
7
7
res = None
8
8
self .send_response (200 )
9
9
filename = "index.html" if match == None else self .path [1 :]
You can’t perform that action at this time.
0 commit comments