[an error occurred while processing this directive]
Write the JS code to connect to a server-side JSON address book called
addressbook.php
.
Start from this HTML.
(sample solution)
(solution)
addressbook.php
with no parameters outputs an array of names:
{"names": ["Suzie", "Billy", ...]}
name
parameter outputs that person's address:
{"name": "Billy", "address": "123 4th St."}
name
and address
parameter saves that person in the address book.
Write the necessary JavaScript code to add effects and drag-and-drop behavior to a page. Start from this HTML/JS. (sample solution) (Prototype solution code) (jQuery solution code)
Use Prototype/Scriptaculous or jQuery to add the effects and drag-and-drop behavior.
Write an animated photo gallery using Scriptaculous. Start with the skeleton
HTML and
CSS. Click the image to run our sample solution:
(solution JS code gallery.js
):
Right now, when you double-click an image, it shows in the large
mainimage
area. But it's boring! Add Scriptaculous effects such as
the following...
mainimage
image (the first one) should scale up to 200% of its normal size, and the
mainimage
image should have a visual effect, such as shaking.
mainimage
image should shake as it changes. Also the old
selected thumbnail should shrink back to its previous size. Note that if you
double-click on the same thumbnail twice in a row, it shouldn't break.
tag
and constraint
.
mainimage
area, the large image will update. (This is the same behavior as when the
thumbnail is double-clicked. See the Scriptaculous Wiki pages about
dragging and
dropping.
mainimage
is updated,
make it have two effects in a row, such as highlighting and then shaking.
You can view the solution javascript here.
Write the PHP code to manage an address book using JSON.
You are given the HTML and JS.
The JS code sends requests to your addressbook.php
web service that reads and saves address data.
(sample solution)
(solution)
Write the PHP file, addressbook.php
, that provides the following behavior:
addressbook.php
with no parameters outputs an array of names:
{"names": ["Suzie", "Billy", ...]}
name
parameter outputs that person's address:
{"name": "Billy", "address": "123 4th St."}
name
and address
parameter saves that person in the address book.
You may assume that any necessary parameters are passed and are in valid formats.
Write a PHP web service factors-xml.php
that computes and outputs prime factorization of integers as XML.
(sample solution)
(solution code)
Provide the following behavior:
factors.php
with an n
parameter outputs the prime factors of that integer.
For example, the request factors.php?n=264
would output:
<integer value="264"> <factor>2</factor> <factor>2</factor> <factor>2</factor> <factor>3</factor> <factor>11</factor> </integer>
One algorithm for prime factorization of n
is to loop through each integer i from 2-n, and for each time n is divisible by i, add i to your list of prime factors.
n
parameter should return an HTTP error code 400 (Invalid Request) with an instructive error message.
Write a PHP web service factors-json.php
that computes and outputs prime factorization of integers as JSON.
(sample solution)
(solution code)
Provide the following behavior:
factors.php
with an n
parameter outputs the prime factors of that integer.
For example, the request factors.php?n=264
would output:
{"value": 264, "factors": [2, 2, 2, 3, 11]}
One algorithm for prime factorization of n
is to loop through each integer i from 2-n, and for each time n is divisible by i, add i to your list of prime factors.
n
parameter should return an HTTP error code 400 (Invalid Request) with an instructive error message.