CS142 Project #6: Javascript and Events

Problem 1: Javascript Calendar (20 points)

Create a new directory project6 with a subdirectory p1 that will contain the solution for this problem. Within that subdirectory, create a file Calendar.js that implements a Javascript class named Calendar that can be used as in the following example:

var calendar = new Calendar("div1");
calendar.render(new Date("July 4, 1776"));

The constructor takes a single argument consisting of the id attribute for a div, and the render method takes one argument consisting of a Date object that selects a particular month (the object can refer to any time within the month). When render is invoked it replaces the contents of the calendar's div with HTML that displays a small one-month calendar such as those you might see in an airline reservation Web site:

The calendar does not need to do anything if the user clicks on a particular date; all it needs to do is display one month and allow the month to be changed by clicking on the controls.

Once you have created the Javascript class, create an HTML file calendar.html that uses the Javascript class to display two different calendar divs. One of the calendars should initially display the current month and the other should display the month of January, 2009. It should be possible to change the month of each calendar independently, using the controls on that calendar.

Problem 2: Photo Tagging (40 points)

In this project you will extend your work on Project #5 by implementing a tagging mechanism that allows users to identify people in the photos of your photo-sharing Web site. Here is a rough sketch of the way this new feature should behave:

To get started, copy the directory tree for Project #5 to a new subdirectory p2 in the project6 directory. Do all of your work for this problem in the new directory.

Is up to you to choose how to implement photo tagging in your application, based on the description above. You can decide whether to use existing pages or add new ones, how to structure any forms that are needed, and so on.

However, you must implement and use a Javascript "class" named Tagger to select the photo region:

Style Points (10 points)

The most important criteria for these points are whether or not your Calendar and Tagger implementations are reusable. In addition, your Javascript must be clean (appropriate use of classes, no global variables). We will also consider the usual issues of MVC decomposition, Rails conventions, validation, overall cleanliness of your code and templates, and the appearance and convenience of your Web pages.

Additional Requirements, Hints, etc.

Deliverables

Use the standard class submission mechanism to submit the entire project6 directory. As always, your HTML files should pass XHTML validation.