This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Humano { | |
public $nome = ''; | |
public $idade = 0; | |
public $saudacao = ''; | |
private $apelido = ''; | |
private $acordado = true; //observe que $acordado é uma propriedade privada | |
//esse método é chamado quando o objeto é instanciado | |
//usado para atribuir propriedades e chamar métodos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//vamos criar uma classe Robot, que tem certos atributos | |
class Robot { | |
public $nome = ''; //um nome que também pode ser um número de série | |
public $bracos = 0; //quantidade de braços | |
public $rodas = 0; //quantidade de rodas | |
public $aparencia = ''; //aparencia, porque o robô pode parecer com alguma coisa | |
public $alinhamento = ''; //alinhamento, se é bom, mau ou neutro, ou misturas disso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//imaginemos um objeto Carro, que recebe nome, marca, chassi e acao | |
//como argumentos o quarto parametro é uma função | |
var Carro = function (nome, marca, chassi, acao) { | |
this.nome = nome; //o nome do carro é setado | |
this.marca = marca; //a marca do carro é setada | |
//numeroChassi é uma variável privada que recebe o chassi | |
//passado como argumento | |
//mensagem é uma variável privada que recebe uma string vazia |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="callback.css"> | |
<script type="text/javascript" src="callback.js"></script> | |
</head> | |
<body> | |
<div id="mainDiv"> | |
<button>Botao 1</button> | |
<button>Botao 2</button> | |
<button>Botao 3</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#mainDiv { | |
min-height: 600px; | |
width: 600px; | |
margin: 0 auto; | |
border: solid 1px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//hoje veremos mais um pouco sobre callbacks | |
//Se pararmos para analisar, esse recurso que vínhamos | |
//usando: window.onload = function... é na verdade um callback | |
//SIM! na verdade estamos passando uma função para ser executada | |
//quando os elementos já tiverem sido renderizados na janela | |
window.onload = function () { | |
//Estamos criando um callback personalizado | |
var meuCallback = function (event) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="pt" dir="ltr" class="client-nojs"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script type="text/javascript" src="arguments.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"></div> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="pt" dir="ltr" class="client-nojs"> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<script type="text/javascript" src="ajax-sem-jquery.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"> | |
<button id="button-ajax">Fazer nova solitação Ajax</button> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Aqui declaramos todas as variáveis que serão usadas | |
var requisicao = null, | |
serverResponse = null, | |
parsedData = null; | |
//esse callback (SIM, olha ele aí de novo) será chamado | |
//quando o evento 'onreadystatechange' for disparado | |
var meuCallback = function (data) { | |
//um parâmetro 'data' é passado para o callback quando este é chamado |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Aqui no Backend criamos uma variável 'data' | |
$data = array(); | |
//o primeiro índice recebe um objeto com 'nome' e 'amo de nascimento' | |
$data[0] = array('nome'=> 'Isaac Newton', 'ano de nascimento'=>1727); | |
$data[1] = array('nome'=> 'Nikola Tesla', 'idade'=>1856); | |
//o parametro 'numeroAleatorio' receberá um número aleatório gerado |
OlderNewer