Datasheet

Why is it important that your web application displays well in a text web browser since almost nobody
uses one any longer? It’s important, because voice systems used by blind people see your web page and
transcribe it orally in a way that is very similar to what a text browser displays. If you’re not convinced
by this argument, you may find it more convincing to know that the search engine web crawlers see
your document approximately the same way as text browsers. Wouldn’t you like it if the watch page for
Microsoft was in the top search results for Microsoft on major search engines? You can be sure that this
won’t be the case for the current version of BuzzWatch.
The issue of serving web pages and web applications that can be used by a wide audience, including
vision-impaired people using voice devices or Braille readers, users browsing the Web from small
devices, web crawlers, and even the small number of geeks browsing the Web with Lynx is known as
web accessibility. Chapter 4 has more on web accessibility.
How can you update BuzzWatch so that it behaves like a good web citizen and keeps the look and feel
and reactivity that makes it a real Web 2.0 application? Fortunately, the answer to this question is, at
least in its principle, quite easy. Since you want one URL per watch, you should accept that users reload
their pages to change URLs when they switch between watches. And since you want BuzzWatch to
degrade nicely and display significant information even in browsers that do not support JavaScript,
BuzzWatch pages should come populated with their content when they load, even if partial refreshes are
operational later on for JavaScript-enabled browsers. In other words, BuzzWatch should be a Web 1.0
application with Web 2.0 features for users that have JavaScript available.
If you have installed BuzzWatch to try these examples by yourself, it’s time to install version 2.0.
To implement these changes, you’ll have to replace the static HTML document that the first version of
BuzzWatch served with a PHP script that generates pages where the information is already pre-populated
in the different panels. The classical way of doing so in PHP is to embed PHP statements in an HTML
document. However, since BuzzWatch has already implemented methods in JavaScript that create this
content client side by manipulating the DOM, you may prefer to port the same methods in PHP. In that
case, your script loads the same HTML document that was sent to the browser up to now in a DOM,
update this DOM to add the information that is needed in the panels, and send the serialization of this
DOM to the browser. Client side, the scripts need to be updated so that they do not immediately refresh
the panels’ content (that would be a waste of bandwidth), but start a timeout instead and refresh the
panels after this timeout.
The
index.php script does quite a few tasks that are similar to those done by the scripts sending the
XML for the different panels, and some refactoring is welcome to define these common actions as func-
tions. The body of the script is:
// Open the database and fetch the current
// watch if needed.
$db=openDb();
$query = queryOneWatch($db);
$watchRow = $query->fetch(SQLITE_ASSOC);
// Create a DOM and load the document
$document = new DOMDocument();
$document->validateOnParse = TRUE;
$document->load(“template.html”);
// Populate the menu bar and the panels
populateMenuGo($db);
populateForms($watchRow);
populateQuotes($watchRow);
26
Chapter 1
04_087889 ch01.qxp 5/2/07 12:56 PM Page 26