Updgrading Prototype and Scriptaculous

Shortly after Practical Web 2.0 Applications with PHP was printed, an updated version of Prototype was released. This article describes how to update the code we develop in the book to use Prototype 1.6.0.

When you upgrade Prototype, you must also use the corresponding version of Scriptaculous. Therefore if you use Prototype 1.6.0, you must also then use Scriptaculous 1.8.0.

Note: Prototype 1.6.0 also provides different ways to declare classes and other various changes, however much of the old code will still work. In this article I won't describe all of the changes you can make to the code. Rather, I only describe what is required to ensure all existing JavaScript code will still work.

Upgrading Prototype

  1. Download Prototype 1.6.0 from http://prototypejs.org.
  2. Overwrite the old version of prototype.js in /var/www/phpweb20/htdocs/js.

Upgrading Scriptaculous

  1. Download Scriptaculous 1.8.0 from http://script.aculo.us/dist/scriptaculous-js-1.8.0.zip
  2. Overwrite old files in /var/www/phpweb20/htdocs/js/scriptaculous.

If you are using Linux, you can use the following commands:

# cd /var/www/phpweb20/htdocs/js
# rm -r scriptaculous
# wget http://script.aculo.us/dist/scriptaculous-js-1.8.0.zip
# unzip scriptaculous-js-1.8.0.zip
# mv scriptaculous-js-1.8.0/src scriptaculous
# rm -r scriptaculous-js-1.8.0

Code Updates

The main change to be aware of in Prototype 1.6.0 is the way that the Hash object is treated. Basically, we now need to use get(), set() and unset() methods, rather than accessing hash elements directly.

This only affects the BlogLocationsManager.class.js file, which is located in the /var/www/phpweb20/htdocs/js directory. Rather than describe each individual change, I've simply included the file for download.

The key changes are as follows:

  • Changing the way the markers class property is used, primary in the addMarkerToMap() method.
  • Updated the hasMarker() method

You can download the new version of the file using the following link:

Dear Reader,

Many programming books on the market today focus specifically on a particular methodology or software package, and although you will gain a solid understanding of the subject matter from these books, you won't always know how to apply what you've learned in a real-world situation. This book is designed to show you how to bring together many different ideas and features by starting with a clean slate and gradually building the code base so it evolves into a complete web application.