A form for lecture feedback is available from the course web site. Please take two minutes to fill it out after you have seen the lecture.
March 31, 2010
Harvard University
Extension School
Course Web Site: http://cscie12.dce.harvard.edu/
Instructor email:
david_heitmeyer@harvard.edu
Course staff email:
cscie12@dce.harvard.edu
Image created at wordle.net
|
|
Structure + Style + Function: solarsystem.html Structure + Style: solarsystem-style.html Structure: solarsystem-markup.html |
And do the same for the other three seasons to get:
Example: Building a list with jQuery
Example 2: Building a list with jQuery
jQuery Form Validation Plugin makes validating forms easy and flexible.
jquery.validation.js plugin in a basic way.
Rules are quite customizable and can be expressed in JavaScript sections and not in the code markup.
Comments and unnecessary whitespace are removed.
Some tools you can use to minify your JS:
Google and Microsoft host several JS libraries through their CDNs.
Details for using jQuery from a CDN
Two options:
google.load() JS method
See: 3 reasons why you should let Google host jQuery for you
AJAX: A New Approach to Web Applications, from Adaptive Path. by Jesse James Garrett
Terms:
Technologies Involved:
Example: Ajax, HTML, and jQuery
Data (HTML) format
Example: Ajax, JSON, and jQuery
Data (JSON) format
{ "seasons" : [
"Spring",
"Summer",
"Autumn",
"Winter"
]
}
Example: Ajax, HTML, and jQuery
Data (XML) format
http://cscie12.dce.harvard.edu/ajax/course_jquery.html
There is a URL that returns a list of courses given a course group (as an XHTML snippet):
What's involved:
courselist_partial which take a course_group query parameter)getCourseList) to call server-side processgetCourseList function.Import jQuery
jQuery function:
Form:
Ajax parts (produce HTML snippets):
Markup:
JS:
Instead of returning HTML to be put into the page, our server-side process will return JSON (JavaScript Object Notation). We can then process the JSON data into the page.
JSON data example:
And the JS to process it:
Return XML data:
And the JS changes slightly to process XML instead of JSON:
Course Search by Department and Instructor
Designed for XHTML (fragment), XML, and JSON output.
document "ready" callback function loads instructor options and also searches for courses.
Before you build your own...
Select a random number from an array (list):
imglist[Math.floor(Math.random()*imglist.length)
imglist.length = length of the arrayMath.random() = random number between 0 and 1Math.floor() = floor functionSo build it up:
imglist.length
Math.random()*imglist.length
Math.random()*imglist.length
Math.floor(Math.random()*imglist.length)
imglist[Math.floor(Math.random()*imglist.length)]
JSON data (via image_list.json):
The XHTML and script:
XML data (via images.xml):
The XHTML and script:
You may wish to use data from third parties. You may wish to provide your data to others to use. This is where XML and JSON are extremely useful.
Yahoo! News Search provides search results in XML and JSON formats.
Security restrictions put limitations on cross-domain JSON requests.
JS
Markup
Working Example: Yahoo News and JSON
The Yahoo! User Interface (YUI) Library is a set of utilities and controls, written in JavaScript, for building richly interactive web applications using techniques such as DOM scripting, DHTML and AJAX. The YUI Library also includes several core CSS resources. All components in the YUI Library have been released as open source under a BSD license and are free for all uses.
Yahoo! User Interface Library (YUI) is used in this example. YUI DataTable is used to create a table from XML data, which is retrieved with a YUI DataSource
Load YUI Libraries
Define DataSource and DataTable
Ext JS is a cross-browser JavaScript library for building rich internet applications.
Load Ext JS Libraries
Define DataSource and DataTable
RSS and Atom are lightweight XML formats for sharing headlines and other Web content.
The heart of an RSS feed is an "item", which can have a title, link, and description.
Item from BBC News:
Atom feed displayed in Firefox:
Firefox "Live Bookmarks" alert you to the existence of an RSS feed for a site and allow convenient access to the items in the feed.
Adapting and extending RSS for use with iTunes, iPods, and other mobile media players.
Podcast snippet ( WBUR/NPR On Point with Tom Ashbrook Podcast ):
Yahoo! Maps and RSS with GeoInfo
Javascript Application that uses Ajax to pull in map marker data.
Place "markers" and information on maps via XML data.
Markup:
Data (ivy.xml)
JS to process Data
Google Maps API can consume a KML file.
Note that the URL of the KML file needs to absolute!
Data: hot_chocolate.kml
Page:
Google Maps can consume a Geo-tagged RSS file.
Note that the URL of the RSS file needs to absolute!
Data:
Page:
The SIMILE project from MIT has some excellent examples of JS applications
Exhibit: Sites Using Web Standards
Provide the data and the template, and Exhibit provides the functionality: different views, timeline according to birth date, filtering, sorting, and grouping.
Tiles View
Table View (columns are sortable)
Thumbnails View (Filters applied: California, Democrat)
Timeline View
Visible are those with birthdays in 1969-1972. Timeline is scrollable.
Congress data used with permission from GovTrack.US.
Comments on Boston.com (Pluck):
Comments on thecrimson.com (Disqus):
|
Webkinz Video Charts |
MLB Gameday
ESPN Gamecast Flash Earth |
Mechanisms
embed elementobject elementobject and/or embed
Issues
See: "Flash Embedding Cage Match" on "A List Apart."
Use JavaScript build the appropriate markup
SWFObject is an easy-to-use and standards-friendly method to embed Flash content, which utilizes one small JavaScript file.
embedSWF function
Files involved:
The JW Player is a widely-used Flash player for video.
The JW Player is a widely-used Flash player for video.
Quick Demo of Firebug Screencast
<applet />
UC Irvine Chemistry Educational Applets
Chemical Kinetics Simulation