diff --git a/README.md b/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/class1.html b/class1.html deleted file mode 100644 index 2414837..0000000 --- a/class1.html +++ /dev/null @@ -1,704 +0,0 @@ - - - - - - - Class 1 ~ Javascript ~ Girl Develop IT - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- -

Beginner Javascript

-

Class 1

-
- - -
-

Welcome!

-
-

While we wait to get started, please ensure you have the following set up:

-
    -
  • A browser up and running (Recommendation: Chrome)
  • -
  • A text editor installed and running (Recommendation: Sublime Text 2)
  • -
-
-
- -
-

Welcome!

-
-

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.

-

Some "rules"

-
    -
  • We are here for you!
  • -
  • Every question is important
  • -
  • Help each other
  • -
  • Have fun
  • -
-
-
- -
-

Welcome!

-
-

Let's get to know eachother

-
    -
  • Who are you?
  • -
  • Why do you want to learn JavaScript?
  • -
  • Fun fact about you
  • -
-
-
- - - - -
-

Course Agenda

-
    -
  • Class 1: Introduction to JavaScript
  • -
  • Class 2: Deeper dive into JavaScript
  • -
  • Class 3: Introduction to jQuery
  • -
  • Class 4: Introduction to APIs, REST and AJAX (We will work with the Meetup.com API)
  • -
-
- -
-

Course Flow

-
    -
  • Each class will include 3 exercises
  • -
  • We will go through a group of slides that explain new concepts, then test our learnings in an exercise together.
  • -
  • In the first couple classes I will walk you through the exercises but as we get the hang of things, I will encourage you to work in partners.
  • -
  • At the end of each week, all code will be shared with you. It's more important to understand then to rush through copying.
  • -
-
- - -
-

Clients and servers

-

How your computer accesses websites

- -

JavaScript is "client side"

-

Your browser understands it!

-
- - - - - -
-

JavaScript Introduction

-
    -
  • JavaScript is a Scripting Language (a lightweight programming language)
  • -
  • JavaScript is programming code that can be inserted into HTML pages.
  • -
  • JavaScript code can be executed by all modern web browsers.
  • -
  • JavaScript is the world's most popular programming language.
  • -
-
- -
-

History of JavaScript

-
    -
  • Developed by Brendan Eich of Netscape in 1995 (in 10 days!)
  • -
  • Originally called Mocha and then LiveScript
  • -
  • Java -- Actually JavaScript has nothing to do with the language Java. Java was just the cool kid in town at the time.
  • -
  • The next version of JavaScript "ECMAScript 6" or "ES6" is in the process of being finalized and should be rolled out soon!
  • -
-
- - - - -
-

What JavaScript Is and Isn’t

-
    -
  • The primary purpose of JavaScript is to add interactivity to the page.
  • -
  • JavaScript does not replace your HTML and CSS, it adds to it.
  • -
  • You may have heard of jQuery or played with it a little bit. This is a JavaScript library.
  • -
  • JavaScript libraries like jQuery, Mootools, Dojo, are collections of JavaScript code that handle the major of the heavy lifting for you (i.e. think "homepage sliders")
  • -
-
- - -
-

What does JavaScript do?

- -
- - -
-

Best way to learn JavaScript...

-
    -
  • DON'T BE SCARED!
  • -
  • Try things out without worrying about breaking the code. This is how you learn.
  • -
  • Practice! This course will not teach you everything about JavaScript, continue to practice on sites like CodeAcademy or Code School (or many others!)
  • -
-
- - -
-

Statements/Script

-
Each line in JavaScript is an instruction or a script
-
When the browser reads it, it "executes the script"
-

-            alert('Hello');
-          
-
- - -
-

Variables

-
-

Variables hold content

-

Words, numbers, true/false, basically any kind of content

-
-
-

Declare a variable (Give it a name)

-

-              var bananas;
-            
-
-
-

Initialize variable (Give it a value)

-

-              bananas = 5;
-            
-
-
- -
-

Variables

-
-

Declare and initialize at the same time!

-

-              var bananas = 5;
-            
-
-
-

Change value of variable

-

-              bananas = 4;
-            
-

(I ate a banana)

-
-
- - -
-

Data types

-
-

string -- a group of characters in quotes

-

-              var fruit = "banana";
-            
-
-
-

number -- (well, a number)

-

-              var pi = 3.14;
-              var year = 2013;
-              var bananaTally = 200;
-            
-
-
-

boolean -- yes or no

-

-              var skyIsBlue = true;
-              var grassIsPink = false;
-            
-
-
- - -
-

Data types

-
-

undefined -- no value yet

-

-              var favoriteDinosaur;
-            
-
-
-

null -- a purposely empty value (not the same as 0)

-

-              var myTigersName = null;
-            
-
-
- In nerd speak, JavaScript variables are "loosely typed". You don't know the kind of value a variable will have until you assign it. -
-
- - -
-

Naming rules

-
-

Begin with a letter, _, or $

-

Contain letters, numbers, _ and $

-

-              var hello;
-              var _hello;
-              var $hello;
-              var hello2;
-            
-
-
-

Names are case sensitive

-

-              var hello;
-              var Hello;
-              var heLLO;
-            
-
-
- - -
-

Expressions

-
-

Math-y expressions!

-

-          var bananas = 5;
-          var oranges = 2;
-          var fruit = bananas + oranges;
-            
-
-
- - - - - - - - - -
SymbolMeaning
+Addition
-Subtraction
*Multiplication
/Division
%Modulus
++Increment
--Decrement
-
-
- - -
-

Expressions

-
-

Word-y expressions!

-

-var name = "Mitch";
-var dinosaur = "Stegosaurus";
-var sentence = "My dinosaur is a " + dinosaur + ". It's name is " + name + ".";
-            
-
-
- - -
-

Let's Develop It

-

Create a new html file

-

-<html>
-  <head>
-    <title>My Site!</title>
-  </head>
-  <body>
-    My site!
-  </body>
-</html>
-
-
- -
-

Let's Develop It

-

Create a new javascript file (a file that ends in .js)

-

Link it to your html file

-

-<html>
-  <head>
-    <title>My Site!</title>
-    <script src="javascript.js"></script>
-  </head>
-  <body>
-    My site!
-  </body>
-</html>
-
-
- -
-

Let's Develop It

-

Life time supply calculator

-

Ever wonder how much a lifetime supply of your favorite snack or drink is?

-
    -
  • Store your age in a variable
  • -
  • Store your maximum age in a variable
  • -
  • Store an estimated amount per day in a variable
  • -
  • Calculate how many you would eat/drink for the rest of your life.
  • -
  • Output the result in an alert(see below) like so: "You will need NN to last you until your old age of NN"
  • -
- -

-  alert(answer);
-
-
- -
- - -
-

The if statement

-

Javascript can run through code based on conditions

-
-

-          if (condition here){
-            // statement to execute
-          }
-
-
-
-

-          var bananas = 1;
-          if (bananas < 2){
-            console.log("You should buy more bananas!")
-          }
-
-
-
- Note: you can write comments that only you, not the browser reads -

-            // comment on one line
-            /* comment on 
-              multiple lines
-              */
-        
-
-
- - -
-

Comparisons

- - - - - - - -
=== Equality
!== Inequality
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
-

Don't confuse = (assign a value)
with === (compare a value)

-
- - -
-

Logic

- - - - -
&& AND
|| OR
! NOT
-
-

-        var bananas = 5;
-        var oranges = 2;
-        if (bananas > 3 && oranges > 3){
-          console.log('Eat fruit!');
-        }
-        if (bananas < 2 || oranges < 2){
-          console.log('Buy fruit!');
-        }
-        if (!(bananas >= 0)){
-          console.log('How do you have negative bananas?');
-        }
-            
-
-
- - -
-

If/Else Statement

-

You can use else to perform an alternative action if the "if" fails

-

-          var bananas = 5;
-          if (bananas > 3){
-            console.log('Eat a banana!');
-          } else {
-            console.log('Buy a banana!');
-          }
-          
-
- -
-

If/Else Statement

-

You can use else if to have multiple choices

-

-var age = 20;
-if (age >= 35) {
-  console.log('You can vote AND hold any place in government!');
-} else if (age >= 25) {
-  console.log('You can vote AND run for the Senate!');
-} else if (age >= 18) {
-  console.log('You can vote!');
-} else {
-  console.log('You have no voice in government (yet)!');
-}
-          
-
- - -
-

Let's Develop It!

-

Add an if/else statement to our lifetime supply calculator so that if the lifetime supply is greater than 40,000, you say "Wow! That's a lot!" otherwise, say "You seem pretty reasonable!"

-
- - -
-

Functions

-

Functions are re-usable collections of statements

-
- Declare a function -

-            function sayHi(){
-              console.log('Hi!');
-            }
-          
-
-
- Call the function -

-            sayHi();
-          
-
-
- - -
-

Arguments

-

Functions can take named arguments

-
-

-            function sayHi(name){
-              console.log('Hi' + name + '!');
-            }
-            sayHi('Mitch, the dinosaur');
-            sayHi('Harold, the hippo');
-            
-            var name = 'Pip, the mouse';
-            sayHi(name);
-          
-
-
- - -
-

Arguments

-

Functions can take MULTIPLE named arguments

-
-

-            function addNumbers(num1, num2){
-              var result = num1 + num2;
-              console.log(result);
-            }
-          
-            addNumbers(5, 6);
-            
-            var number1 = 12;
-            var number2 = 15;
-            addNumbers(number1, number2);
-          
-
-
- - -
-

Return values

-

Functions can return a value

-
-

-    function addNumbers(num1, num2){
-      var result = num1 + num2;
-      return result; //Anything after this line won't be read
-    }
-    var sum  = addNumbers(5, 6);
-          
-
-
- - -
-

Variable Scope

-

JavaScript have "function scope". They are visible in the function where they are defined

-
- A variable with "local" scope: -

-  function addNumbers(num1, num2){
-    var result = num1 + num2;
-    return result; //Anything after this line won't be read
-  }
-  var sum  = addNumbers(5, 6);
-  console.log(result); //will return undefined because result only exists inside the addNumbers function
-          
-
-
- - -
-

Variable Scope

-

JavaScript have "function scope". They are visible in the function where they are defined

-
- A variable with "global" scope: -

-   var result;
-    function addNumbers(num1, num2){
-      result = num1 + num2;
-      return result; //Anything after this line won't be read
-    }
-    var sum  = addNumbers(5, 6);
-    console.log(result); //will return 11 because the variable was defined outside the function
-          
-
-
- - -
-

Let's Develop It

-
-

Wrap the lifetime supply calculator in a function called calculate()

-

Add a link to the html that calls the function when it is clicked

-

- <a href = "#" onclick="calculate()">
- Calculate life time supply
- </a>
-         
-
-
- - -
-

Questions?

-
? -
-
-
- -
- - - - - - - - - diff --git a/class1/exercise1/index.html b/class1/exercise1/index.html deleted file mode 100755 index aec0ed2..0000000 --- a/class1/exercise1/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - My Site! - - - - My Site! - - \ No newline at end of file diff --git a/class1/exercise1/javascript.js b/class1/exercise1/javascript.js deleted file mode 100755 index b8bfb45..0000000 --- a/class1/exercise1/javascript.js +++ /dev/null @@ -1,7 +0,0 @@ -var age = 26; -var oldAge = 96; -var perDay = 2; - -var days = (oldAge - age) * 365; -var total = perDay * days; -alert("You will need " + total + " to last you until the ripe old age of " + oldAge); diff --git a/class1/exercise2/index.html b/class1/exercise2/index.html deleted file mode 100755 index aec0ed2..0000000 --- a/class1/exercise2/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - My Site! - - - - My Site! - - \ No newline at end of file diff --git a/class1/exercise2/javascript.js b/class1/exercise2/javascript.js deleted file mode 100755 index 2acd931..0000000 --- a/class1/exercise2/javascript.js +++ /dev/null @@ -1,11 +0,0 @@ -var age = 26; -var oldAge = 96; -var perDay = 2; - -var days = (oldAge - age) * 356; -var total = perDay * days; -if(total > 40000){ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); -}else{ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"); -} \ No newline at end of file diff --git a/class1/exercise3/index.html b/class1/exercise3/index.html deleted file mode 100755 index 398209e..0000000 --- a/class1/exercise3/index.html +++ /dev/null @@ -1,10 +0,0 @@ - - - My Site! - - - - My Site! - Calculate life time supply - - \ No newline at end of file diff --git a/class1/exercise3/javascript.js b/class1/exercise3/javascript.js deleted file mode 100755 index 7fc40c2..0000000 --- a/class1/exercise3/javascript.js +++ /dev/null @@ -1,13 +0,0 @@ -function calculate(){ - var age = 26; - var oldAge = 96; - var perDay = 2; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); - }else{ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"); - } -} diff --git a/class2.html b/class2.html deleted file mode 100644 index 23a0525..0000000 --- a/class2.html +++ /dev/null @@ -1,553 +0,0 @@ - - - - - - - Class 2 ~ Javascript ~ Girl Develop IT - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- -

Beginning Javascript

-

Class 2

-
- - -
-

Welcome!

-
-

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.

-

Some "rules"

-
    -
  • We are here for you!
  • -
  • Every question is important
  • -
  • Help each other
  • -
  • Have fun
  • -
-
-
- - -
-

Loops

-

Sometimes you want to go through a piece of code multiple times

-

Why?

-
    -
  • Showing a timer count down
  • -
  • Displaying the results of a search
  • -
  • Adding images to a slideshow
  • -
-
- -
-

The while loop

-

The while loop tells JS to repeat statements while a condition is true:

-

-      while (expression) {
-        // statements to repeat
-      }
-          
-

-      var x = 0;
-      while (x < 5) {
-        console.log(x);
-        x++;
-      }
-          
-
- Review: '++' means increment by 1! -
-
-
Danger!!
-

What happens if we forget x++;?

-

The loop will never end!!

-
-
- -
-

The for loop

-

The for loop is a safer way of looping

-

-          for (initialize; condition; update) {
-            // statements to repeat
-          }
-          
-

-          for (var i = 0; i < 5; i++) {
-            console.log(i);
-          }
-          
-
- Less danger of an infinite loop. All conditions are at the top! -
-
- - -
-

Array

-

An array is a data-type that holds an ordered list of values, of any type:

-
-

-          var arrayName = [element0, element1, ...];
-            
-
-
-

-var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
-var favoriteNumbers = [16, 27, 88];
-var luckyThings = ['Rainbows', 7, 'Horseshoes'];
-            
-
-
- The length property reports the size of the array: -

-          console.log(rainbowColors.length);
-            
-
-
- -
-

Arrays -- returning values

-

You can access items with "bracket notation".

-
- The number inside the brackets is called an "index" -

-          var arrayItem = arrayName[indexNum];
-            
-
-
- Arrays in JavaScript are "zero-indexed", which means we start counting from zero. -

-      var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
-      var firstColor = rainbowColors[0];
-      var lastColor = rainbowColors[6];
-            
-
-
- -
-

Arrays -- updating values

-
- You can also use bracket notation to change the item in an array: -

-        var awesomeAnimals = ['Corgis', 'Otters', 'Octopi'];
-        awesomeAnimals[0] = 'Bunnies';
-            
-
-
- Or to add to an array: -

-          awesomeAnimals[4] = 'Corgis';
-            
-
- -
- You can also use the push method: -

-          awesomeAnimals.push('Ocelots');
-            
-
-
- -
-

Loops and Arrays

- Use a for loop to easily look at each item in an array: -

-var rainbowColors = ['Red', 'Orange', 'Yellow', 'Green', 'Blue', 'Indigo', 'Violet'];
-for (var i = 0; i < rainbowColors.length; i++) {
-  console.log(rainbowColors[i]);
-}
-          
-
- - -
-

Let's Develop It

-
    -
  • Add a new link to the exercise from last week
  • -
  • Add an onclick to the link for a function called favoriteThings()
  • -
  • Create a new function called favoriteThings() in the javascript file
  • -
  • In the function, create an array and loop through the results
  • -
  • Post the results in an alert "My favorite things are XX, YY, ZZ'
  • -
  • Bonus -- add an 'and' in the sentence before the last item
  • -
-
- - -
-

Objects

-

Objects are a data type that let us store a collection of properties and methods.

-

-          var objectName = { 
-            propertyName: propertyValue,
-            propertyName: propertyValue,
-            ...
-          };
-          
-
-

-      var charlie = {
-        age: 8,
-        name: "Charlie Brown",
-        likes: ["baseball", "The little red-haired girl"],
-        pet: "Snoopy"
-      };
-          
-
-
- -
-

Objects -- returning values

-

Access values of "properties" using "dot notation":

-
-

-      var charlie = {
-        age: 8,
-        name: "Charlie Brown",
-        likes: ["baseball", "The little red-haired girl"],
-        pet: "Snoopy"
-      };
-      
-
-
-

-          var pet = charlie.pet;
-            
-
-
- -
-

Objects -- returning values

-
- Or using "bracket notation" (like arrays): -

-          var name = charlie['name'];
-            
-
-
- Non-existent properties will return undefined: -

-          var gender = charlie.gender
-            
-
-
- -
-

Objects -- changing values

-

Use dot or bracket notation with the assignment operator to change objects.

-
- Change existing properties: -

-          charlie.name = "Chuck";
-          
-
-
- Or add new properties: -

-          charlie.gender = "male";
-            
-
-
- You can also delete properties: -

-          delete charlie.gender;
-          
-
-
- -
-

Arrays of Objects

-

Arrays can hold objects too!

-
-

-          var peanuts = [
-            {name: "Charlie Brown", 
-             pet: "Snoopy"},
-            {name: "Linus van Pelt",
-             pet: "Blue Blanket"}
-          ];
-            
-
-
- That means we can use a for loop! -

-  for (var i = 0; i < peanuts.length; i++) {
-    var peanut = peanuts[i];
-    console.log(peanut.name + ' has a pet named ' + peanut.pet + '.');
-  }
-          
-
-
- -
-

Objects in functions

-

You can pass an object into a function as a parameter

-

-        var peanut ={
-          name: "Charlie Brown", 
-          pet: "Snoopy"
-          };
-          
-
-

-  function describeCharacter(character){
-    console.log(character.name + ' has a pet named ' + character.pet + '.');
-  }
-            
-
-
-

-              describeCharacter(peanut);
-            
-
-
- - -
-

Let's Develop It

-
    -
  • Add another link that calls the function myFriends() onclick
  • -
  • Add a new function to the javascript myFriends
  • -
  • In the function, create an array of friends objects, with their names and hair colors
  • -
  • Use a for loop to go through each friend and describe them
  • -
  • Alert the results
  • -
  • Bonus -- make a separate functions that describe the friends
  • -
-
- - -
-

DOM

-
    -
  • "Document Object Model"
  • -
  • A way to interact with the HTML elements on a webpage
  • -
  • Chrome and Firefox -- Right click --> Inspect Element
  • -
- -
- -
-

DOM Interaction

-

On every webpage, the document object gives us ways of accessing and changing the DOM.

-

Every DOM "node" has properties. They are connected like a family tree.

-

Parent (parentNode), children (childNodes, firstChild), siblings (prevSibling, nextSibling)

-
-

-  var bodyNode = document.body; // <body>
-  var htmlNode = document.body.parentNode; // <html>
-  for (var i = 0; i < document.body.childNodes.length; i++) {
-    var childNode = document.body.childNodes[i];
-    //could be <p>, <h1>, etc.
-    //any html element
-  }
-          
-
-
- -
-

DOM Interaction: Easier

-

Finding every element on the page by siblings and children is time consuming!

-

The document object also provides methods for finding DOM nodes without going one by one

-
- Find element by id -

-<img id="mainpicture" src="http://girldevelopit.com/assets/pink-logo.png">
-            
-

-var img = document.getElementById('mainpicture');            
-            
-
-
- -
-

DOM Interaction: Easier

-
- Find element by tag name (p, li, div, etc.) -

-          <li class="peanut">Charlie Brown</li>
-          <li class="peanut">Linus van Pelt</li>
-            
-

-      var listItems = document.getElementsByTagName('li');
-      for (var i =0; i < listItems.length; i++) {
-        var listItem = listItems[i];
-      }
-          
-
-
- - -
-

Methods

-
    -
  • Methods are functions that are associated with an object
  • -
  • The affect or return a value for a specific object
  • -
  • Used with dot notation
  • -
-
- Previously seen example: -

-            var img = document.getElementById('mainpicture');
-            
-
-
- - -
-

DOM Nodes -- Attributes

-

We can use node methods to set and retrieve attributes

-
- getAttribute/setAttribute -

- var img = document.getElementById('mainpicture');
- img.getAttribute('src');
- img.setAttribute('src', 'http://girldevelopit.com/assets/pink-logo.png');
-            
- -

- var img = document.getElementById('mainpicture');
- img.getAttribute('class');
- img.setAttribute('class', 'picture-class');
-            
-
-
- - -
-

DOM innerHTML

-

Each DOM node has an innerHTML property:

-
-

-        document.body.innerHTML;
-          
-
-
- You can set innerHTML yourself to change the contents of the node: -

-document.body.innerHTML = '<p>I changed the whole page!</p>';
-          
-
-
- You can also just add to the innerHTML instead of replace everything: -

-document.body.innerHTML += "...just adding this bit at the end of the page.";
-          
-
-
- - -
-

DOM Modifying

-

The document object can create new nodes:

-
-

-              document.createElement(tagName);
-              document.createTextNode(text);
-              document.appendChild();
-            
-
-
-

-var newImg = document.createElement('img');
-newImg.src = 'http://girldevelopit.com/assets/pink-logo.png';
-document.body.appendChild(newImg);
-            
-
-
-

-var newParagraph = document.createElement('p');
-var paragraphText = document.createTextNode('New Paragraph!');
-newParagraph.appendChild(paragraphText);
-document.body.appendChild(newParagraph);
-      
-
- -
- - -
-

Let's Develop It

-
    -
  • Put it all together
  • -
  • Modify your existing three functions to add new elements to the screen instead of fire an alert
  • -
  • Keep in mind how to find an element, how to append an element, and how to change the inner html of an element
  • -
  • There are lots of possible solutions! Be creative!
  • -
-
- -
-

Questions?

-
? -
-
-
- -
- - - - - - - - - diff --git a/class2/exercise1/index.html b/class2/exercise1/index.html deleted file mode 100755 index c3cc935..0000000 --- a/class2/exercise1/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - My Site! - - - - My Site!
- Calculate life time supply
- See my favorite things - - \ No newline at end of file diff --git a/class2/exercise1/javascript.js b/class2/exercise1/javascript.js deleted file mode 100755 index c41d3a5..0000000 --- a/class2/exercise1/javascript.js +++ /dev/null @@ -1,26 +0,0 @@ -function calculate(){ - var age = 26; - var oldAge = 96; - var perDay = 2; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); - }else{ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"); - } -} - -function favoriteThings(){ - var favoriteThings = ['Rabbits', 'Orange', 'Yogurt', 'Brussel Sprouts', 'Otters']; - var result = 'My favorite things are: '; - for (var i = 0; i - - My Site! - - - - My Site!
- Calculate life time supply
- See my favorite things
- My friends - - \ No newline at end of file diff --git a/class2/exercise2/javascript.js b/class2/exercise2/javascript.js deleted file mode 100755 index 4bd3c07..0000000 --- a/class2/exercise2/javascript.js +++ /dev/null @@ -1,44 +0,0 @@ -function calculate(){ - var age = 26; - var oldAge = 96; - var perDay = 2; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); - }else{ - alert("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"); - } -} - -function favoriteThings(){ - var favoriteThings = ['Rabbits', 'Orange', 'Yogurt', 'Brussel Sprouts', 'Otters']; - var result = 'My favorite things are: '; - for (var i = 0; i - - My Site! - - - - My Site!
- Calculate life time supply
-
- -
- See my favorite things -
- -
- My friends - - \ No newline at end of file diff --git a/class2/exercise3/javascript.js b/class2/exercise3/javascript.js deleted file mode 100755 index 2cc0d79..0000000 --- a/class2/exercise3/javascript.js +++ /dev/null @@ -1,60 +0,0 @@ -function calculate(){ - var age = 26; - var oldAge = 96; - var perDay = 2; - - var days = (oldAge - age) * 356; - var total = perDay * days; - var resultDiv = document.getElementById('lifetime-supply') - if(total > 40000){ - resultDiv.innerHTML = "You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"; - }else{ - resultDiv.innerHTML = "You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"; - } -} - -function favoriteThings(){ - var favoriteThings = ['Rabbits', 'Orange', 'Yogurt', 'Brussel Sprouts', 'Otters']; - var resultDiv = document.getElementById('favorite-things'); - - var resultParagraph = document.createElement('p'); - var result = 'My favorite things are: '; - - for (var i = 0; i - - - - - - Class 3 ~ Javascript ~ Girl Develop IT - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- -

Beginning Javascript

-

Class 3

-
- - -
-

Welcome!

-
-

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.

-

Some "rules"

-
    -
  • We are here for you!
  • -
  • Every question is important
  • -
  • Help each other
  • -
  • Have fun
  • -
-
-
- - -
-

What is a library?

-
    -
  • Software libraries hold functions (not books!)
  • -
  • When you include a library, you can use all the functions in that library
  • -
  • That means: you get to take advantage of other people's experience!
  • -
  • And... Save time!
  • -
-
- - -
-

What is jQuery?

-

jQuery is a library of JavaScript functions.

-

It contains many functions to help simplify your programming, including:

-
    -
  • HTML element selection & manipulation
  • -
  • CSS manipulation
  • -
  • HTML events
  • -
  • JavaScript effects and animations
  • -
-
- -
-

Why use jQuery?

-
    -
  • The most popular JavaScript library
  • -
  • jQuery empowers you to "write less, do more."
  • -
  • Great documentation and tutorials
  • -
  • Used by nearly 20 million(!) websites
  • -
-
- -
-

jQuery: A Brief History

-
    -
  • jQuery was created by John Resig, a JavaScript tool developer at Mozilla.
  • -
  • January 2006: John announced jQuery at BarCampNYC: BarCampNYC Wrap-up
  • -
  • September 2007: A new user interface library is added to jQuery: jQuery UI: Interactions and Widgets
  • -
  • September 2008: Microsoft and Nokia announce their support for jQuery
  • -
  • December 2009: jQuery wins .Net Magazine's Award for Best Open Source Application
  • -
-
- - -
-

Including jQuery

- Two ways to include jQuery on your page: -
- Download the library, store it locally: -

-  <head>
-    <script type="text/javascript" src="jquery.js"></script>
-  </head>
-          
-
-
- Include the the live library: -

-  <head>
-    <script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js">
-    </script>
-  </head>
-          
-
-
- Note: live code can change! It's always best to download -
-
- - -
-

jQuery Selectors

-

Remember document.getElementById() and documet.getElementsByTagName()?

-

jQuery selectors let you get elements by:

-
    -
  • Element name (div, p) -
    
    -      var divs = $("div"); // All divs on page
    -            
    -
  • -
  • ID name (#mainpicture, #results) -
    
    -var img = $("#mainpicture"); //img with id mainpicture
    -            
    -
  • -
  • Class name (.result, .picture) -
    
    -var images = $(".picture"); //All images with class picture 
    -            
    -
  • -
-
- - - -
-

jQuery Actions

-
-

jQuery has hundreds of actions that can be performed on any element

-

All the actions are methods

-

As methods they are called with dot notation

-
-
- Action format -

-        $(selector).action();     
-            
-
-
- - -
-

Updating attributes and css

-
-

-  <img id="mainpicture" src="http://girldevelopit.com/assets/pink-logo.png">         
-            
-
-
- Attribute get and set -

-  var img = $('#mainpicture');
-  img.attr('src');
-  img.attr('src', 'http://girldevelopit.com/assets/pink-logo.png');
-            
-
-
- CSS property get and set -

-  var img = $('#mainpicture');
-  img.css('width');
-  img.css('width', '200px');
-            
-
-
- - -
-

Updating values and html

-
-

-  <div id = "results">Boo!</div>         
-            
-
-
- Get and set html value -

-  var div = $('#results');
-  div.html();
-  div.html('New html!');
-            
-
-
- - -
-

Append and Prepend

-
-

-  <div id = "results">Boo!</div>         
-            
-
-
- Append html -

-    var div = $('#results');
-    div.append('Additional html');
-            
-
-
- Prepend html -

-    var div = $('#results');
-    div.prepend('Additional html (on top)');
-            
-
-
- -
-

Creating new element

-
-

-    var newDiv = $('<div></div>');
-            
-
-
- Seriously. That's it! -
-
- - -
-

Let's Develop It!

-

Try to convert last week's DOM interaction into jQuery.

-

Don't forget to include jQuery in your html head!

-
- - -
-

Document Ready

-
-

Webpages take time to load

-

Almost always, you don't want the JavaScript to be called until the page is loaded

-
-
- Document ready is a method called when the page is loaded -

-        $(document).ready(function(){
-          
-        });
-            
-
-
- Note: The function() inside is an "anonymous function". It has no name, but still performs like a function. -
-
- - -
-

HTML events

-

Events occur on a webpage via user interaction

-

Common Events:

-
    -
  • mouseenter -- mouse goes inside an element
  • -
  • mouseleave -- mouse leaves an element
  • -
  • click -- mouse clicks an element
  • -
  • Other events
  • -
-
- -
-

Handling events

-

-  $(selector).mouseenter(function(){
-    //code when the mouse enters
-  })
-      
-
-

-  $('.box').mouseenter(function(){
-    $(this).css('background-color', 'purple')
-  })
-      
-
-
-
The $(this) selector in jQuery refers to the element on whom the action was called.
-
Here $(this) is the $('.box') that the mouse entered. -
-
- -
-

Handling event examples

-
-

-      $('.box').mouseenter(function(){
-        $(this).css('background-color', 'purple')
-      })
-            
-
-
-

-      $('.box').mouseleave(function(){
-        $(this).css('background-color', 'orange')
-      })
-          
-
-
-

-      $('.box').click(function(){
-        $(this).css('background-color', 'green')
-      })
-          
-
-
- -
-

Combining events

-

If you want multiple events to happen on the same element, you should use the bind method

-
-

-      $('.box').bind({
-        click: function() {
-          $(this).css('background-color', 'green')
-        },
-        mouseenter: function() {
-          $(this).css('background-color', 'purple')
-        },
-        mouseleave: function(){
-          $(this).css('background-color', 'orange')
-        }
-      });
-          
-
-
- - -
-

Let's Develop It

-
    -
  • Add a div to your html that is 100px by 200px
  • -
  • Bind events to the div in your javascript file
  • -
  • Don't forget to surround your events with document ready
  • -
  • Try to change size, color, or event the html inside the div
  • -
  • Bonus: change all the onclick events to jQuery click events
  • -
-
- - -
-

HTML forms

-

HTML Forms allow users to enter information

-
-

-<form id ="about-me">
-  <input type = "text" id = "name" placeholder = "Enter a name"/>
-  <label>Do you like popcorn</label>
-  Yes <input type = "radio" name = "popcorn" val = "yes"/>
-  No <input type = "radio" name = "popcorn" val = "no"/>
-  <label>Favorite Dinosaur</label>
-  <select id = "dinosaur">
-    <option value = "t-rex">Tyrannosaurus Rex</option>
-    <option value = "tri">Triceratops</option>
-    <option value = "stego">Stegosaurus</option>
-    <option value = "other">Other</option>
-  </select>
-  <input type = "submit" value = "Go!" style = "padding: 7px; font-size:1em"/>
-</form>
-            
-
-
- -
-

HTML forms

-

HTML Forms allow users to enter information

-
-
-
-
- Yes - No
-
-
- -
-
-
- - -
-

Values from Forms

-

You can use JavaScript to get values from a form

-
-

-    $('#name').val();
-    $('select#dinosaur').val();
-    $('input:radio[name=popcorn]:checked').val();
-            
-
-
- Or set values of a form -

-    $('#name').val('Mitch');
-    $('select#dinosaur').val('stego');
-    $('input:radio[name=popcorn]:checked').val('no');
-            
-
-
- -
-

Values from Forms

-

jQuery has an event for form submission

-
-

-      $('#about-me').submit(function(event){
-            //code to execute after submission
-            return false;
-        });
-            
- "return false" to prevent the form trying to submit to a server. -
-
- - -
-

Let's Develop It

-
    -
  • Choose one (or all!) of your functions made so far
  • -
  • i.e. lifetime supply, favorite things, or my friends
  • -
  • Create a form to send dynamic data to the function when you click the button
  • -
  • Don't forget to add parameters to your existing functions!

    -
  • This is a little harder than all the other exercises.
  • -
  • Be creative!
  • -
-
- -
-

Questions?

-
? -
-
-
-
- -
-
- - - - - - - - - diff --git a/class3/exercise1/index.html b/class3/exercise1/index.html deleted file mode 100755 index dc6017f..0000000 --- a/class3/exercise1/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - My Site! - - - - - My Site!
- Calculate life time supply
-
- -
- See my favorite things -
- -
- My friends - - \ No newline at end of file diff --git a/class3/exercise1/javascript.js b/class3/exercise1/javascript.js deleted file mode 100755 index 5f5cd31..0000000 --- a/class3/exercise1/javascript.js +++ /dev/null @@ -1,55 +0,0 @@ -function calculate(){ - var age = 26; - var oldAge = 96; - var perDay = 2; - - var days = (oldAge - age) * 356; - var total = perDay * days; - var resultDiv = $('#lifetime-supply') - if(total > 40000){ - resultDiv.html("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); - }else{ - resultDiv.html("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"); - } -} - -function favoriteThings(){ - var favoriteThings = ['Rabbits', 'Orange', 'Yogurt', 'Brussel Sprouts', 'Otters']; - var resultDiv = $('#favorite-things'); - - var resultParagraph = $('

'); - var result = 'My favorite things are: '; - - for (var i = 0; i') - - var introParagraph = $('

My friends are:

'); - resultDiv.append(introParagraph) - - for(var i = 0; i < friends.length; i++){ - var resultParagraph = $('

' + describeFriend(friends[i]) + '

'); - resultDiv.append(resultParagraph); - } - $('body').append(resultDiv); -} -function describeFriend(friend){ - return "My friend " + friend.name + " has " + friend.hair + " hair. "; -} \ No newline at end of file diff --git a/class3/exercise2/index.html b/class3/exercise2/index.html deleted file mode 100755 index 7434619..0000000 --- a/class3/exercise2/index.html +++ /dev/null @@ -1,25 +0,0 @@ - - - My Site! - - - - - - My Site!
-
-
-
-
- Calculate life time supply
-
- -
- See my favorite things -
- -
- My friends - - - \ No newline at end of file diff --git a/class3/exercise2/javascript.js b/class3/exercise2/javascript.js deleted file mode 100755 index 23a2fe4..0000000 --- a/class3/exercise2/javascript.js +++ /dev/null @@ -1,75 +0,0 @@ -$(document).ready(function(){ - $('.box').bind({ - click: function() { - $(this).css('background-color', 'green') - $(this).html('Clicked!') - }, - mouseenter: function() { - $(this).css('background-color', 'purple') - $(this).html('Hi!') - }, - mouseleave: function(){ - $(this).css('background-color', 'orange') - $(this).html('Bye!') - } - }); - $('#calculate').click(calculate); - $('#favorites').click(favoriteThings); - $('#friends').click(myFriends); -}) - -function calculate(){ - var age = 26; - var oldAge = 96; - var perDay = 2; - - var days = (oldAge - age) * 356; - var total = perDay * days; - var resultDiv = $('#lifetime-supply') - if(total > 40000){ - resultDiv.html("You will need " + total + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"); - }else{ - resultDiv.html("You will need " + total + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"); - } -} - -function favoriteThings(){ - var favoriteThings = ['Rabbits', 'Orange', 'Yogurt', 'Brussel Sprouts', 'Otters']; - var resultDiv = $('#favorite-things'); - - var resultParagraph = $('

'); - var result = 'My favorite things are: '; - - for (var i = 0; i') - - var introParagraph = $('

My friends are:

'); - resultDiv.append(introParagraph) - - for(var i = 0; i < friends.length; i++){ - var resultParagraph = $('

' + describeFriend(friends[i]) + '

'); - resultDiv.append(resultParagraph); - } - $('body').append(resultDiv); -} -function describeFriend(friend){ - return "My friend " + friend.name + " has " + friend.hair + " hair. "; -} \ No newline at end of file diff --git a/class3/exercise2/style.css b/class3/exercise2/style.css deleted file mode 100755 index 8d6c2eb..0000000 --- a/class3/exercise2/style.css +++ /dev/null @@ -1,5 +0,0 @@ -.box{ - width: 200px; - height: 100px; - border: 1px solid #ccc; -} \ No newline at end of file diff --git a/class3/exercise3/index.html b/class3/exercise3/index.html deleted file mode 100755 index 76441ea..0000000 --- a/class3/exercise3/index.html +++ /dev/null @@ -1,37 +0,0 @@ - - - My Site! - - - - - - My Site!
-
-
-
-
-
-
-
-
- -
-
- -
-
-

My favorite things:

-
-
-
- -
- -
-
-
- -
- - \ No newline at end of file diff --git a/class3/exercise3/javascript.js b/class3/exercise3/javascript.js deleted file mode 100755 index f371c3e..0000000 --- a/class3/exercise3/javascript.js +++ /dev/null @@ -1,60 +0,0 @@ -$(document).ready(function(){ - $('.box').bind({ - click: function() { - $(this).css('background-color', 'green') - $(this).html('Clicked!') - }, - mouseenter: function() { - $(this).css('background-color', 'purple') - $(this).html('Hi!') - }, - mouseleave: function(){ - $(this).css('background-color', 'orange') - $(this).html('Bye!') - } - }); - $('#calculate').submit(function(event){ - var givenAge = $('#age').val(); - var givenSnack = $('#snack').val(); - var givenPerDay = $('#times-per-day').val(); - $('#lifetime-supply').html(calculate(givenAge, givenSnack, givenPerDay)); - return false; - }); - $('#favorites').submit(function(event){ - var givenThing = $('#thing').val(); - favoriteThings(givenThing); - return false - }); - $('#friends').submit(function(event){ - var name = $('#friend-name').val(); - var hair = $('#friend-hair').val() - var friend = {name: name, hair:hair}; - myFriends(friend); - return false; - }); -}) - -function calculate(age, snack, perDay){ - var oldAge = 96; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - return "You will need " + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"; - }else{ - return "You will need " + + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"; - } -} - -function favoriteThings(thing){ - $('#favorite-things').append('

'+ thing +'

'); -} -function myFriends(friend){ - var resultDiv = $('
') - var resultParagraph = $('

' + describeFriend(friend) + '

'); - resultDiv.append(resultParagraph); - $('body').append(resultDiv); -} -function describeFriend(friend){ - return "My friend " + friend.name + " has " + friend.hair + " hair. "; -} \ No newline at end of file diff --git a/class3/exercise3/style.css b/class3/exercise3/style.css deleted file mode 100755 index 67e15aa..0000000 --- a/class3/exercise3/style.css +++ /dev/null @@ -1,11 +0,0 @@ -.box{ - width: 200px; - height: 100px; - border: 1px solid #ccc; -} - -input{ - width: 200px; - padding: 5px; - margin: 5px; -} \ No newline at end of file diff --git a/class4.html b/class4.html deleted file mode 100644 index 1fb7097..0000000 --- a/class4.html +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - - Class 4 ~ Javascript ~ Girl Develop IT - - - - - - - - - - - - - - - - - - - - - - - -
- - -
- -
- -

Beginning Javascript

-

Class 4

-
- - -
-

Welcome!

-
-

Girl Develop It is here to provide affordable and accessible programs to learn software through mentorship and hands-on instruction.

-

Some "rules"

-
    -
  • We are here for you!
  • -
  • Every question is important
  • -
  • Help each other
  • -
  • Have fun
  • -
-
-
- -
-

Warning

-
- The following few slides have lots of acronyms and jargon. -
-
On behalf of developers everywhere, we apologize
-
- -
-

What is an API?

-
    -
  • Application Programming Interface
  • -
  • Data structure and rules for accessing a web-based application
  • -
  • How we can access information from sites that are not our own (Twitter, Meetup, Facebook, Foursquare)
  • -
-
- -
-

What is an API?

-
    -
  • Primary role: a channel for applications to work together -
      -
    • Your website and the Twitter API
    • -
    • Twitter's mobile app and the Twitter API
    • -
    • Hootsuite's mobile app and the Twitter API
    • - -
    -
- - -
-

What is AJAX?

-
    -
  • Asynchronous JavaScript and XML
  • -
  • Method to communicate to a server or API
  • -
  • Asynchronous means: -
      -
    • I ask Twitter for all the tweets ever!
    • -
    • That will take a while
    • -
    • My whole website could be locked up while I wait!
    • -
    • Or, my call can be 'asynchronous' and my website will just listen for Twitter's response with one ear, but go about normal business until the response arrives. -
    -
  • -
  • Requests and results can be in JavaScript or XML
  • -
-
- - -
-

What is REST?

-
    -
  • Representational State Transfer
  • -
  • REST is a way to ask an API for information by using a URL.
  • -
  • REST Urls are created with the following syntax: -
      -
    • http://ApiSite.com/method?parameter=value&parameter=value
    • -
    • Method -- what you want from the API. Defined by API documentations
    • -
    • Parameter -- a type of filter or restraint. Defined by API documentations
    • -
    • Value -- value for parameter. Defined by you!
    • -
    -
  • - -
-
- -
-

Where do I learn about an API?

-

All (good) APIs have documentation

-
- - -
-

What is JSON?

-
    -
  • JavaScript Object Notation
  • -
  • Format for data returned from APIs
  • -
  • You've seen it before!
  • -
  • JavaScript objects
  • -
-
- - -
-

Getting started!

-

Get an API Key

-

A what?

-
    -
  • Api Key or Developer Key is a way for an API to identify you
  • -
  • More secure for an API (Know who is using their API)
  • -
  • More secure for you -- people can't pretend to be your website
  • -
-
- - -
-

Meetup API

-

We will be using the Meetup API

-

Documentation

- -
- -
-

Meetup API

-

We will be finding interesting Meetups near us

-

Open Events

- -
- -
-

Meetup API

-

Try it in the meetup console

-

Open Events Console

- -
- -
-

Meetup API

-

Try it in the meetup console

- -
- - -
-

jQuery Ajax

-

jQuery method to perform an AJAX call

-
-

-    $.ajax({
-  		url: 'http://site.com',
-  		data: {
-  		  parameter: 'value',
-  		  parameter: 'value'
-  		},
-  		crossDomain: true,
-  		dataType: 'jsonp',
-  		type: "GET",
-  		success: function (data) {
-  		    // code with data returned
-  		},
-  		error: function(data) {
-  			 // code with error returned
-  		}				
-  	});
-          	
-
-
- -
-

jQuery Ajax

-
-

-    $.ajax({
-  		url: 'http://site.com',
-  		...			
-  	});
-          	
-
-
    -
  • $.ajax() -- jQuery method for sending AJAX requests
  • -
  • Takes one parameter -- a JavaScript object
  • -
  • Note the {}
  • -
  • url -- first property, the url where you will send the AJAX request
  • -
-
- -
-

jQuery Ajax

-
-

-	...
-	data: {
-	  parameter: 'value',
-	  parameter: 'value'
-	},
-	...	
-          	
-
-
    -
  • data -- a JavaScript object with all the parameters for the AJAX request
  • -
  • Some parameters in the Meetup open events -
      -
    • key (refers to api key)
    • -
    • city
    • -
    • country
    • -
    • topic
    • -
    -
  • -
-
- -
-

jQuery Ajax

-
-

-	...
-  crossDomain: true,
-	dataType: 'jsonp',
-	type: "GET",
-	...	
-          	
-
-
    -
  • crossDomain -- are you sending the request to a domain that is not your own?
  • -
  • dataType -- how will you evaluate the data returned
  • -
  • type -- what type of request is it? -
      -
    • GET -- retrieve data
    • -
    • POST -- post new data
    • -
    -
  • -
-
- - -
-

jQuery Ajax

-
-

-	...
-  success: function (data) {
-	    // code with data returned
-	},
-	error: function(data) {
-		 // code with error returned
-	}
-	...	
-          	
-
-
    -
  • success -- code that will execute if results are sent back successfully
  • -
  • error -- code that will execute if results return an error
  • -
-
- - -
-

Let's Develop It!

-
    -
  • Create a new div with the id "events"
  • -
  • Create a new function in your javascript that calls Meetup open events method
  • -
  • Add parameters such as city, state or lat, lon to find meetups near you
  • -
  • Add a parameter such as category or topic to find meetups that you would be interested in
  • -
  • For now, just look at the results in the console.log()
  • -
  • Call this new function in document ready
  • -
-
- -
-

Let's Develop It!

- -
- -
-

Let's Develop It!

-
    -
  • Create a new function that can parse results.
  • -
  • Remember that the results will be an array of objects
  • -
  • Loop through your results
  • -
  • For each result, create a new div
  • -
  • Get the name, description, group name, and url of each event
  • -
  • Append them to your new div
  • -
  • Append the new div to the div "events"
  • -
-
- -
-

Let's Develop It!

-
    -
  • Create a form for users to enter in their location and a topic of their choosing
  • -
  • On submit, call the same Meetup open events method, but with the user's values
  • -
-
- -
-

Bonus

-

Still have time? Can't stop learning?

-
-

One of the best things about jQuery is the developer community

-

They love to build!

-

Check out some great plugins:

- -
-
- -
-

Questions?

-
? -
-
-
-
- -
-
- - - - - - - - - diff --git a/class4/exercise1/index.html b/class4/exercise1/index.html deleted file mode 100755 index f0c627e..0000000 --- a/class4/exercise1/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - My Site! - - - - - - My Site!
-
-
-
-
-
- Events I might like: -
-
-
-
-
- -
-
- -
-
-

My favorite things:

-
-
-
- -
- -
-
-
- -
- - \ No newline at end of file diff --git a/class4/exercise1/javascript.js b/class4/exercise1/javascript.js deleted file mode 100755 index 504ece7..0000000 --- a/class4/exercise1/javascript.js +++ /dev/null @@ -1,85 +0,0 @@ -$(document).ready(function(){ - getMeetups(); - $('.box').bind({ - click: function() { - $(this).css('background-color', 'green') - $(this).html('Clicked!') - }, - mouseenter: function() { - $(this).css('background-color', 'purple') - $(this).html('Hi!') - }, - mouseleave: function(){ - $(this).css('background-color', 'orange') - $(this).html('Bye!') - } - }); - $('#calculate').submit(function(event){ - var givenAge = $('#age').val(); - var givenSnack = $('#snack').val(); - var givenPerDay = $('#times-per-day').val(); - $('#lifetime-supply').html(calculate(givenAge, givenSnack, givenPerDay)); - return false; - }); - $('#favorites').submit(function(event){ - var givenThing = $('#thing').val(); - favoriteThings(givenThing); - return false - }); - $('#friends').submit(function(event){ - var name = $('#friend-name').val(); - var hair = $('#friend-hair').val() - var friend = {name: name, hair:hair}; - myFriends(friend); - return false; - }); -}); - -function getMeetups(){ - var api_key = "50722e1d56c194e61763a2ee1e4535"; - var url = "https://api.meetup.com/2/"; - var method = "open_events" - $.ajax({ - url: url + method, - data: { - key: api_key, - lat: 40.7143528, - lon: -74.0059731, - topic: 'JavaScript' - }, - crossDomain: true, - dataType: 'jsonp', - type: "GET", - success: function (data) { - console.log(data) - }, - error: function(data) { - console.log("Error", data); - } - }); -} - -function calculate(age, snack, perDay){ - var oldAge = 96; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - return "You will need " + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"; - }else{ - return "You will need " + + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"; - } -} - -function favoriteThings(thing){ - $('#favorite-things').append('

'+ thing +'

'); -} -function myFriends(friend){ - var resultDiv = $('
') - var resultParagraph = $('

' + describeFriend(friend) + '

'); - resultDiv.append(resultParagraph); - $('body').append(resultDiv); -} -function describeFriend(friend){ - return "My friend " + friend.name + " has " + friend.hair + " hair. "; -} \ No newline at end of file diff --git a/class4/exercise1/style.css b/class4/exercise1/style.css deleted file mode 100755 index e182bd6..0000000 --- a/class4/exercise1/style.css +++ /dev/null @@ -1,17 +0,0 @@ -.box{ - width: 200px; - height: 100px; - border: 1px solid #ccc; -} - -input{ - width: 200px; - padding: 5px; - margin: 5px; -} -.event{ - margin:5px; - padding:5px; - border: 1px solid #ccc; - background-color: #ddd; -} \ No newline at end of file diff --git a/class4/exercise2/index.html b/class4/exercise2/index.html deleted file mode 100755 index f0c627e..0000000 --- a/class4/exercise2/index.html +++ /dev/null @@ -1,40 +0,0 @@ - - - My Site! - - - - - - My Site!
-
-
-
-
-
- Events I might like: -
-
-
-
-
- -
-
- -
-
-

My favorite things:

-
-
-
- -
- -
-
-
- -
- - \ No newline at end of file diff --git a/class4/exercise2/javascript.js b/class4/exercise2/javascript.js deleted file mode 100755 index fe52d41..0000000 --- a/class4/exercise2/javascript.js +++ /dev/null @@ -1,97 +0,0 @@ -$(document).ready(function(){ - getMeetups(); - $('.box').bind({ - click: function() { - $(this).css('background-color', 'green') - $(this).html('Clicked!') - }, - mouseenter: function() { - $(this).css('background-color', 'purple') - $(this).html('Hi!') - }, - mouseleave: function(){ - $(this).css('background-color', 'orange') - $(this).html('Bye!') - } - }); - $('#calculate').submit(function(event){ - var givenAge = $('#age').val(); - var givenSnack = $('#snack').val(); - var givenPerDay = $('#times-per-day').val(); - $('#lifetime-supply').html(calculate(givenAge, givenSnack, givenPerDay)); - return false; - }); - $('#favorites').submit(function(event){ - var givenThing = $('#thing').val(); - favoriteThings(givenThing); - return false - }); - $('#friends').submit(function(event){ - var name = $('#friend-name').val(); - var hair = $('#friend-hair').val() - var friend = {name: name, hair:hair}; - myFriends(friend); - return false; - }); -}); - -function getMeetups(){ - var api_key = "50722e1d56c194e61763a2ee1e4535"; - var url = "https://api.meetup.com/2/"; - var method = "open_events" - $.ajax({ - url: url + method, - data: { - key: api_key, - lat: 40.7143528, - lon: -74.0059731, - topic: 'JavaScript' - }, - crossDomain: true, - dataType: 'jsonp', - type: "GET", - success: function (data) { - parseMeetups(data.results) - }, - error: function(data) { - console.log("Error", data); - } - }); -} - -function parseMeetups(results){ - for(var i = 0; i < results.length; i ++){ - var div = $('
'); - var name = $('
Name: '+ results[i].name+'
'); - var description = $('
Description: '+ results[i].description+'
'); - var group = $('
Group: '+ results[i].group.name+'
'); - var link = $('') - div.append(name, description, group, link); - $('#events').append(div); - } -} - -function calculate(age, snack, perDay){ - var oldAge = 96; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - return "You will need " + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"; - }else{ - return "You will need " + + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"; - } -} - -function favoriteThings(thing){ - $('#favorite-things').append('

'+ thing +'

'); -} -function myFriends(friend){ - var resultDiv = $('
') - var resultParagraph = $('

' + describeFriend(friend) + '

'); - resultDiv.append(resultParagraph); - $('body').append(resultDiv); -} -function describeFriend(friend){ - return "My friend " + friend.name + " has " + friend.hair + " hair. "; -} \ No newline at end of file diff --git a/class4/exercise2/style.css b/class4/exercise2/style.css deleted file mode 100755 index e182bd6..0000000 --- a/class4/exercise2/style.css +++ /dev/null @@ -1,17 +0,0 @@ -.box{ - width: 200px; - height: 100px; - border: 1px solid #ccc; -} - -input{ - width: 200px; - padding: 5px; - margin: 5px; -} -.event{ - margin:5px; - padding:5px; - border: 1px solid #ccc; - background-color: #ddd; -} \ No newline at end of file diff --git a/class4/exercise3/index.html b/class4/exercise3/index.html deleted file mode 100755 index c61e67d..0000000 --- a/class4/exercise3/index.html +++ /dev/null @@ -1,45 +0,0 @@ - - - My Site! - - - - - - My Site!
-
-
-
-
-
-
-
- -
-
- Events you might like: -
-
-
-
-
- -
-
- -
-
-

My favorite things:

-
-
-
- -
- -
-
-
- -
- - \ No newline at end of file diff --git a/class4/exercise3/javascript.js b/class4/exercise3/javascript.js deleted file mode 100755 index 0203e36..0000000 --- a/class4/exercise3/javascript.js +++ /dev/null @@ -1,101 +0,0 @@ -$(document).ready(function(){ - $('.box').bind({ - click: function() { - $(this).css('background-color', 'green') - $(this).html('Clicked!') - }, - mouseenter: function() { - $(this).css('background-color', 'purple') - $(this).html('Hi!') - }, - mouseleave: function(){ - $(this).css('background-color', 'orange') - $(this).html('Bye!') - } - }); - $('#calculate').submit(function(event){ - var givenAge = $('#age').val(); - var givenSnack = $('#snack').val(); - var givenPerDay = $('#times-per-day').val(); - $('#lifetime-supply').html(calculate(givenAge, givenSnack, givenPerDay)); - return false; - }); - $('#favorites').submit(function(event){ - var givenThing = $('#thing').val(); - favoriteThings(givenThing); - return false - }); - $('#friends').submit(function(event){ - var name = $('#friend-name').val(); - var hair = $('#friend-hair').val() - var friend = {name: name, hair:hair}; - myFriends(friend); - return false; - }); - - $('#meetup').submit(function(event){ - - getMeetups($('#topic').val(), $('#zipcode').val()) - return false; - }); -}); - -function getMeetups(topic, zipcode){ - var api_key = "50722e1d56c194e61763a2ee1e4535"; - var url = "https://api.meetup.com/2/"; - var method = "open_events" - $.ajax({ - url: url + method, - data: { - key: api_key, - zip: zipcode, - topic: topic - }, - crossDomain: true, - dataType: 'jsonp', - type: "GET", - success: function (data) { - parseMeetups(data.results) - }, - error: function(data) { - console.log("Error", data); - } - }); -} - -function parseMeetups(results){ - for(var i = 0; i < results.length; i ++){ - var div = $('
'); - var name = $('
Name: '+ results[i].name+'
'); - var description = $('
Description: '+ results[i].description+'
'); - var group = $('
Group: '+ results[i].group.name+'
'); - var link = $('') - div.append(name, description, group, link); - $('#events').append(div); - } -} - -function calculate(age, snack, perDay){ - var oldAge = 96; - - var days = (oldAge - age) * 356; - var total = perDay * days; - if(total > 40000){ - return "You will need " + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". Wow! That's a lot!"; - }else{ - return "You will need " + + total + " of " + snack + " to last you until the ripe old age of " + oldAge + ". You seem pretty reasonable"; - } -} - -function favoriteThings(thing){ - $('#favorite-things').append('

'+ thing +'

'); -} -function myFriends(friend){ - var resultDiv = $('
') - var resultParagraph = $('

' + describeFriend(friend) + '

'); - resultDiv.append(resultParagraph); - $('body').append(resultDiv); -} -function describeFriend(friend){ - return "My friend " + friend.name + " has " + friend.hair + " hair. "; -} \ No newline at end of file diff --git a/class4/exercise3/style.css b/class4/exercise3/style.css deleted file mode 100755 index e182bd6..0000000 --- a/class4/exercise3/style.css +++ /dev/null @@ -1,17 +0,0 @@ -.box{ - width: 200px; - height: 100px; - border: 1px solid #ccc; -} - -input{ - width: 200px; - padding: 5px; - margin: 5px; -} -.event{ - margin:5px; - padding:5px; - border: 1px solid #ccc; - background-color: #ddd; -} \ No newline at end of file diff --git a/images/bg_hr.png b/images/bg_hr.png new file mode 100644 index 0000000..514aee5 Binary files /dev/null and b/images/bg_hr.png differ diff --git a/images/blacktocat.png b/images/blacktocat.png new file mode 100644 index 0000000..e160053 Binary files /dev/null and b/images/blacktocat.png differ diff --git a/images/client-server.png b/images/client-server.png deleted file mode 100644 index 236a880..0000000 Binary files a/images/client-server.png and /dev/null differ diff --git a/images/console.png b/images/console.png deleted file mode 100644 index ee941c8..0000000 Binary files a/images/console.png and /dev/null differ diff --git a/images/dom.png b/images/dom.png deleted file mode 100644 index 217ed63..0000000 Binary files a/images/dom.png and /dev/null differ diff --git a/images/foursquare.png b/images/foursquare.png deleted file mode 100644 index 776a4cf..0000000 Binary files a/images/foursquare.png and /dev/null differ diff --git a/images/gdi_logo_badge.png b/images/gdi_logo_badge.png deleted file mode 100644 index 797ea96..0000000 Binary files a/images/gdi_logo_badge.png and /dev/null differ diff --git a/images/icon_download.png b/images/icon_download.png new file mode 100644 index 0000000..5a793f1 Binary files /dev/null and b/images/icon_download.png differ diff --git a/images/meetup.png b/images/meetup.png deleted file mode 100644 index 7af8cf8..0000000 Binary files a/images/meetup.png and /dev/null differ diff --git a/images/meetup_console.png b/images/meetup_console.png deleted file mode 100644 index 7fb5a3a..0000000 Binary files a/images/meetup_console.png and /dev/null differ diff --git a/images/meetup_open.png b/images/meetup_open.png deleted file mode 100644 index fe09581..0000000 Binary files a/images/meetup_open.png and /dev/null differ diff --git a/images/meetup_results.png b/images/meetup_results.png deleted file mode 100644 index c692a09..0000000 Binary files a/images/meetup_results.png and /dev/null differ diff --git a/images/results.png b/images/results.png deleted file mode 100644 index 94aea09..0000000 Binary files a/images/results.png and /dev/null differ diff --git a/images/sprite_download.png b/images/sprite_download.png new file mode 100644 index 0000000..f9f8de2 Binary files /dev/null and b/images/sprite_download.png differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..ba18928 --- /dev/null +++ b/index.html @@ -0,0 +1,79 @@ + + + + + + + + + + + Gdi-intro-to-javascript + + + + + + + + +
+
+

+Welcome to GitHub Pages.

+ +

This automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:

+ +
$ cd your_repo_root/repo_name
+$ git fetch origin
+$ git checkout gh-pages
+
+ +

If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.

+ +

+Designer Templates

+ +

We've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.

+ +

+Rather Drive Stick?

+ +

If you prefer to not use the automatic generator, push a branch named gh-pages to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.

+ +

+Authors and Contributors

+ +

You can @mention a GitHub username to generate a link to their profile. The resulting <a> element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.

+ +

+Support or Contact

+ +

Having trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.

+
+
+ + + + + + + + diff --git a/javascripts/main.js b/javascripts/main.js new file mode 100644 index 0000000..d8135d3 --- /dev/null +++ b/javascripts/main.js @@ -0,0 +1 @@ +console.log('This would be the main JS file.'); diff --git a/params.json b/params.json new file mode 100644 index 0000000..24de932 --- /dev/null +++ b/params.json @@ -0,0 +1 @@ +{"name":"Gdi-intro-to-javascript","tagline":"","body":"### Welcome to GitHub Pages.\r\nThis automatic page generator is the easiest way to create beautiful pages for all of your projects. Author your page content here using GitHub Flavored Markdown, select a template crafted by a designer, and publish. After your page is generated, you can check out the new branch:\r\n\r\n```\r\n$ cd your_repo_root/repo_name\r\n$ git fetch origin\r\n$ git checkout gh-pages\r\n```\r\n\r\nIf you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.\r\n\r\n### Designer Templates\r\nWe've crafted some handsome templates for you to use. Go ahead and continue to layouts to browse through them. You can easily go back to edit your page before publishing. After publishing your page, you can revisit the page generator and switch to another theme. Your Page content will be preserved if it remained markdown format.\r\n\r\n### Rather Drive Stick?\r\nIf you prefer to not use the automatic generator, push a branch named `gh-pages` to your repository to create a page manually. In addition to supporting regular HTML content, GitHub Pages support Jekyll, a simple, blog aware static site generator written by our own Tom Preston-Werner. Jekyll makes it easy to create site-wide headers and footers without having to copy them across every page. It also offers intelligent blog support and other advanced templating features.\r\n\r\n### Authors and Contributors\r\nYou can @mention a GitHub username to generate a link to their profile. The resulting `` element will link to the contributor's GitHub Profile. For example: In 2007, Chris Wanstrath (@defunkt), PJ Hyett (@pjhyett), and Tom Preston-Werner (@mojombo) founded GitHub.\r\n\r\n### Support or Contact\r\nHaving trouble with Pages? Check out the documentation at http://help.github.com/pages or contact support@github.com and we’ll help you sort it out.\r\n","google":"","note":"Don't delete this file! It's used internally to help with page regeneration."} \ No newline at end of file diff --git a/reveal/LICENSE b/reveal/LICENSE deleted file mode 100644 index 23a2d5a..0000000 --- a/reveal/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2011-2012 Hakim El Hattab, http://hakim.se - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file diff --git a/reveal/README.md b/reveal/README.md deleted file mode 100644 index dd7d820..0000000 --- a/reveal/README.md +++ /dev/null @@ -1,278 +0,0 @@ -# reveal.js - -A framework for easily creating beautiful presentations using HTML. [Check out the live demo](http://lab.hakim.se/reveal-js/). - -reveal.js comes with a broad range of features including [nested slides](https://github.com/hakimel/reveal.js#markup), [markdown contents](https://github.com/hakimel/reveal.js#markdown), [PDF export](https://github.com/hakimel/reveal.js#pdf-export), [speaker notes](https://github.com/hakimel/reveal.js#speaker-notes) and a [JavaScript API](https://github.com/hakimel/reveal.js#api). It's best viewed in a browser with support for CSS 3D transforms but [fallbacks](https://github.com/hakimel/reveal.js/wiki/Browser-Support) are available to make sure your presentation can still be viewed elsewhere. - - -#### More reading in the Wiki: -- [Changelog](https://github.com/hakimel/reveal.js/wiki/Changelog): Up-to-date version history. -- [Examples](https://github.com/hakimel/reveal.js/wiki/Example-Presentations): Presentations created with reveal.js, add your own! -- [Browser Support](https://github.com/hakimel/reveal.js/wiki/Browser-Support): Explanation of browser support and fallbacks. - -## rvl.io - -Slides are written using HTML or markdown but there's also an online editor for those of you who prefer a more traditional user interface. Give it a try at [www.rvl.io](http://www.rvl.io). - - -## Instructions - -### Markup - -Markup heirarchy needs to be ``
`` where the ``
`` represents one slide and can be repeated indefinitely. If you place multiple ``
``'s inside of another ``
`` they will be shown as vertical slides. The first of the vertical slides is the "root" of the others (at the top), and it will be included in the horizontal sequence. For example: - -```html -
-
-
Single Horizontal Slide
-
-
Vertical Slide 1
-
Vertical Slide 2
-
-
-
-``` - -### Markdown - -It's possible to write your slides using Markdown. To enable Markdown, add the ```data-markdown``` attribute to your ```
``` elements and wrap the contents in a ``` -
-``` - - -### Configuration - -At the end of your page you need to initialize reveal by running the following code. Note that all config values are optional and will default as specified below. - -```javascript -Reveal.initialize({ - // Display controls in the bottom right corner - controls: true, - - // Display a presentation progress bar - progress: true, - - // Push each slide change to the browser history - history: false, - - // Enable keyboard shortcuts for navigation - keyboard: true, - - // Enable the slide overview mode - overview: true, - - // Loop the presentation - loop: false, - - // Number of milliseconds between automatically proceeding to the - // next slide, disabled when set to 0, this value can be overwritten - // by using a data-autoslide attribute on your slides - autoSlide: 0, - - // Enable slide navigation via mouse wheel - mouseWheel: true, - - // Apply a 3D roll to links on hover - rollingLinks: true, - - // Transition style - transition: 'default' // default/cube/page/concave/zoom/linear/none -}); -``` - -### Dependencies - -Reveal.js doesn't _rely_ on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example: - -```javascript -Reveal.initialize({ - dependencies: [ - // Cross-browser shim that fully implements classList - https://github.com/eligrey/classList.js/ - { src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } }, - // Interpret Markdown in
elements - { src: 'plugin/markdown/showdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - { src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } }, - // Syntax highlight for elements - { src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } }, - // Zoom in and out with Alt+click - { src: 'plugin/zoom-js/zoom.js', async: true, condition: function() { return !!document.body.classList; } }, - // Speaker notes - { src: 'plugin/notes/notes.js', async: true, condition: function() { return !!document.body.classList; } } - ] -}); -``` - -You can add your own extensions using the same syntax. The following properties are available for each dependency object: -- **src**: Path to the script to load -- **async**: [optional] Flags if the script should load after reveal.js has started, defaults to false -- **callback**: [optional] Function to execute when the script has loaded -- **condition**: [optional] Function which must return true for the script to be loaded - - -### API - -The Reveal class provides a minimal JavaScript API for controlling navigation and reading state: - -```javascript -// Navigation -Reveal.slide( indexh, indexv ); -Reveal.left(); -Reveal.right(); -Reveal.up(); -Reveal.down(); -Reveal.prev(); -Reveal.next(); -Reveal.prevFragment(); -Reveal.nextFragment(); -Reveal.toggleOverview(); - -// Retrieves the previous and current slide elements -Reveal.getPreviousSlide(); -Reveal.getCurrentSlide(); - -Reveal.getIndices(); // { h: 0, v: 0 } } -``` - -### States - -If you set ``data-state="somestate"`` on a slide ``
``, "somestate" will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide. - -Furthermore you can also listen to these changes in state via JavaScript: - -```javascript -Reveal.addEventListener( 'somestate', function() { - // TODO: Sprinkle magic -}, false ); -``` - -### Ready event - -The 'ready' event is fired when reveal.js has loaded all (synchronous) dependencies and is ready to start navigating. - -```javascript -Reveal.addEventListener( 'ready', function( event ) { - // event.currentSlide, event.indexh, event.indexv -} ); -``` - -### Slide change event - -An 'slidechanged' event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes. - -```javascript -Reveal.addEventListener( 'slidechanged', function( event ) { - // event.previousSlide, event.currentSlide, event.indexh, event.indexv -} ); -``` - -### Internal links - -It's easy to link between slides. The first example below targets the index of another slide whereas the second targets a slide with an ID attribute (```
```): - -```html -Link -Link -``` -### Fullscreen mode -Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode. - -### Fragments -Fragments are used to highlight individual elements on a slide. Every elmement with the class ```fragment``` will be stepped through before moving on to the next slide. Here's an example: http://lab.hakim.se/reveal-js/#/16 - -The default fragment style is to start out invisible and fade in. This style can be changed by appending a different class to the fragment: - -```html -
-

grow

-

shrink

-

roll-in

-

fade-out

-

highlight-red

-

highlight-green

-

highlight-blue

-
-``` - -### Fragment events - -When a slide fragment is either shown or hidden reveal.js will dispatch an event. - -```javascript -Reveal.addEventListener( 'fragmentshown', function( event ) { - // event.fragment = the fragment DOM element -} ); -Reveal.addEventListener( 'fragmenthidden', function( event ) { - // event.fragment = the fragment DOM element -} ); -``` - - -## PDF Export - -Presentations can be exported to PDF via a special print stylesheet. This feature requires that you use [Google Chrome](http://google.com/chrome). -Here's an example of an exported presentation that's been uploaded to SlideShare: http://www.slideshare.net/hakimel/revealjs-13872948. - -1. Open your presentation with [css/print/pdf.css](https://github.com/hakimel/reveal.js/blob/master/css/print/pdf.css) included on the page. The default index HTML lets you add *print-pdf* anywhere in the query to include the stylesheet, for example: [lab.hakim.se/reveal-js?print-pdf](http://lab.hakim.se/reveal-js?print-pdf). -2. Open the in-browser print dialog (CMD+P). -3. Change the **Destination** setting to **Save as PDF**. -4. Change the **Layout** to **Landscape**. -5. Change the **Margins** to **None**. -6. Click **Save**. - -![Chrome Print Settings](https://s3.amazonaws.com/hakim-static/reveal-js/pdf-print-settings.png) - - -## Speaker Notes - -reveal.js comes with a speaker notes plugin which can be used to present per-slide notes in a separate browser window. The notes window also gives you a preview of the next upcoming slide so it may be helpful even if you haven't written any notes. Append ```?notes``` to presentation URL or press the 's' key on your keyboard to open the notes window. - -By default notes are written using standard HTML, see below, but you can add a ```data-markdown``` attribute to the ```