1. web server: internet-connected computers running server software, so called because they serve web documents as requested.
2. local: web developers run on the same computer you are working on
server software packages: Apache is the most common one.
3. web clients( browsers): Chrome/firefox/...
4. URL:
commnunication protocol(HTTP/HTTPS):// domain name:port/path
5. when you visit a website such as: alignedleft.com/tutorials/d3/
1) without sepcify a protocol, HTTP is assumed, and http:// is prepended to the URL
2) the browser attempt to connect to the server behind alignedleft.com across the network, via port 80, hte default port for HTTP
3) the server associated with alignedleft.com acknowledges the connection and is taking requests.
4) the browser sends a request for the page that lives at / tutorials/d3
5) the server sends back the HTMLcontent for that page
6) the client browser receives the HTML, it discovers references to other files needed to assemble and display the entire page, including CSS, images. So it contacts the server again, once per file, requesting the additonal information.
7) the server responds, dipatching each file as needed
8) finally, all the web documents have been transferred over. Now the client is to render the content.
parse HTML to understand its structure of the content.--review the CSS selectors, apply properties to matched elements.--plug in images and execute JavaScript code.
6. Classes and ids attributes
they can be assigned to any type of element. CSS ans JavaScript rely heavily on them.
Class and ID names can only begin with alphabetic characters.
7. comments in HTML
<!-- COMMENTS -->
8. DOM : Document Object Model refers to the hierarchical structure of HTML
the browser will parse HTML to make sense of a page's content.
As coders building visualizations, we care about the DOM, because our code must navigate its hierarchy to apply styles and actions to its elements.
9. rendering
definition: the process by which browsers, after parsing the HTML and generating the DOM, apply visual rules to the DOM contents and draw those pixels to the screen.
everything is a box!!
CSS
10. CSS
consists of selectors and properties, like the following:
selector {
the same properties can be applied to multiple selectors at once by separating selectors with a comma, as in the following:
match the single element with a given ID
#header
#nav
combine selectors in different ways to target specific elements.
div.sidebar /* selects elements div with class sidebar */
#button.on /* select element with ID "button" , but only when the class "on" is applied */
12. Properties and Values:
groups of property/ value pairs cumulatively form the styles:
margin: 10px;
padding: 25px;
color: pink;
13. comments
/* COMMENTS */
14. Referencing styles
1) embed the CSS in your HTML
embed the css style in the document head, include all the CSS code within a style element
<head>
2) Reference an external stylesheet from the HTML
<head>
3) Attach inline styles
add a style attribute to any element
<p style="color: blue; font-size: 48px; font-style: italic; "> Inline styles </p>
15. Inheritance, Cascading, and Specificity
Inheritance is a great feature of CSS, as children adopt styles of their parents.
Cascading: because selectors matches cascade from the top down. when more than one selectors applies to an element, the latest one override the old ones, as in the following:
(5) and assigns it to the variable on the left (number).
var fruits = [{kind: "grape",color: "red",quantity: 12,tasty: true},{kind: "kiwi",color: "brown",quantity: 98,tasty: true}];
fruits[0].kind
JSON
Specific syntax for organizing data as JavaScript objects, the syntax is optimized for use with Javascript and AJAX requests,
which is why you'll see a lot of web-based application programming interfaces(APIs) that return data formate as JSON
First, the initialization statement is run. Then, the test is evaluated, like a mini if statement. If the test is true, then the bracketed code is run. Finally, the update statement is run, and the test is reevaluated.
1) embedded in HTML
<body>
<script type="text/javascript">alert("Hello, world!");</script>
<title>Page Title</title>
<script type="text/javascript" src="myscript.js"></script>
</head>
8. Gotchas:
1) dynamic typing: automatically types a variable based on what kind of information you assign to it. (Note that '' or "" indicate string values. I prefer double quotation marks "", but some people like singles ' '.)
2) variable hoisting:
Contrary to what you would expect, JavaScript code is usually, but not always, executedin linear, top-to-bottom order, as in the following:
var numLoops = 100;
for (var i = 0; i < numLoops; i++) {
console.log(i);
};
which is equivalent to
var numLoops = 100;
var i;
for (i = 0; i < numLoops; i++) {
console.log(i);
}
variable declarations are hoisted up to the top of the function context in which they reside. So in our example, i is actually declared before the for loop even begins
3) function level scope
In programming, the concept of variable scope helps us identify which variables are accessible in which contexts.
Many languages use block-level scope, in which variables exist only within the current “block” of code, usually indicated by curly braces. With block-level scope, our i would exist only within the context of the for loop, for example, so any attempts to read the value of i or change i outside of the loop would fail
In JavaScript, however, variables are scoped at the function level, meaning they are accessible anywhere within the function (not block) in which they reside.
Global namespace
window
var zebras="amazing"; // this will add variable zebras into window global namespace
What’s so wrong with adding values to window? As you get started, nothing at all. But as your projects grow in complexity, and especially if you begin to incorporate other non-D3 JavaScript code (such as jQuery, Facebook “Like” buttons, or Google Analytics
tracking code), at some point you’re bound to run into a conflict because you’re using the variable zebras for your project, but zebraTracker.js is also using a variable with the
There are two easy workarounds (and, to clarify, you probably don’t have to worry about this until later):
• Declare variables only within other functions. This is not usually feasible, but the function-level scope will prevent local variables from conflicting with others.
• Declare a single global object, and attach all of your would-be global variables to that object. For example:
var Vis = {}; //Declare empty global object
Vis.zebras = "still pretty amazing";
Vis.monkeys = "too funny LOL";
Vis.fish = "you know, not bad";