Personal homepage JS
__MACOSX/._Javascript_DOM_Functions_Objects_Events
Javascript_DOM_Functions_Objects_Events/index.html
NEIU CS300 Javascript DOM, Functions & Events Honda ACRD ODSY CRV PLT Toyota CMRY SNA CRLA Nissan RGE ALTM MXMA SNTR ARMD Computer User No Cars Selected Northeastern Illinois University - CS300 © Copyright 2018Javascript_DOM_Functions_Objects_Events/.DS_Store
__MACOSX/Javascript_DOM_Functions_Objects_Events/._.DS_Store
Javascript_DOM_Functions_Objects_Events/css/.DS_Store
__MACOSX/Javascript_DOM_Functions_Objects_Events/css/._.DS_Store
Javascript_DOM_Functions_Objects_Events/css/styles.css
body{ float: left; width: 100%; padding: 0; margin: 0; font-family: calibri, arial, sans-serif; } header{ position: fixed; top: 0; left: 0; width: 96%; height: 75px; padding: 20px 2%; border-bottom: 2px solid black; background: #f7f7f7; z-index: 5; color: #008B95; } header .left{ font-size: 36px; } header .right{ font-size: 18px; } .left{ float: left; width: 35%; } .right{ float: right; width: 60%; text-align: right; } .big{ font-weight: 900; text-transform: uppercase; } .small{ font-weight: 400; text-transform: lowercase; } #container{ float: left; width: 100%; height: 500px; margin-top: 150px; } article{ float: right; width: 98%; padding-top: 2%; min-width: 490px; height: auto; } h2{ float: left; clear: both; width: 50%; margin: 10px 0 5px 5%; } .clear{ float: left; width: 100%; clear: both; } footer{ float: left; width: 100%; padding: 20px 0; margin-top: 30px; border-top: 5px double black; } .ftrLeft{ padding-left: 2%; } .ftrRight{ padding-right: 2%; } .orange{ background: #E98E4E; } .orangeHover{ background: #f0b083; } .blueGreen{ background: #6CA3B2; } .lightAqua{ background: #99D1D5; } .lightAquaHover{ background: #b8dfe2; } /*Lot*/ .row{ width: 100%; height: 12%; float: left; } .col-3{ width: 24%; } .col-6{ width: 49%; } .col-9{ width: 74%; } .button{ height: 80%; line-height: 100%; margin: 1.25px .5%; float: left; background: #6CA3B2; color: white; text-align: center; font-size: 48px; } .button:hover{ cursor: pointer; background: #b8dfe2 !important; } #carLot{ width: 25%; height: 420px; margin-left: 2%; padding: 2%; float: left; background: rgba(0, 0, 0, .1); color: white; border: 2px solid black; } #console{ width: 64%; height: 470px; margin-right: 2%; float: right; font-size: 18px; border: 2px solid black; overflow: scroll; } #console div b{ text-decoration: underline; } #consoleLeft{ height: 100%; width: 30%; border-right: 1px solid rgba(0, 0, 0, .5); } #consoleRight{ height: 100%; /*width: 56%;*/ float: left; } #consoleLeft, #consoleRight{ padding: 2%; text-align: left; overflow: scroll; } .make{ float: left; clear: both; width: 100%; height: 145px; } .makeName{ float: left; clear: both; width: 100%; height: 30px; line-height: 30px; font-size: 24px; color: black; } .car{ float: left; height: 100px; width: 15%; margin: 2%; border: 1px solid black; color: black; background: #99D1D5; box-shadow: 3px 3px 3px 0 rgba(0, 0, 0, .3); } .car:hover, .car:active{ background: #b8dfe2; } .car:active{ font-weight: bold; border-width: 3px; } .roof{ float: left; width: 96%; height: 50%; margin-top: 40%; padding: 2%; line-height: 50px; text-align: center; border-top: 1px solid black; border-bottom: 1px solid black; } .roof:active{ border-top-width: 3px; border-bottom-width: 3px; }
Javascript_DOM_Functions_Objects_Events/images/favicon.ico
__MACOSX/Javascript_DOM_Functions_Objects_Events/images/._favicon.ico
Javascript_DOM_Functions_Objects_Events/images/.DS_Store
__MACOSX/Javascript_DOM_Functions_Objects_Events/images/._.DS_Store
Javascript_DOM_Functions_Objects_Events/scripts/scripts.js
/* * document.getElementById(id) -> single node * ToDo: Get #consoleLeft and #consoleRight */ /* * document.getElementsByClassName(class) -> nodeList * ToDo: Get all .car */ /* * document.querySelectorAll(selector) -> nodeList * ToDo: Get all #toyotas .car and #nissans .car */ /* * document.getElementsByTagName(tagName) --> return a node list with every element of this type */ /* * document.createElement(tagToCreate) -> new tag * ToDo: Create a new paragraph */ /* * [element].innerHTML -> set the HTML of a node (may include tags) * ToDo: Set HTML of new paragraph to list the count of cars in the dealer lot */ /* * [element].style -> set a desired CSS property (use camelCase instead of hyphens) * ToDo: Change new paragraph text color to red */ /* * [element].setAttribute(attrName, attrValue) -> set a desired attribute * ToDo: Set id for new paragraph to 'allCars' */ /* * [element].appendChild(newElement) -> adds new element as the last child of the parent * ToDo: Add new paragraph to #consoleLeft */ //Create another new paragraph /* * document.createTextNode('text') -> new text node (i.e. text only) * ToDo: Create a new text node and set text to be # of Toyotas on the dealer lot * - Add the new text to the paragraph * - Add the paragraph to #consoleLeft */ //Create another new paragraph //Set the text to be # of Nissans on the dealer lot //Create a new ul /* * forEach -> loop through a collection/list * ToDo: Loop thru all nissans * - Create an li for each nissan * - Get the model from name attribute * - Make text the model using [element].textContent * * Inside forEach loop * [element].getAttribute(attr) -> gets the value of an attribute */ //Add ul to #consoleLeft /* * [element].insertBefore(newElement, existingElement) -> adds new element before a specific child * ToDo: Add new paragraph to #consoleLeft before the ul */ /* * function -> Javascript version of a method * ToDo: Create printCarDetails(carDiv) * - Loop thru cars and compare model to name attribute (getAttribute) * - Get Car Details and output to #consoleRight */ //Loop thru cars and find selected car object //Get #carTitle //Create h5 and give id carTitle /* * [element].textContent -> another way to set a node's text (no tags allowed) * ToDo: Set h5 text to car make and model */ /* * [element].replaceChild(newElement, existingElement) -> replace existing child with new element * ToDo: Replace h5 with carTitle */ /* * ToDo: Create new paragraph * - Set innerHTML to be year, # of doors, MSRP, 72 monthly payments */ //Find all existing #consoleRight p and remove 1st one /* * Inside if block * [element].removeChild(toRemove) -> remove existing child */ //Add new paragraph to #consoleRight /* * addEventListener -> add a 'listener' so we can respond to a specific action * ToDo: Add 'click' event listener for all Toyotas to go to printCarDetails(this) * ToDo: Add 'click' event listener for all Nissans to go to printCarDetails(this) */ /* * setInterval(codeToExecute, milliseconds) -> executes something at a specified interval (every 'x' amount of milliseconds) * ToDo: Set an interval that will update the count of Hondas on the lot once every second */ /* * setTimeout(codeToExecute, milliseconds) -> executes the specified code ONCE after 'x' amount of time * clearInterval(intervalName) -> stops the interval * ToDo: Since there are only 4 Hondas on the lot, stop the counter after 4 seconds. Set a timeout for 4 seconds that will clear the interval */ //Set an interval that will update the count of Toyotas on the lot once every second. Stop counting once you've reached the number of toyotas
__MACOSX/Javascript_DOM_Functions_Objects_Events/scripts/._scripts.js
Javascript_DOM_Functions_Objects_Events/scripts/cars.js
/* * using a function to create an object */ function Car(make, model, year, doors, price){ this.make = make; this.model = model; this.year = year; this.doors = doors; this.price = price; /* * Privelaged function -> a function belonging to the object */ this.msrp = function(){ /* * toLocaleString -> allows us to format text according to region */ return price.toLocaleString('en-US', { style: 'currency', currency: 'USD' }); } this.monthlyPayments = function(term){ var amount = this.price / term; return amount.toLocaleString('en-US', { style: 'currency', currency: 'USD' }); } } var accord = new Car('Honda', 'Accord', 2017, 4, 26000); var odyssey = new Car('Honda', 'Odyssey', 2018, 4, 35000); var crv = new Car('Honda', 'CRV', 2017, 4, 17500); var pilot = new Car('Honda', 'Pilot', 2018, 4, 32595); var camry = new Car('Toyota', 'Camry', 2018, 4, 27500); var sienna = new Car('Toyota', 'Sienna', 2018, 4, 34500); var corolla = new Car('Toyota', 'Corolla', 2017, 4, 23250); var rogue = new Car('Nissan', 'Rogue', 2018, 4, 19570); var altima = new Car('Nissan', 'Altima', 2018, 4, 28200); var maxima = new Car('Nissan', 'Maxima', 2018, 2, 31000); var sentra = new Car('Nissan', 'Sentra', 2017, 4, 16500); var armada = new Car('Nissan', 'Armada', 2017, 4, 32250); var cars = [accord, odyssey, crv, pilot, camry, sienna, corolla, rogue, altima, maxima, sentra, armada];