390 likes | 401 Views
Learn the fundamentals of HTML, CSS, and JavaScript in this crash course. Install Firebug or Chrome, complete the online skills assessment, and join the i290-iolab@ischool mailing list.
E N D
LAST WEEK ON IO LAB If you haven’t done these things already, please do them before we begin today’s lecture Install Mozilla Firebug OR Chrome Complete the online skills assessment. Join the i290-iolab@ischool mailing list. Check out http://tinyurl.com/3rojd6y
Berkeley School of Information, Fall 2011 Information Organization Lab
HTML <p>This is a paragraph.</p> <imgsrc="http://site.com/a.png"> <ol><li>Item One</li><li>Item Two</li></ol>
HTML element <p>This is a paragraph.</p> <imgsrc="http://site.com/a.png"> <ol><li>Item One</li><li>Item Two</li></ol> nested elements
HTML Structure tag <p>This is a paragraph.</p> <imgsrc="http://site.com/a.png"> <ol><li>Item One</li><li>Item Two</li></ol> closing tag
HTML Attributes <p>This is a paragraph.</p> attribute <imgsrc="http://site.com/a.png"> <ol id="alphaList"><li class="subtle">Item One</li><li class="heavy">Item Two</li></ol>
(Bad/Old) HTML <body><p>This is <fontface="Papyrus"size="+3">hideous!</font><formonsubmit="validateForm();"><inputtype="submit"></form></body>
(Bad/Old) HTML <body><p>This is <fontface="Papyrus"size="+3">hideous!</font><formonsubmit="validateForm();"><inputtype="submit"></form></body>
HTML5 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> Simplify:<!DOCTYPE html><html lang="en">
HTML5 <imgsrc="http://berkeley.edu/logo.png"> <imgsrc="http://berkeley.edu/logo.png"/> <imgsrc="http://berkeley.edu/logo.png">
body div header div content h1 p p p ul li li li Document Object Model <html><body><divid="header"><h1>Document Object Model</h1></div><divid="content"><p>This is my first paragraph</p><p>My second paragraph has a list:<ul><li>Item One</li><li>Item Two</li><li>Item Three</li></ul></p><p>This is the third paragraph</p></div></body></html>
Rule Structure From CSS: The Definitive Guide
Common Properties See http://htmldog.com/reference/cssproperties/ for a good list of CSS2 properties, NOT w3school. Even better: edit in Chrome!
CSS Resources Available free for students at http://proquest.safaribooksonline.com.
First Things First JavaScript is a high-level, object-oriented language used most often in web browsers. A semi-colon goes at the end of every statement. You can write comments in your code with // or /* */
Variables 29 'Bob' true Numbers Strings Boolean ['Bob', 'John', 'Coye', 'Deirdre'] Arrays {'name': 'Arnold', 'weight': 240} Objects
Variables var stateName = 'California';
Strings A sequence of characters. (Secretly an object) Use single- or double-quotes to indicate a string. Examples var myName ="Larry";myName → "Larry"myName.length → 5myName.toUpperCase() → "LARRY"myName.indexOf('a') → 1
Arrays An ordered collection of elements. Use square brackets to indicate an array. Examples var myArray = ['dog', 'fish', 'cat'];myArray.length → 3myArray[0] → ['dog']myArray.push('horse') → myArray == ['dog', 'fish', 'cat', 'horse'] myArray.indexOf('fish') → 1myArray.sort() → ['cat', 'dog', 'fish'];
General Objects A collection of key-value pairs or named properties. Use braces to indicate an object. (Everything is an object) var person = {'name': 'Arnold', 'weight': 240, 'height': 6.2 }person.name → "Arnold"person.height → 6.2person.wife ='Maria';person.wife → 'Maria'person['wife'] → 'Maria'
Functions functionadd(x, y) {return x + y;} add(2,4) → 6 // Same result, but more "what actually happens" varadd=function(x, y) {return x + y;}
Browser functions alert('…') // Hey you confirm('…') // you sure? prompt('…') // Can I ask you something console.log('…') // Very useful!!
Control structures if (3>2) {alert('3 is greater than 2');} for (var i=0; i < myArray.length; i++) { console.log( myArray[i]);}; // 90%: if, for, while, switch, break, continue
jQuery CSS meets JavaScript +
New hotness vs.Old and Busted (But with JavaScript instead of computers)
jQuery • Selects objects from the DOM using CSS selectors. • Do something with the selected elements. Using jQuery involves two steps:
Main jQuery operations • Attributes: Changing existing elements. • Traversing: Moving from selected elements in the DOM to others. • Manipulating: Inserting or removing elements. • Events: Attaching functions to events in the browser.
Web Browser Extensions • Greasemonkey and Chrome and bears, oh my!
Extend What? • Browser chrome • Page content • Page style • Page behavior
Greasemonkey Mozilla Jetpack Firefox Extensions Chrome Extensions
Good for the Browsers GOOD FOR US
Let’s Try ithttp://code.google.com/chrome/extensions/getstarted.html
For Next Week Write your first Chrome Extension that does anything. Come with questions next class. Decide on an idea for Project 1.
HTML5 in 1 Slide Get started: http://www.alistapart.com/articles/previewofhtml5http://diveintohtml5.org DOCTYPE: <!doctype html> NEW TAGS <header> <footer> <nav> <article> <section> <aside> (But IE 6,7--even IE 8!—doesn't support styling these tags.) AUDIO/VIDEO <audio> <video> (But then the codecs need to work, sometimes ogg, sometimes mp3…) FEATURES localStorage New input types (great for mobile, see http://diveintohtml5.org/forms.html ) Modernizr http://www.modernizr.com