Giter VIP home page Giter VIP logo

exercise-w03d03-js's Introduction

Fellowship of the Bling ($)

Frodo ponders the power of the ring.

Using our new-found knowledge of jQuery, create a function for each of the following steps to practice DOM Manipulation, JavaScript, and jQuery.

Setup

Check out js/fellowship.js. This is where you will work.

Starter data (character and land names) has been provided in js/data.js.

Remember to work on a localhost server!

Directions

  1. Define and invoke the functions outlined below inside of js/fellowship.js.
  2. Do Parts 1 and 2. Everything else is extra, in case you want to continue practicing.
  3. If you finish with Part 5, you can try to chain together all of the functions you've created. The easiest way to do this is to call them all with setTimeout... But you can also attempt to chain them using jQuery's queue method.

Part 1

Make Middle Earth

var makeMiddleEarth = function() {
  // 1.  Create a section tag with an id of "middle-earth".
  // 2.  Create an article tag for each land in the lands array.
  // 3.  Give each article tag a class of "land".
  // 4.  Inside each article tag include an h1 tag with the name
  //     of the land as content.
  // 5.  Append each article.land to section#middle-earth.
  // 6.  Append section#middle-earth to the document body.
}

// test this in the console (watch the HTML, though) by running:
makeMiddleEarth();

Make the Hobbits

var makeHobbits = function() {
  // 1.  Create a ul tag with an id of "hobbits".
  // 2.  Create li tags for each Hobbit in the hobbits array.
  // 3.  Give each li tag a class of "hobbit".
  // 4.  Set the text of each li.hobbit to one of the Hobbits
  //     in the array.
  // 5.  Append the ul#hobbits to the article.land representing 
  //     "The Shire" (the first article tag on the page).
}

// test this in the console (watch the HTML, though) by running:
makeHobbits();

Part 2

Keep It Secret, Keep It Safe

var keepItSecretKeepItSafe = function() {
  // 1.  Create a div with an id of "the-ring".
  // 2.  Give div#the-ring a class of "magic-imbued-jewelry".
  // 3.  Add div#the-ring as a child element of the li.hobbit
  //     representing "Frodo."
}

// test this in the console (watch the HTML, though) by running:
keepItSecretKeepItSafe();

Make Buddies

var makeBuddies = function() {
  // 1.  Create an aside tag.
  // 2.  Create a ul tag with an id of "buddies" and append it to 
  //     the aside tag.
  // 3.  Create li tags for each buddy in the buddies array in 
  //     data.js.
  // 4   Give each li tag a class of "buddy" and append them to 
  //       "ul#buddies".
  // 5.  Insert the aside tag as a child element of the secion.land 
  //     representing "Rivendell."
}

// test this in the console (watch the HTML, though) by running:
makeBuddies();

Beautiful Stranger

var beautifulStranger = function() {
  // 1.  Find the li.buddy representing "Strider".
  // 2.  Change the "Strider" text to "Aragorn" and make its 
  //     color green.
}

// test this in the console (watch the HTML, though) by running:
beautifulStranger();

Leave the Shire

var leaveTheShire = function() {
  // 1.  "Assemble the Hobbits" and move them (as a list) to Rivendell.
}

// test this in the console (watch the HTML, though) by running:
leaveTheShire();

Part 3

Forge the Fellowship

var forgeTheFellowShip = function() {
  // 1.  Create a div with an id of "the-fellowship" within the 
  //     section.land for "Rivendell". Append a list to it.
  // 2.  Add each hobbit and buddy one at a time to 
  //     'div#the-fellowship' list.
  // 3.  After each character is added make an alert that they 
  //     have joined your party.
}

// test this in the console (watch the HTML, though) by running:
forgeTheFellowShip();

The Balrog

var theBalrog = function() {
  // 1.  Select the "li.buddy" for "Gandalf"...
  // 2.  And change its text to "Gandalf the White", and give it
  //     the class "the-white".
  // 3.  Apply style to the element, adding a "3px solid white" 
  //     border to it, giving it a border radius of "10px," and
  //     making it's color white.
}

// test this in the console (watch the HTML, though) by running:
theBalrog();

Horn of Gondor

// Boromir's been killed by the Uruk-hai!!

var hornOfGondor = function() {
  // 1.  Pop up an alert that the Horn of Gondor has been blown.
  // 2.  Put a line-through on Boromir's name.
  // 3.  Fade Boromir's opacity to 0.3 (he lives on in spirit).
  // 4.  Make Boromir's text color black.
}

// test this in the console (watch the HTML, though) by running:
hornOfGondor();

Part 4

It's Dangerous to Go Alone

var itsDangerousToGoAlone = function() {
  // 1.  Create a list with class "soulmates" in Mordor.
  // 2.  Take Frodo and Sam out of The Fellowship and move them 
  //     to ul.soulmates in Mordor.
  // 3.  Add a div with an id of "mount-doom" to Mordor
}

// test this in the console (watch the HTML, though) by running:
itsDangerousToGoAlone();

"We Wants It!"

function weWantsIt() {
  // 1.  Create a div with an id of "gollum" and add it to Mordor.
  // 2.  Remove The Ring from Frodo and give it to Gollum.
  // 3.  Move Gollum into Mount Doom.
}

// test this in the console (watch the HTML, though) by running:
weWantsIt();

There And Back Again

function thereAndBackAgain() {
  // 1.  Remove Gollum and the Ring from the document.
  // 2.  Add a list to the shire, and move all the hobbits in to it.
  // 3.  Add the class "collapse" to Mordor.
}

// test this in the console (watch the HTML, though) by running:
thereAndBackAgain();

Part 5

Now that we have all of these functions running, let's add some interaction!

  1. When the page loads, begin playing the sound that can be found in the element with id "hobbit-theme";
  2. Add an event listener to the "Ring" (element with id "the-ring").
  3. When the user "clicks" on the Ring, run the function nazgulScreech (found in js/data.js)
  4. When the user "clicks" on the Ring, it causes Frodo's opacity to go down to 0 for two seconds (using jQuery's fadeOut), only to fade back in (using jQuery).
  5. If the Ring is clicked 3 times, the entire body element should disappear, to be replaced with the text:
    The Ring has been returned to Sauron and the world is over.
    Good job, Bozo Baggins!

Part 6

Use a series of setTimeout calls, chained as in the example below, or (even better) jQuery's queue method in order to run the functions in order!

A setTimeout example:

var makeMiddleEarth = function() {
  console.log("in the beginning, there was the word...");
  setTimeout(makeHobbits, 2000);
}

var makeHobbits = function() {
  console.log("makin' 'obbits");
}

makeMiddleEarth();

Have the animations begin the second the page loads!

Bonus

Add Play and Pause buttons to the page that begin or stop the queued animation functions!

This should work, regardless of where in the storyline you are!

Resources

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.