GithubHelp home page GithubHelp logo

nss-day-cohort-17 / mastey-exercise-single-page-app-lukeschuyler Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 29 KB

mastey-exercise-single-page-app-lukeschuyler created by GitHub Classroom

HTML 10.08% CSS 14.44% JavaScript 75.49%

mastey-exercise-single-page-app-lukeschuyler's Introduction

Single Page Applications Quiz

Setup

  1. Create the working directory for the quiz first.

    mkdir -p ~/workspace/quizzes/spa && cd $_
  2. Clone this repository and cd into the directory it creates.

  3. Now run the following commands.

    git checkout -b quiz
    touch index.html
    touch quiz.js
    touch quiz.css
    touch inventory.json

You are now ready to work in the quiz branch.

When your work in complete, push up the branch (git push origin quiz) and submit the pull request on Github.

Instructions

You operate a used car lot, and need to have an application where you can update the description and availability of each car in your inventory. You are going to using the Bootstrap grid to lay out your HTML structure.

Behavior

  1. Create an array of cars in the inventory.json file (see example structure below). Put at least three cars in the array.
  2. When your page first loads, you need to use an XHR to load the contents of the JSON file, and parse them into a native JavaScript object.
  3. Loop over your array of cars and build up an HTML string to build a card for each car. Also, use Bootstrap to create rows. Each row should contain 3 columns. Make sure you have a parent element with a class of container. Hint: You must build up the entire string of columns/rows before injecting into the DOM. Use a counter variable to know when to close a row after three columns.
  4. Put a standard Bootstrap navbar element at the top of your page.
  5. Put a text input field in the navigation bar.
  6. Make sure you display all properties of the car in the DOM. Basic styling is up to you.
  7. Make sure that each car card element has a CSS class which adds a black border around it.
  8. When you click on one of the car elements, change the width of the border to a higher value, and change the background color to any other color of your choosing.
  9. Also, on click of the car element, clear the value of the text input in the navbar, and put the cursor in the text input.
  10. When you start typing into the navbar's text input, the description, and only that property, of the currently selected car should be bound to what you are typing in and match it exactly.

Technical Requirements

  1. You should add a function (e.g. loadInventory) that loads the inventory.json file and stores the inventory in a variable. This function should accept
  2. You should add a function populatePage that renders the inventory to the page.
  3. You should add a function that only creates all of the eventHandlers that you need for the application. Name the function activateEvents.
  4. You should add a function that resets the border thickness and background color for each car element back to the original values.
  5. You should add a function that changes the thickness of the border of a car element, and changes its background color. The function must accept two arguments:
    1. A car DOM element that was clicked on.
    2. A color name of your choice (see behavior requirement 5 above).

Starter Code

Please read, and feel free to use, the code below to get started.

inventory.json
{
  "cars": [
    {
      "make": "Nissan",
      "model": "Rogue",
      "year": "2006",
      "price": "8999",
      "description": "This is an immaculate 2006 Nissan Rogue with only 25000 miles on it. Leather seats, power everything."
    }
  ]
}
quiz.js
var inventory = [];
loadInventory();

function populatePage (inventory) {
  // Loop over the inventory and populate the page

  // Now that the DOM is loaded, establish all the event listeners needed
  activateEvents();
}

// Load the inventory and send a callback function to be
// invoked after the process is complete

function loadInventory (callback) {
  var inventoryLoader = new XMLHttpRequest();

  inventoryLoader.addEventListener("load", function () {

  });
}

string-manipulation

mastey-exercise-single-page-app-lukeschuyler's People

Contributors

lukeschuyler avatar stevebrownlee avatar sscotth avatar

Watchers

James Cloos avatar Callan Morrison avatar

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.