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
function Player() { | |
} | |
Player.prototype.play = function(song) { | |
this.currentlyPlayingSong = song; | |
this.isPlaying = true; | |
}; | |
Player.prototype.pause = function() { | |
this.isPlaying = false; | |
}; |
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 vamos descrever o teste para Player | |
describe("Player", function() { | |
//criamos as variáveis player e song | |
var player; | |
var song; | |
//beforeEach, como a tradução indica, cria um novo Player | |
//e um novo Song antes de cada teste | |
beforeEach(function() { | |
player = new Player(); |
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<link rel="stylesheet" type="text/css" href="css/style.css"> | |
<script type="text/javascript" src="js/jquery-1.9.0.js"></script> | |
<script type="text/javascript" src="js/Form.js"></script> | |
</head> | |
<body> | |
<!-- Poderíamos usar a tag form aqui, no entanto, |
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
/*vamos especificar uma largura fixa para a div | |
assim, quando definimos a margem com '40px auto' | |
ela terá margem superior e inferior igual a 40px e | |
será centralizada por causa do 'auto' | |
Note que eu especifiquei somente dois 'números', | |
porque dessa forma é entendido que a margem superior | |
e inferior são iguais a 40 e a da esquerda e direita | |
são 'auto' | |
*/ | |
#main-form { |
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
//Criamos um objeto Form | |
var Form = function () { | |
return { | |
init: function () { | |
//O método init deve ser nosso construtor | |
//chamamos o método setEvents | |
this.setEvents(); | |
}, |
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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Form Runner</title> | |
<link rel="stylesheet" type="text/css" href="lib/jasmine-1.3.1/jasmine.css"> | |
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine.js"></script> | |
<script type="text/javascript" src="lib/jasmine-1.3.1/jasmine-html.js"></script> |
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
validateUsername: function (username) { | |
//Esse método usa VÁRIAS regex para validar o parâmetro 'username' | |
//e retorna true num caso e false caso não entre no if | |
if ( !(/[^a-z0-9._]/g).test(username) && | |
(/^[a-z]/g).test(username) && | |
username.search(/\..*\.|_.*_/g) === -1 && | |
username.search(/[a-z].*[a-z].*[a-z]/g) >= 0 && | |
username.length > 5 ) { |
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
//Abra seu firebug na aba de Rede para ver as solicitações para o servidor | |
window.onload = function () { | |
//Quando clicamos no botão com a id 'picture' | |
$('#picture').on('click', function () { | |
//vamos armazenar o objeto jQuery numa variável | |
var entirePhoto = $('#entire-photo'); | |
//escondemos o formulário de contato |
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 PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> | |
<head> | |
<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> | |
<script type="text/javascript" src="js/jquery-1.9.0.js"></script> | |
<script type="text/javascript" src="js/conteudo-on-demand.js"></script> | |
</head> | |
<body> | |
<div id="wrapper"> | |
<img src="perfil.jpeg" alt="foto do perfil"> |
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
<div> | |
<label> | |
Nome: | |
</label> | |
<div> | |
<input type="text" name="nome"> | |
</div> | |
<label> | |
Email: | |
</label> |