Practical JavaScript DOM Scripting and Ajax Projects 1st Edition Frank Zammetti instant download
Practical JavaScript DOM Scripting and Ajax Projects 1st Edition Frank Zammetti instant download
https://ebookultra.com/download/practical-javascript-dom-
scripting-and-ajax-projects-1st-edition-frank-zammetti/
https://ebookultra.com/download/dom-scripting-web-design-with-
javascript-and-the-document-object-model-2nd-edition-jeremy-keith/
https://ebookultra.com/download/dom-scripting-web-design-with-
javascript-and-the-document-object-model-second-edition-jeremy-keith/
https://ebookultra.com/download/learn-javascript-and-ajax-
with-w3schools-1st-edition-w3schools/
https://ebookultra.com/download/zk-ajax-without-javascript-
framework-1st-edition-henri-chen/
JavaScript Ajax for Dummies 1. Edition Andy Harris
https://ebookultra.com/download/javascript-ajax-for-dummies-1-edition-
andy-harris/
https://ebookultra.com/download/scripting-in-java-integrating-with-
groovy-and-javascript-1st-edition-kishori-sharan/
https://ebookultra.com/download/dhtml-utopia-modern-web-design-using-
javascript-dom-1st-edition-edition-stuart-langridge/
https://ebookultra.com/download/ajax-creating-web-pages-with-
asynchronous-javascript-and-xml-1st-edition-edmond-woychowsky/
https://ebookultra.com/download/mootools-essentials-the-official-
mootools-reference-for-javascript-and-ajax-development-1st-edition-
aaron-newton/
Practical JavaScript DOM Scripting and Ajax Projects
1st Edition Frank Zammetti Digital Instant Download
Author(s): Frank Zammetti
ISBN(s): 9781590598160, 1590598164
Edition: 1
File Details: PDF, 6.20 MB
Year: 2007
Language: english
Practical JavaScript™,
DOM Scripting, and
Ajax Projects
■■■
Frank W. Zammetti
Practical JavaScript™, DOM Scripting, and Ajax Projects
Copyright © 2007 by Frank W. Zammetti
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means,
electronic or mechanical, including photocopying, recording, or by any information storage or retrieval
system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-59059-816-0
ISBN-10 (pbk): 1-59059-816-4
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every occurrence
of a trademarked name, we use the names only in an editorial fashion and to the benefit of the trademark
owner, with no intention of infringement of the trademark.
Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc., in the
United States and other countries. Apress, Inc., is not affiliated with Sun Microsystems, Inc., and this book
was written without endorsement from Sun Microsystems, Inc.
Lead Editor: Matthew Moodie
Technical Reviewer: Herman van Rosmalen
Editorial Board: Steve Anglin, Ewan Buckingham, Gary Cornell, Jason Gilmore, Jonathan Gennick,
Jonathan Hassell, James Huddleston, Chris Mills, Matthew Moodie, Jeff Pepper, Paul Sarknas, Dominic
Shakeshaft, Jim Sumser, Matt Wade
Project Manager: Tracy Brown Collins
Copy Edit Manager: Nicole Flores
Copy Editor: Marilyn Smith
Assistant Production Director: Kari Brooks-Copony
Production Editor: Laura Esterman
Compositor: Susan Glinert
Proofreaders: Lori Bring and April Eddy
Indexer: Broccoli Information Management
Cover Designer: Kurt Krames
Manufacturing Director: Tom Debolski
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th Floor,
New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail orders-ny@springer-sbm.com, or
visit http://www.springeronline.com.
For information on translations, please contact Apress directly at 2560 Ninth Street, Suite 219, Berkeley, CA
94710. Phone 510-549-5930, fax 510-549-5939, e-mail info@apress.com, or visit http://www.apress.com.
The information in this book is distributed on an “as is” basis, without warranty. Although every precaution
has been taken in the preparation of this work, neither the author(s) nor Apress shall have any liability to
any person or entity with respect to any loss or damage caused or alleged to be caused directly or indirectly
by the information contained in this work.
The source code for this book is available to readers at http://www.apress.com in the Source Code/Download
section.
Dedicated to all the animals I’ve eaten over the years, without whom I
most certainly would have died a long time ago due to starvation. Well, I suppose
I could have been a vegan, but then I’d have to dedicate this to all the plants
I’ve eaten, and that would just be silly because very few plants can read.
To all my childhood friends who provided me with cool stories to tell: Joe, Thad,
Meenie, Kenny, Franny, Tubby, Stubby, Kenway, JD, dVoot, Corey, and Francine.
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
v
Contents
vii
viii ■C O N T E N T S
■INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 525
About the Author
■FRANK W. ZAMMETTI is a web architect specialist for a leading worldwide financial company by
day, and a PocketPC and open source developer by night. He is the founder and chief software
architect of Omnytex Technologies, a PocketPC development house.
Frank has more than 13 years of “professional” experience in the IT field, and over 12 more
of “amateur” experience. He began his nearly lifelong love of computers at age 7, when he became
one of four students chosen to take part in the school district’s pilot computer program. A year
later, he was the only participant left! The first computer Frank owned was a Timex Sinclair 1000,
in 1982, on which he wrote a program to look up movie times for all of Long Island (and without
the 16kb expansion module!). After that, he moved on to an Atari computer, and then a
Commodore 64, where he spent about four years doing nothing but assembly programming
(games mostly). He finally got his first IBM-compatible PC in 1987, and began learning the finer
points of programming (as they existed at that time!).
Frank has primarily developed web-based applications for about eight years. Before that,
he developed Windows-based client/server applications in a variety of languages. Frank holds
numerous certifications, including SCJP, MCSD, CNA, i-Net+, A+, CIW Associate, MCP, and
numerous BrainBench certifications. He is a contributor to a number of open source projects,
including DataVision, Struts, PocketFrog, and Jakarta Commons. In addition, Frank has started
two projects: Java Web Parts and The Struts Web Services Enablement Project. He also was one
of the founding members of a project that created the first fully functioning Commodore 64
emulator for PocketPC devices (PocketHobbit).
Frank has authored various articles on topics that range from integrating DataVision into
web applications to using Ajax in Struts-based applications, as well as a book on Ajax for Apress.
He is currently working on a new application framework specifically geared to creating next-
generation web applications.
Frank lives in the United States with his wife Traci, his two kids Andrew and Ashley, and his
dog Belle. And an assortment of voices in his head, but the pills are supposed to stop that.
xv
About the Technical Reviewer
■HERMAN VAN ROSMALEN works as a developer/software architect for De Nederlandsche Bank N.V.,
the central bank of the Netherlands. He has more than 20 years of experience in developing
software applications in a variety of programming languages. Herman has been involved in
building mainframe, PC, and client/server applications. For the past six years, however, he has
been involved mainly in building J2EE web-based applications. After working with Struts
(pre-1.0) for years, he got interested in Ajax and joined the Java Web Parts open source project
in 2005.
Herman lives in a small town, Pijnacker, in the Netherlands, with his wife Liesbeth and
their children, Barbara, Leonie, and Ramon.
xvii
About the Illustrator
■ANTHONY VOLPE did the illustrations for this book and the K&G Arcade game. He has worked on
several video games with author Frank Zammetti, including Invasion Trivia!, Io Lander, and
Ajax Warrior. Anthony lives in Collegeville, Pennsylvania, and works as a graphic designer and
front-end web developer. His hobbies include recording music, writing fiction, making video
games, and going to karaoke bars to make a spectacle of himself.
xix
Random documents with unrelated
content Scribd suggests to you:
IV. The Money in this Office is not intended for business
purposes—by no means—it is solely to lend. Please
note this.
V. A Supply of Cash is always provided to Cash Cheques for
all comers, and relieve Bank Clerks of their legitimate
duties. Stamped cheque forms given gratis.
VI. Talk loud and whistle, especially when we are engaged;
if this has not the desired effect, sing.
VII. The Clerks receive visits from their friends and their
relatives; please don’t interrupt them with business
matters when so engaged.
VIII. Gentlemen will please examine our letters, and jot
down the Names and Addresses of our Customers,
particularly if they are in the same profession.
IX. As we are always glad to see old friends, it will be
particularly refreshing to receive visits and renewal of
orders from any former Customer who has passed
through the Bankruptcy Court, and paid us not more
than Sixpence in the Pound. A Warm welcome may be
relied on.
X. Having no occupation for our Office Boy, he is entirely at
the service of callers.
XI. Our Telephone is always at the disposal of anyone
desirous of using it.
XII. The following are kept at this Office for Public
Convenience:—
A Stock of Umbrellas (silk), all the Local Newspapers,
Railway Time Tables, and other Guides and Directories;
also a supply of Note Paper, Envelopes, and Stamps.
XIII. Should you find our principals engaged, do not hesitate
to interrupt them. No business can possibly be of
greater importance than yours.
XIV. If you have the opportunity of overhearing any
conversation, do not hesitate to listen. You may gain
information which may be useful in the event of
disputes arising.
XV. In case you wish to inspect our premises, kindly do so
during wet weather, and carry your umbrella with you.
We admire the effect on the floor; it gives an air of
comfort to the establishment. (The Umbrella Stand is
only for ornament, and on no account to be used).
P.S.—Our hours for listening to Commercial Travellers, Beggars,
Hawkers, and Advertising Men are all day. We attend to our Business
at Night only.
Does the top of a carriage wheel move faster than the bottom?
This question seems absurd. That the top moves faster, however, is
perfectly correct; for if not it would simply move round in the same
place: in a wheel on a fixed axle the bottom moves backward as fast
as the top moves forward; but in a wheel that is going forward,
drawn by a progressive axle, the bottom does not go back at all, but
remains almost stationary until it is its turn to rise and go forward.
37. A General, arranging his army in a solid square, finds he has
284 men to spare, but on increasing the sides of the square by one
man, he wants 25 men to complete the square. How many men has
he?
“STEWING.”
38. A student reads two lines more of “Virgil” each day than he
did the day before, and finds that, having read a certain quantity in
18 days, he will read at this rate the same quantity in the next 14
days. How much will he read in the whole time?
39. Two bootmakers who lived in the town of B., thrown out of
employment, resolved to go to G., a town 24 miles north from B.,
where there is a large factory; one of them went straight on to G.,
but the other went first to C., a small township west of B., and then
went direct to G., his whole journey being 45 miles. What is the
distance from C. to G.?
40. A tree which grows each year 1 inch less than the previous
year, grew a yard in the first year; the value of the tree at any time
is equal to the number of pence in the cube of the number of yards
of its height. What is the value of the tree when done growing?
MAGIC SQUARES.
A Magic Square is a series of figures arranged in the equal
divisions of a square in such a manner that the figures in each row
when added up, whether horizontally, vertically, or diagonally, form
exactly the same sum.
They have been called
“Magic” because the ancients
ascribed to them great virtues,
and because this arrangement
of numbers formed the basis
and principle of their talismans.
Archimedes devoted a great
amount of attention to them,
which has caused a great many
to speak of them as “the
squares of Archimedes.” They
may be either odd or even.
When the former, the following
method will be found valuable:—
With the digits from 1 to 25 form a square so that the numbers
when added up horizontally, vertically, or diagonally will amount to
65.
Method.—Imagine an exterior line of squares above the magic
square you wish to form, and another on the right hand of it. These
two imaginary lines are shown in the diagram.
1st. In placing the numbers in the square, we must go in the
ascending diagonal direction from left to right, any number which,
by pursuing this direction, would fall into the exterior line must be
carried along that line of squares, whether vertical or horizontal, to
the last square. Thus, 1 having been placed in the centre of the top
row, 2 would fall into the exterior square above the fourth vertical
line; then ascending diagonally 3 falls into the square diagonally
from 2, but 4 falls out of it to the end of a horizontal line, and it
must be carried along that line to the extreme left and there placed.
Resuming our diagonal ascension to the right we place 5 where the
reader sees it, and would place 6 in the middle of the top row, but
as we find 1 is already there we look for the direction to
2nd. That when in ascending diagonally we come to a square
already occupied, we must place the number which, according to the
1st rule should go into that occupied square directly under the last
number placed: thus, in ascending with 4, 5, 6, the 6 must be placed
under the 5, because the square next to 5 in diagonal direction is
occupied.
A Promising Sign—I O U.
44.
45. A man sold a horse for £35 and half as much as he gave for
it, and gained thereby 10 guineas. What did he pay for the horse?
48. If a goose weighs 10 lbs. and a half of its own weight, what
is the weight of the goose?
5 × 13 = 65 square inches.
49. If we buy 20 sheep for 20 shillings, and give 2s. for wethers,
1s. 6d. for ewes, and 4d. for lambs, how many of each must we
buy?
50. A sets out from a place and travels 5 miles an hour. B sets
out 4½ hours after A and travels in the same direction 3 miles in the
first hour, 3½ miles the second hour, 4 miles the third hour, and so
on. In how many hours will B overtake A?
OFTEN ASKED.
51. What is the difference between 4 square miles and 4 miles
square?
PANCAKE DAY.
53. On Shrove Tuesday last, I’ll tell you what
pass’d
In a neighbouring gentleman’s kitchen,
Where pancakes were making, with eggs, and with
bacon
As good as e’er cut off a flitchen.
The cook-maid she makes four lusty pancakes
For William her favourite gardener,
“Pray be quick with that four,” cries Jack, “and make
more,
For William won’t let me go partner.”
Being sparing of lard, the pan’s bottom she marr’d
In making the last of Will’s four;
So she said, “Pr’ythee, John, run and borrow a pan,
Or else I can’t make any more.”
Jack soon got a pan, but found by his span
That the first was more wide than the latter,
This being a foot o’er, whereas that before
Was three inches more and a quarter.
Jack cries, “Don’t me cozen, but make half a dozen.
For the pan is much less than before;”
Says Will, “For a crown (and I’ll put the cash down)
Your six will be more than my four.”
“Tis done,” says brisk Jack, and his crown he did
stake,
So both of them sent for a gauger;
The dimensions he takes, of all their pancakes,
To determine this important wager.
He found, by his stick, they were equally thick,
So one of Will’s cakes he did take,
Which he straight cut in twain, twelve one-fifth[1]
the chord line;
And gave the less piece unto Jack.
“To the best of my skill,” says the gauger, “this will
Make both of your shares equal and true;”
Will swore that he lied, so, the point to decide,
Will swore that he lied, so, the point to decide,
They refer themselves, sirs, unto you;
Then pray give your answers, as soon as you can,
sirs,
For what with their quarrels and jars,
We’re afraid of some murder, for no day goes over
But they fight, and are cover’d with scars!
[1] Inches.
There has been a superstitious notion that Fools’ Day dated back
to the time of Noah’s Ark. The dove that was sent forth from the Ark
is supposed to have returned on April 1st.
All Fools’ Day had it’s origin in France, before the time of the
Reformed Calendar. When the year commenced on March 25th, the
French frequently paid their New Year’s visits and bestowed their
gifts on April 1st, as March 25th occurred in Passion Week. After the
adoption of the new calendar, however, these New Year’s
observances took place on January 1st, and it was a common thing
for people to forget the change of date. Pretended presents and
mock ceremonial visits became common, and the persons thus
imposed on were known as April fish, i.e., a mackerel, which, like a
fool, is easily caught. Hence, All Fools’ Day.
PRACTICAL ILLUSTRATION.
In one of our great public schools a
master known to successive generations of
his pupils for fifty years as “old Buggus”
delighted in surprising his boys with strange
sayings and doings. On one occasion,
desirous of illustrating a question in the
arithmetic lesson, he said to a boy, “I am a
tripe merchant, and this platform is my
shop. You will come here and buy a pound
of tripe. Now, begin.”
“Please, I want a pound of tripe,” said a boy, sauntering up.
“Where’s your money?” demanded old Buggus, hoping to put the
boy out of countenance.
“Where’s your tripe?” was the ready retort; but it gained for its
unfortunate author four hours’ detention on the next holiday.
PROFITABLE CARELESSNESS.
A very amusing story is told of a harness-maker who lived some
years ago in London. He had a handsome saddle in his shop,
occupying a conspicuous position therein. On his return from
luncheon one day he observed that the saddle was gone. Calling to
his foreman, he said:
“John, who has bought the saddle?”
“I’m sure I don’t know, sir,” said the foreman, scratching his head
as if he were trying to think. “I cannot tell, and the worst part of it
is, it hasn’t been paid for. While I was at work in the back of the
shop a gentleman came in, priced it, decided to take it, told me to
charge it, and throwing it into his trap, drove off, before I could think
to ask his name.”
“That was very stupid of you,” said the harness-maker, disposed
to be angry at the man’s carelessness. “Very likely we have been
robbed.”
“I don’t think that sir,” said the foreman, “for I’m very sure that
the gentleman has traded here before.”
“Well, I can’t afford to lose the money,” said the harness-maker.
“We’ll have to find out who took it and send him the bill. Ah!” he
added, with a smile, after a moment’s reflection, “I have it. We’ll
charge it up to the account of every one of our customers who keep
open accounts here. Those who didn’t get it will refuse to pay, so we
shall be all right.”
“The book-keeper was instructed to do this, and the bills in due
course of time went out. Some weeks later the harness-maker asked
the book-keeper if he had succeeded in discovering who the
customer was.
“No, sir,” he replied, “and we never shall, I fear, sir, for about 40
people have paid for it already without saying a word.”
A CYCLE CATCH.
Tie a cord to the pedal of a bicycle, such
pedal to be the one that is the nearer to the
ground, and, standing behind the back
wheel, pull the cord, when, strange as it
appears, the machine will come towards
you, although everyone would first imagine
that the bicycle would move forward. How
is this?
One ought to have dates at one’s finger ends seeing they grow
upon the palms.
BOOK-KEEPING COMMANDMENTS.
By Ledger laws, what I receive Is Debtor made to those who
give. Stock for my debts must Debtor be, and Creditor by Property.
Profit and Loss accounts are plain, I Debit loss and Credit gain.
57. How far does a man walk while planting a field of corn 285
feet square, the rows being 3 ft apart from the fence?
A MATTER OF OPINION.
A man walks round a pole on the top of which is a monkey. As
the man moves, the monkey turns on the top of the pole, so as still
to keep face to face with the man. Now, when the man has gone
round the pole, has he or has he not gone round the monkey?
TRY IT.
Take the number 15, multiply it by itself, and you
have 225; now multiply 225 by itself, then multiply that
product by itself, and so on until 15 products have
been multiplied by themselves in turn. The final
product called for contains 38,539 figures (the first of
which is 1412). Allowing three figures to an inch, the
answer would be over 1070 feet long. To perform the
operation would require about 50,000,000 figures. If
they can be made at the rate of 100 a minute, a person working 10
hours a day for 300 days in each year would be 28 years on the job.
PATHETIC ADVERTISING.
“Died, on the 11th ultimo., at his shop in Fleet-street, Mr. Edward
Jones much regretted by all who knew and dealt with him. As a
man, he was amiable; as a hatter, upright and moderate. His virtues
were beyond all price, and his beaver hats were only £1 4s each. He
has left a widow to deplore his loss, and a large stock to be sold
cheap for the benefit of his family. He was snatched to the other
world in the prime of life, and just as he had concluded an extensive
purchase of felt, which he got so cheap that the widow can supply
hats at a more moderate charge than any house in London. His
disconsolate family will carry on his business with punctuality.”
A CRICKET “CATCH.”
61. In an eleven, when the ninth batsman
goes in, how many wickets have to fall before all
are out?
62. A boat’s crew can row eight miles an hour in still water; what
is the speed of a river’s current if it takes them 2 hours and 40
minutes to row 8 miles up and 8 miles down?
BAD WRITING.
In a well-known firm in Sydney the clerks are presided over by a
rather impetuous manager, whose violent fits of temper very often
dominate his reason. For instance, the other day he was wiring into
one of them about his bad work.
“Look here, Jones,” he thundered, “this won’t do. These figures
are a perfect disgrace to a clerk! I could get an office boy to make
better figures than those, and I tell you I won’t have it! Now, look at
that five, it looks just like a three. What do you mean, sir, by making
such beastly figures? Explain!”
“I—er beg your pardon, sir,” suggested the trembling clerk, his
heart fluttering terribly, “but—er well, you see, sir, it is three.”
“A three?” roared the manager; “why, it looks just like a five!”
EDUCATIONAL VAGARIES.
Extracts from Reports of Country Provisional Schools.
School No. 1: On roll, 1 boy, 1 girl; total, 2. Average
attendance, 0·6 boy, 0·6 girl; total, 1·2.
School No. 2: On roll, 2 boys, 2 girls; total 4. Average
attendance, 1·6 boys, 1·3 girls; total, 2·9.
School No. 3: On roll, 2 boys, no girls. Average
attendance, 0·8 boys.
By the above we see the public are paying for a teacher to
provide education for eight-tenths of a boy!
65.
Three-fourths of a cross, and a circle complete,
Two semi-circles at a perpendicular meet;
Next add a triangle which stands on two feet,
Two semi-circles and a circle complete.
A DISPUTE.
66. Two men have an equal interest in a
grindstone, which is 5 ft. 6 in. in diameter. The
centre of the stone, to the extent of a diameter
of 18 in., is useless, and not to be taken into
account.
Required to find the depth to which the first
partner may be allowed to grind away from the
stone in order to leave an equal share of the stone to the second
partner.
RIVAL BUTCHERS.
T. Jones.—“Sausages, 3d. per lb.—to pay more is to be robbed.”
J. Smith.—“Sausages, 4d. per lb.—to pay less is to be poisoned.”
“SHE.”
68.
A country spark addressed a charming “she,”
In whom all lovely features did agree;
But being void of numbers, as doth show,
Desirous was the lady’s age to know.
“My age is such that if multiplied by three,
Two-sevenths of the product triple be:
The square root of two-ninths of that is four;—
Tell me my age or never see me more.”
RUNNING SHORT.
69. A vessel on a 3 months’ trip has provisions for 4 months, but
the stores are served out as if the voyage had to be completed in 3
months. At the end of 2 months, it is discovered that the voyage will
take 3½ months. To what proportion must the rations be reduced
for the remaining time?
A DRAUGHTS PUZZLE.
70. Ten draughtsmen are placed in a row. The puzzle is to lift one
up and passing over two at a time (neither more nor less) to place it
on the top, or to “crown” the next one, continuing in this fashion
until all are crowned. In passing over a piece already crowned, it is
to be reckoned as two pieces.
BRAIN-BEWILDERERS.
An amusing periodical got up by the boys of a certain college
gives a capital skit on the style of examination-papers frequently
presented for the torture of pupils. Here are a few examples:—
Supposing the River Murray to be three cubits in breadth—which
it isn’t—what is the average height of the Alps, stocks being at
nineteen and a-half?
If in autumn apples cost fourpence per pound in Melbourne, and
potatoes a shilling a score in spring, when will greengages be sold in
Brisbane at three-halfpence each, Sydney oranges being at a
discount of five per cent.?
If two men can kill twelve kangaroos in going up the right side of
a rectangular turnip-field, how many would be killed by five men and
a terrier pup in going down the other side?
If a milkmaid four feet ten inches in height, while sitting on a
three-legged stool, took four pints of milk out of every fifteen cows,
what was the size of the field in which the animals grazed, and what
was the girl’s name, age, and the occupation of her grandfather?
If thirty thousand millions of human beings have lived since the
beginning of the world, how many may we safely say will die before
the end of it? N.B.—This example to be worked out by simple
subtraction, algebra, and the rule of three. Compare results.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookultra.com