Midterm Review
Midterm Review Questions
The images already rearrange themselves as you make the window wider or narrower! Why? Why did we have to make paragraphs float left to achieve a similar result?
-because the maximum width of the html document is by default the size of your screen. You have not specified any margins, but the margins are already predefined to be the size the users display as the absolute max. -images by default will float left next one another -each paragraph by default floats left, but also with a new line break.
The DOM (document object model)
Draw Elements from DOM
Child and parent relationship
The DOM network
Modifying the DOM
Adding style:
Add and remove elements from the DOM
Adding Script Node will?
First, including a script url will embed the api script that is returned by that url.
But in general (and, in then) the script becomes executed automatically.
JSONp essentially acts like a script object
Removing children from parent
Objects
Defined as literals
Everything is public
Defined with constructor functions
Allows private data and methods, using var
this keywords defines public data.
If we return b in tell(), this can work.
Variable scope
A variable defined in a function without the var keyword become global.
Consider:
Closures
How we can manage to define private variables
Another example
data is both preserved in the closure, as well as remains private to the new object.
Asynchronous programming and Event Handlers
Web programs run by event handlers
Onclick, animation, callbacks
Here was the example with API request
SVG
Scalable vector Graphics
Is a program that defines vector graphic visual
Consider the following SVG
Which is defined as follows:
Where we can notice we have 2 defined rectangle objects with properties:
Position x, y within the document
Fill colors in hex representation
Width and height properties
Timers and Animation
var animObj = setInterval(singleFrame, 30);
Runs callback function every 30 seconds
stop with clearInterval(animObj);
JSON and Object Access.
Javascript literal
Use to pass around information
Converted to and from object literals
Contains only data, not methods
Accessing information from JSON
Indexing -> [] for lists
.whatever for dictionaries
Colors
Hexadecimal to Color:
#ff8020;
Read in 3 equal parts: red/green/blue
1) Convert each 2 numbers into base 10
2) In our case, 255/128/32
These number represent the intensity of each respected color
To interpret the color use this with the RGB intensities:

Color to Hexadecimal:
Start with the RGB color cube
Define the intensities in base 10
Convert to hexadecimal with base conversion.
Have all the same RGB code will define some color within the white->black range.
HTML (hyper-text-markup-language), CSS and Layout
Two types of elements: inline and block
Inline: Like words within paragraph tags
We use text-align to describe the horizontal properties of inline, and vertical-align for vertical properties.
ex:
<a>, <b> (bold), <i>(italics), <img>
img because it can be placed mid way between a group of words
Block: Like images, or complete paragraphs.
ex:
<p>, <h1>, <ul>,<nav>(nav bar),<div>
Responsive:
Fixed: use pixels, whose size is relative to the resolution of display. For smart phone devices, the size also varies appropriately with the device. (e.g. reference pixels which get larger based how far your eyes are from the screen (predefined ofcourse)).
Useful with icons
Fluid: use percentages
Size of element includes size of content and size of padding, border and margin.
Inline-block example:
Responsive Nav Bar Example:
CSS Override Rules
Specificity
last specified property
div id over classes
MVC Architecture
Model
manages and stores data
responds to informational changes
manages logic, and rules
updates view
View
extends model
displays user interface
take current information from model
Controller
extends model
accepts input to manipulate model
Last updated
Was this helpful?