Archive for the ‘JavaScript’ Category

Book Review: jQuery 1.3 with PHP

Sunday, December 13th, 2009

jQuery 1.3 with PHP

jQuery 1.3 with PHP

Before I start this review proper, I need to disclose one nugget of information first: The author, Kae Verens, and I are both currently serving as members of the Irish PHP Users Group Committee and have known each other for quite a few years. If you believe I can remain impartial and objective (as I hope you do – because I am), read on:

This is the first book sent to me from Packt where I wasn’t left dizzy from trying to understand just what it is the author was trying to get across. It looks like their proof-reader was awake for this one – totally awesome.

jQuery, as the vast majority of us already know, is a JavaScript library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. In other words it does all the heavy lifting and takes care of cross-browser compatibility issues so you don’t have to and thus allows you to focus on the work that you need to do without all those distractions.

“jQuery 1.3 with PHP” is aimed “for PHP application developers who want to improve their user interfaces through jQuery’s capabilities and responsiveness”. Over the course of ten chapters Verens starts the off with an introduction, then a series of ‘Quick Tricks’ that almost immediately help you add some measure of “Web 2.0″ functionality to what I’d term a “web 0.2 application” rather sharply.
The book ends with a chapter on Optimization – some of which you are bound to already know and some which are complete gems.

In the middle are chapters with mini-projects on tabs and accordians, forms and form validation, file management, calendars (and how to make your own google-calendar-like application), image manipulation, drag and drop and data tables.
In each case, projects are analysed and the required steps for each are outlined in the simplest terms – no extraneous buzzwords are used or are the projects over-analysed for the sake of pedantry.

I was a little surprised in some places where, for example, the json encoded output was not created via json_encode; but then thought not everyone is going to have PHP 5.2 or greater installed. Thumb forward a few pages and this is mentioned. So all’s o k.

It was good to see Kae suggesting use of the PEAR Validate package (or similar) in the Forms and Forms Validation chapter (chapter 4). I had to wonder if there was a PEAR package for creating and shunting down jQuery validation rules to the client – and found that there isn’t. That’s something to consider for later on, I guess.

The rest of the book is similarly both easy to read and easy to understand – my first port of call for learning how to do something that I’d almost term exotic with jQuery and with PHP in the background is usually Google but that is going to change (actually it already has).

Honestly, I wouldn’t be surprised if this books working title was “JQuery and PHP: The HowTo” – it is that good.
Now, this book is not for learning jQuery – that is not within its remit, but I would heartily recomend “jQuery 1.3 with PHP” by Kae Verens to anyone wanting to utilise jQuery from a PHP background.

Book Review: Learning jQuery 1.3

Tuesday, June 16th, 2009

A while ago I was sent a review copy of “Learning JQuery 1.3” by Jonathan Chaffer and Karl Swedberg, as published by Packt. I’ve now had a chance to read it objectively and compare it against the original “Learning JQuery” which Packt also sent me to review about a year ago. That earlier edition covered a much less mature version (version 1.1.3.1 to be precise) of this popular Javascript framework.

Aimed at web developers and designers with a basic understanding of HTML and CSS (and some level of comfort with Javascript), the later book is thicker than the original – it weights in at some 440 pages compared to the 360 pages that were required for the first. A new chapter, “Developing Plugins” covers how to write plugins for the framework and how to “share it with the world” – naming conventions, documentation style and other advice are included. There is also a new “Quick Reference” appendix which just begs to be reproduced in “Cheat-sheet” format for pinning up on your wall. Chapters already present in the earlier book are more detailed and read better.

The subject matter is expertly covered and unless you were aware of the changes in jQuery 1.3, compared to the older version that the original was focused it would be difficult to tell which portions of the book are new – the revision and updates to the original are seamless.

Quite rightly, Swedberg and Chaffer do not explain all differences between jQuery 1.3 and its predecessors – they rightly assume that if you’re reading “Learning JQuery 1.3″ then you don’t need to be informed of exactly how jQuery 1.3 differs from the version they previous covered. The book flows better because of this and remains very easy to understand because of this approach.

There is no hint of the selector engine in 1.3 being any different than what was already covered. The language used for explaining the different concepts to the reader is more precise, especially so in the Events chapter and this makes understanding the concepts being covered much more easy – for this reason alone buying the revised edition is well worth the money.

The book doesn’t focus on new additions that were freshly added to jQuery 1.3 but also ones that had been added to jQuery since the first edition was published; JSONP, which was introduced in jQuery 1.2 is covered in the chapter on AJAX, as is the more low-level $.ajax() method; it also mentions which features have been removed from jQuery since the first edition was published – XPath being one such example. The listing of development tools has also been reworked, as has the Online Resources section. These listings mention resources that are current and up-to-date.

I remember mentioning in my review of the first book (trying hard not to use the word ‘original’ again!) that until a later edition of it was released that you wouldn’t be able to find a better book on the subject. I stand by that assertion – the only book that covers jQuery better than the first edition of “Learning jQuery” is the second edition of the same.

Andrii Nikitin’s son Needs Help – ASAP

Monday, July 14th, 2008

(Reposted from Zack Urlocker’s blog, via Vidyut Luther and planet MySQL. I don’t usually repost such things but a 2.5 year old’s health is at stake so I’m making an exception. If you use mysql at all – and even if you don’t – please dig deep.)

Andrii and his son Ivan

Andrii and his son Ivan



Andrii Nikitin, one of the MySQL support engineers located in Ukraine, has asked for help from MySQLers and so I’m sharing this information to the community at large. Andrii’s son Ivan, who is 2 1/2, is in need of a bone marrow transplant operation. This will require going to a clinic in Europe that will not be covered by regular insurance. So Andrii has asked to see if we could help raise funds. The cost is expected to be €150,000 – €250,000. A huge amount for an engineer from Ukraine to cover. But a small amount by many people could make a big difference.

Many MySQLers have kicked in to help out, but more is needed. Ivan’s health has taken a turn for the worse recently and the issue is now quite pressing. Even a small donation could mean the difference between life and death for Ivan.

I hope some of you who use MySQL or have young kids will join me in making a donation today. You can do so by using Paypal, by sending a cheque to MySQL, or via wire transfer.

Paypal:
Paypal
Or
by check payable to:

MySQL, Inc.
Mail to: MySQL, Inc.
Attn: Linda Dong
20450 Stevens Creek Blvd #350
Cupertino, CA 95014

or
US wire transfer:

MySQL Inc: 7396643001
SWIFT: NDEAUS3N

or
International wire transfer in any currency:
Bank: Nordea Bank
Bank address: Stockholm, Sweden
Bank account: 3259 17 03868
IBAN: SE27 3000 0000 0325 9170 3868
SWIFT: NDEASESS

Thanks to those who have donated already. A child’s life is precious and I hope we can give Ivan a chance.

Book Review: Learning jQuery

Saturday, July 5th, 2008

Packt sent me a copy of “Learning jQuery” by Jonathan Chaffer and Karl Swedberg. jQuery is a javascript library that I have been using on and off and was delighted to be given a chance to review this book and have a chance to read through and learn about jQuery in a less urgent manner than I had initially.

With a tag-line of “Better Interaction Design and Web Development with Simple JavaScript Techniques” and some 376 pages long (split into 10 chapters, along with three appendices) the book excels at fulfilling that promise.

From the chapter on Getting Started through selectors (css, dom, xpath), Chaffer and Swedberg examine and show how to use jQuery for animations, ajax and manipulating tables to the all important client-side form validation with disarmingly concise eloquence and skill. They also detail how to use and develop jQuery Plug-ins.

Any of the required server-side code examples, for the AJAX chapter, are in PHP but that doesn’t make the book any less relevant or more specialised towards PHP – it should be trivial to rework them for any language.

The authors use an example based approach and this works very well as they continue to progressively enhance each example with additional features and functionality – you can really see their shopping cart and image carousel examples really build up into very well formed examples of what can be done with jQuery.

If you haven’t already been turned on to jQuery by it’s excellent on-line documentation and fluent API (method chaining), this is the book that will do it.

There is one caveat though: “Learning jQuery” was written for jQuery v1.1 and published in June 2007; version 1.2 of jQuery was released four months later with some substantial changes to the API.
This doesn’t matter all that much to be honest; obviously this book doesn’t cover what’s available in v1.2 but until there’s a second edition of this book (and wouldn’t that be great?) you won’t find a better book on the subject.

Integrating JavaScript lint with vim

Sunday, March 18th, 2007

After looking for a lint program for JavaScript, I’ve found JavaScript Lint and after a few pokes around the documentation and forum, got it installed and integrated with vim.
I posted this information to the Irish PHP Users’ Group mailing list on Wednesday – thought I’d share it to a wider audience tonight.

This is how I did it, note this process now only works with the downloaded package JavaScript Lint 0.3.0:

I got, compiled and installed javascriptlint:
$ svn co https://svn.sourceforge.net/svnroot/javascriptlint/trunk javascriptlint
$ cd javascriptlint
$ make -f Makefile.ref all
$ cd Linux_All_DBG.OBJ/
$ sudo cp jsl jscpucfg /usr/local/bin/
$ #generate default config file (and edit to taste)
$ jsl -help:conf > /etc/jsl.conf

I added the following lines to the “Defining identifiers” section of jsl.conf, as JavaScript Lint
doesn’t know anything about DOM objects in web browsers.

+define window
+define document
+define alert
+define XMLHttpRequest
+define ActiveXObject
+define Image
+define parent
+define dispatchEvent
+define screen
+define navigator
+define setTimeout

I also turned on the ‘option explicit’ settingÅŸ which causes the linter to catch undeclared variables in the “Defining identifiers” section.

For integrating with vim I added these lines to my ftplugin/javascript.vim file:

set makeprg=jsl\ -nologo\ -nofilelisting\ -nosummary\ -nocontext\ -conf\ '/etc/jsl.conf'\ -process\ %
set errorformat=%f(%l):\ %m
"make F10 call make for linting etc.
inoremap <silent> <F10> <C-O>:make<CR>
map <silent> <F10> :make<CR>

fold error in javascript.vim

Saturday, March 17th, 2007

I discovered Yi Zhao’s replacement for javascript.vim which has better syntax highlighting for .js files. One slight problem though – straight after I copied it into my ~/.vim/syntax directory all my fold settings stopped working.
To fix this edit javascript.vim and change “setlocal foldlevel=6″ to “setlocal foldlevel=0″.

AJAX Security

Wednesday, April 5th, 2006

Navaho Gunleg raises some points about securing your AJAX enabled web application in his blog at darknet.

JavaScript Gotcha – Oneliners and hiding code.

Monday, April 3rd, 2006

Quick JavaScript gotcha, the following one-liner won’t work:

Password: <script language='JavaScript'> <!-- document.writeln(generatepwd()) ; --> </script>

This will, because the code itself is no longer on the same line as the ‘<!–’ or ‘–>’ tags/comment delimiters.

Password: <script language='JavaScript'>
<!--
document.writeln(generatepwd()) ;
--> </script>

Quick Reference Cards

Friday, January 16th, 2004

Found this handy collection of Quick Reference Cards through google (what else?). I already have the ViM quick reference card printed and adorning my cubicle in work. There are some very nice goodies here :)

JavaScript Link

Wednesday, November 12th, 2003

Thought I’d mention JavaScript Math FAQS” before I loose the link.
I’d recommend it to any Javascript developer.