29 Jun

jQuery 1.3 With PHP: Calendars

I was supposed to write about Datatables for chapter 6 of jQuery 1.3 with PHP, but the website of the plugin I was going to use (http://www.datatables.net/) was down for about a week, and so I wrote about Calendars instead.

I used Red3‘s jquery-week-calendar plugin for a recent project in work, and was so impressed I really had to write about it.

In chapter 6 of the book, I’ll walk through how to build a simple calendar, including creation and editing of events, and including once-off and recurring events.

demo

The demo is a session-based calendar, which records only for the duration of your browser session. It’s for demo purposes only, obviously. If you want to use it in a larger project, you would need to adapt the PHP so that it records to a database or files or something.

Download

Here’s an image of it in use:

fig_6_0

Only four or so chapters left and then I’m done with the hard part. After that, is rewrites, then you can all throw your money at me.

21 May

jQuery 1.3 With PHP: tiny file manager

For chapter 5 of my book, jQuery 1.3 with PHP, I wrote a small file manager. It doubles up as a file selector.

demo

You would use this in an admin area where it is necessary to select files or directories, and you’d also like to create/rename/move those things around.

fig_5_10

Try a few things on it – change the selection in the two select-boxes, move a few things around, etc. I think it’s useful and nicely compact.

You can download it here along with the examples that lead up to the finished thing. You will also need a copy of jQuery and uploadify.

To install, just link to your copies of the above libraries, correct the $base variable in the .php file, and in the .js file, change ../jquery.uploadify-v1.6.2/ (in the fm_uploadFileSetup function) to wherever you installed it.

$base should point somewhere outside of the web root, as the file manager does not discriminate between innocent files such as test.txt and potentially harmful files such as hackme.php. A downloader is included which allows any files uploaded through this to also be downloaded through it.

05 May

jQuery 1.3 With PHP: chapter 4

Chapter 4 (of my book jQuery 1.3 with PHP for Packt) was on form validation. I put up the demos in the usual place.

Of particular interest is this one. It has a number of points, including two that I haven’t seen anywhere else yet.

  • remote checking of email addresses against the server database (kae@verens.com is registered, for example).
  • the Country drop-down is a new trick which I’ll explain in a moment.
  • the City field acts as an auto-suggest based on what’s selected in Country (select Ireland and type a letter in there).
  • the form itself does not have an action parameter. that’s the second trick.

Optimising Large Select-boxes

In the example, I’ve only mentioned a few countries, but in reality, you’d use the full list. If you look at the source of the form, you’ll see that actually, only Ireland is mentioned. This is because it does not make sense to always print tens of KB of HTML if most of it will not be used – what if the form is for an irish company and it is not expected that the country would /need/ to change?

The solution is to only load the country list if the select-box is clicked.

This also applies to other large select-boxes. I’ll be using this trick in-house for forms that always slow down when they’re rendering select-boxes – especially db-sourced select-boxes.

Action-less Forms

This is an attempt to get away from captchas, which are getting increasingly difficult for humans to solve, and easier for computers.

The idea is that the form is rendered with no action parameter, and then jQuery retrieves the needed parameter via AJAX 1.5 seconds later. The server records the time the form was rendered, and if the jQuery request comes in before 1.5 seconds, then it’s a spam-bot and will not be allowed to post. If the form is submitted in less than 10 seconds, or greater than 10 minutes, or if it’s submitted without loading the form and action in the first place, then it’s a spam bot and will not be allowed to post.

I’m pretty confident this will slow down spam a bit. It can’t possibly /solve/ it, but it will make it more difficult for spam-bots, yet humans will not notice anything out-of-the-ordinary at all.

The source is of course available.

17 Apr

update on Me

Quick update of what’s happening in the world of Kae.

I’ve been busy recently with a new project in the office, making an ultra-WebME system which can be used by companies who are not web designers, to offer their clients “pre-packaged” websites. I may elaborate on that in a few weeks once the pilot study is out of the way.

I haven’t touched the KFM file manager project in ages, and recently realised that it’s because I’m just not happy with it anymore. It’s monstrously complex now, and just not flexible enough for the changes I want to build into it. So, I’m seriously thinking of rewriting it completely, or building a new file manager project to compete with it.

WebME is progressing quickly. The plugins architecture is damned easy to use, if I do say so myself. So much so that Conor wrote a mailing-list plugin before I even got to announce the plugin system. To try it out, get the Subversion copy of WebME, and also the subversion copy of the existing plugins (svn checkout http://webworks-webme.googlecode.com/svn/ww.plugins/) and create a symbolic link from ‘ww.plugins’ in the root of your WebME installation to the checked-out ww.plugins directory. Then in the /ww.admin section, go to Site Options > Plugins and try some stuff. I’ll be writing a proper tutorial on how to create a plugin. Probably today.

I started learning piano at the beginning of last month and am proud to say that I appear to be learning at a prodigious rate. This is probably because I can already play well on a number of other instruments. Last tune I learned was Ecossaise in E Flat by Beethoven (WoO 86), played here by Matt Baker:

Before that was I’ll Take You Home Kathleen, played here by Dave Seddon on steel guitar (couldn’t find a piano version that wasn’t ruined by people singing over the music 😉 ):

I’m still in quite a lot of pain since last week’s operation, but hopefully it will ease off over the weekend, as I have the next chapter of my book to submit.

28 Mar

jQuery 1.3 With PHP: quick tricks

As mentioned before, I’m writing a book for Packt Publishing called jQuery 1.3 with PHP.

I think I’m just about done with the first chapter I’ll be submitting, tentatively entitled Quick Tricks.

The book will include full explanations of how they work, but here are the examples.

In the last two examples, the demo is designed to show what happens in a failed save or delete as well as in a successful one.

Source is, of course, available.