- Christian Sakai -
<a href="http://google.com">Click here to go to Google</a><tag-name tag-attr-one="tag-value-one" tag-attr-two="tag-value-two">tag-content</tag-name><!-- this is a comment -->
<!DOCTYPE html> <!-- defines the document type -->
<html></html> <!-- the root of our HTML document -->
<head></head> <!-- the head section -->
<body></body> <!-- the body section --><meta></meta> <!-- metadata about an HTML document, can be more than one -->
<title></title> <!-- title of an HTML document -->
<!-- link to an external resource (most used to link to style sheets) and fonts -->
<link></link> <!DOCTYPE html> <!-- denotes that this is an HTML document -->
<html>
<head>
<meta charset="utf-8"> <!-- the encoding attribute with utf-8 as the value -->
<meta name="viewport" content="width=device-width"> <!-- responsive configuration -->
<title>Intro to Web Development</title>
<!-- font styles -->
<link href='https://fonts.googleapis.com/css?family=Orbitron'
rel='stylesheet'
type='text/css'>
<!-- local css styles -->
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- later the content of the website is here -->
</body>
</html><div><div>
<h1>Heading 1</h1> <!-- heading tags from 1 to 6 (largest to smallest) -->
<p>This is a paragraph</p>
<a href="https://www.facebook.com">Click here to go to Facebook</a>
<img src="image/cat.jpg"></img>
<input type="text"></input>
<button>Click me</button>
<!-- connect your JavaScript here, can also code it inside -->
<script src="js/app.js">
console.log("hello world")
// bunch of other JavaScript code
</script>
<!DOCTYPE html> <!-- denotes that this is an HTML document -->
<html>
<head>
<meta charset="utf-8"> <!-- the encoding attribute with utf-8 as the value -->
<meta name="viewport" content="width=device-width"> <!-- responsive configuration -->
<title>Intro to Web Development</title>
<!-- font styles -->
<link href='https://fonts.googleapis.com/css?family=Orbitron'
rel='stylesheet'
type='text/css'>
<!-- local css styles -->
<link href="css/style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div>
<!-- game intro -->
<div>
<h3>Guess a Number!</h3>
<p>
This is a guessing number game. Please type a number between 1-100 and click Guess!
</p>
<div>
<!-- end game intro -->
<!-- game summary -->
<div>
<h1>Are you going to win?</h1>
<div>
<!-- end summary -->
<!-- game input -->
<div>
<input type="text">
<button type="button">Guess!</button>
</div>
<!-- end game input -->
</div>
<!-- JavaScript that does the magic -->
<script src="js/app.js"></script>
</body>
</html>http://www.w3schools.com/tags/default.asp
// Create this folder structure below
guessing-game
| css/style.css
| js/app.js
| index.html
// Copy the code from previous slide to index.htmlselector {
attribute-one: value-one;
attribute-two: value-two;
}.h1 {
color: red;
font-size: 20px;
}h1, h2, h3, h4, h5, h6, p {
color: black;
}
.awesome-section {
padding: 10px;
background-color: pink;
}
#click-button {
font-weight: bold;
}<div class="awesome-section"></div>
<button id="click-button"></button>p {
color: pink;
}
div p {
color: black;
}
<p>This will be pink</p>
<div>
<article>
<p>But this will be black</p>
</article>
</div>p {
color: pink;
}
div p {
color: black;
}
div > p {
color: red;
}
<p>This will be pink</p>
<div>
<article>
<p>But this will be black</p>
</article>
</div>
<div>
<p>And this will be red</p>
</div>h1, h2, h3, h4, h5, h6, p {
color: black;
}
h1 {
color: pink;
}
body {
color: blue;
}
/* no rule for <p> here */<body>
<p>I will be blue</p>
</body><h1>I am pink!</h1>
<h4>but I am black</h4>
p {
color: black;
}
#red-id {
color: red;
}
.blue-class {
color: blue;
}<p class="blue-class" id="red-id">
Will I be blue or red or black?
</p><p class="blue-class" id="red-id" style="color: yellow;">
How about me? Will I be blue or red or black or yellow?
</p><body>
<div>
<!-- game intro -->
<div>
<h3>Guess a Number!</h3>
<p>
This is a guessing number game. Please type a number between 1-100 and click Guess!
</p>
<div>
<!-- end game intro -->
<!-- game summary -->
<div>
<h1>Are you going to win?</h1>
<div>
<!-- end game summary -->
<!-- game input -->
<div>
<input type="number">
<button type="button">Guess!</button>
</div>
<!-- end game input -->
</div>
<!-- JavaScript that does the magic -->
<script src="js/app.js"></script>
</body>
<!-- font styles -->
<link href='https://fonts.googleapis.com/css?family=Orbitron'
rel='stylesheet'
type='text/css'>
<!-- local css styles -->
<link href="css/style.css" rel="stylesheet" type="text/css">
// Remember this folder structure?
guessing-game
| css/style.css
| js/app.js
| index.html
// Put your css code in css/style.css<body>
<div class="game-board">
<!-- game intro -->
<div class="game-intro">
<h3>Guess a Number!</h3>
<p>
This is a guessing number game. Please type a number between 1-100 and click Guess!
</p>
<div>
<!-- end game intro -->
<!-- game summary -->
<div class="game-summary">
<h1 id="result">Are you going to win?</h1>
<div>
<!-- end game summary -->
<!-- game input -->
<div class="game-input">
<input type="number" id="user-input">
<button type="button" id="guess-button">Guess!</button>
</div>
<!-- end game input -->
</div>
<!-- JavaScript that does the magic -->
<script src="js/app.js"></script>
</body>
body {
font-family: Orbitron;
color: green;
}
.game-board {
border: 3px solid green;
padding: 10px;
border-radius: 5px;
}
.game-intro h3 {
text-align: center;
}
.game-intro p {
text-align: center;
}
.game-summary h1 {
text-align: center;
}
.game-input {
text-align: center;
}
.game-input input {
width: 50px;
border-radius: 5px;
font-size: 30px;
}
.game-input button {
font-size: 30px;
border-radius: 5px;
background-color: white;
border: 3px solid green;
color: green;
}<body>
<div class="game-board">
<!-- game intro -->
<div class="game-intro">
<h3>Guess a Number!</h3>
<p>
This is a guessing number game. Please type a number between 1-100 and click Guess!
</p>
<div>
<!-- end game intro -->
<!-- game summary -->
<div class="game-summary">
<h1 id="result">Are you going to win?</h1>
<div>
<!-- end game summary -->
<!-- game input -->
<div class="game-input">
<input type="number" id="user-input">
<button type="button" id="guess-button">Guess!</button>
</div>
<!-- end game input -->
</div>
<!-- JavaScript that does the magic -->
<script src="js/app.js"></script>
</body>
http://www.w3schools.com/css/default.asp
Behavior or Presentation?
var hello = "hello";
var world = "world";
console.log(hello + " " + world + "!"); // "hello world!"
var a = 3;
var b = 2;
var multiply = a * b;
console.log(multiply); // 6
Try it in your browser console
var myArray = [1, 2, 3, "hello", "world"];
console.log(myArray[0]); // 1
console.log(myArray[4]); // "hello"
var myObject = {
name: "Christian",
gender: "male"
};
console.log(myObject); // { name: "Christian", gender: "male" }
console.log(myObject.gender); // "male"Try it in your browser console
var add = function(a, b) {
return a + b;
};
console.log(add(1, 2)); // 3
Try it in your browser console
Pass function into functions
var adder = function(a, b) {
return a + b;
};
var calculate = function(a, b, calculatingFunction) {
var result = calculatingFunction(a, b);
return result;
};
console.log(calculate(1, 2, adder)); // 3
var x = 2;
var y = 3;
var changeValueOfXAndY = function() {
x = 5;
var y = 4;
};
changeValueOfXandY();
console.log(x); // 5
console.log(y); // 3
Try it in your browser console
var makeAdder = function(num) {
var adderNumber = num;
var add = function(numToBeAdded) {
return adderNumber + numToBeAdded;
};
return add;
};
var adderFunc = makeAdder(2);
console.log(adderFunc(3)); // 5Try it in your browser console
<p id="paragraph">This is a paragraph</p>// Get the element with id="paragraph"
var paragraphNode = document.getElementById("paragraph");
// change the style color to red
paragraphNode.style.color = "red";<input type="text" id="user-input">// Get the element with id="user-input"
var userInputNode = document.getElementById("user-input");
// get the value of the user input
userInputNode.value;
<button type="button" id="guess-button">Guess!</button>
// Get the element with id="guess-button"
var guessButtonNode = document.getElementById("guess-button");
// Attach a click event handler to the element
guessButtonNode.onclick = function() {
// something to be executed
};<!-- game summary -->
<div class="game-summary">
<h1 id="result">Are you going to win?</h1>
</div>
<!-- end game summary -->
<!-- game input -->
<div class="game-input">
<input type="number" id="user-input">
<button type="button" id="guess-button">Guess!</button>
</div>
<!-- end game input -->// Remember this folder structure?
guessing-game
| css/style.css
| js/app.js
| index.html
// Put your js code in js/app.jsWhen the use clicks the button, we want to get the input. If the user is correct, render "WIN" to the result, "LOSE" otherwise.
<!-- game summary -->
<div class="game-summary">
<h1 id="result">Are you going to win?</h1>
</div>
<!-- end game summary -->
<!-- game input -->
<div class="game-input">
<input type="number" id="user-input">
<button type="button" id="guess-button">Guess!</button>
</div>
<!-- end game input -->var resultNode = document.getElementById("result");
var userInputNode = document.getElementById("user-input");
var guessButtonNode = document.getElementById("guess-button");
var getRandomInt = function(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
var randomNumber = getRandomNumber(1, 100);
console.log("Secret random number for debugging purposes: ", randomNumber);
guessButtonNode.onclick = function() {
var userInputValue = userInputNode.value;
if (randomNumber === parseInt(userInputValue)) {
resultNode.textContent = "WIN";
} else {
resultNode.textContent = "LOSE";
}
};questions?
Join our QC ACM Slack Channel #web-dev
https://github.com/christiansakai
christianmsakai@gmail.com