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
- Download Prototype 1.6.0 from http://prototypejs.org.
- Overwrite the old version of
prototype.jsin/var/www/phpweb20/htdocs/js.
Upgrading Scriptaculous
- Download Scriptaculous 1.8.0 from http://script.aculo.us/dist/scriptaculous-js-1.8.0.zip
- 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
markersclass property is used, primary in theaddMarkerToMap()method. - Updated the
hasMarker()method
You can download the new version of the file using the following link: