Please visit my new campsite listing site ukcampingmap.co.uk


Archive for the ‘My resources’ Category

Optimize how?

Thursday, July 2nd, 2009

Yesterday and today I’ve been rewriting my jQuery crossSelect plugin (probably over half of the code has changed) to; a) Fix the serious bugs brought about by trying to bring my plugin closer in line with how it’s supposed to be done, without fully understanding the implications in advance; b) make the code more efficient, in part applying the ideas in this excellent article; and c) prepare the code for bringing in more functionality in later releases.

With regard to c), the main thing I needed to do was rewrite all my selection and removal functions so that moving many items into the selected column at once could just be the move one item function iterated a number of times. I’ve now ( I think) found a pretty efficient solution (each move many function is only 3 lines long), but along the way I came across an interesting dilemma.

My selectOne() function essentially moved a list item and then checks how many items are in each list before adjusting the buttons appropriately. Now, to do a selectAll() or a selectMany() the obvious thing to do is just to iterate that selectOne() function over all list items – just a handful of lines of code – … but this unfortunately leads to a less efficient (and probably slower) function. Writing a selectAll()/selectMany() function from scratch would enable me to only adjust the buttons once and, in the selectAll() case, not have to care about tracking which list item I’m dealing with as they all get moved over in the end… but this way would not only be less elegant, I feel, but also lead to more lines of code.

I’d always assumed that optimising code meant two things – faster and smaller – and I’d always thought that one more or less implies the other. Turns out I was wrong.

In the end, the escape from this trade off involved removing the button adjustment from selectOne() and putting it in selectNow(), a new function triggered by a click. But this required a feature of jQuery which I’ll talk about in some other post.

crossSelect jQuery plugin

Wednesday, May 27th, 2009

I thought I should write a short post to say I have written another jQuery plugin, for making multiple select form elements more intuitive to use. It’s called crossSelect, and here is a demo.

One of these days I will make a proper portfolio site/subsite which collects all the stuff I make together.

I will, I will, I will!

fullTextArea jQuery plug-in

Friday, April 17th, 2009

I’ve just written it, and have to provide a homepage for it. will add more details later.

Demo: fulltextarea.html

Current release

jqueryfulltextarea031

Release details:

  • Tidied up and optimised code

Previous versions

Idea for wordpress plug-in

Saturday, April 4th, 2009

My blog is, I am conscious of, split into two roughly mutually exclusive overarching categories:

These, I feel, could almost be considered sub-blogs, and other subcategories (eg In Phokus) could equally be treated as sub-blogs.

So my idea for a word-press plug-in is the following:

  1. Enables feeds for any category or subcategory to be published (This plug-in has already shown that these feeds exist, but just need linking to appropriately. I’ve just installed it on this blog, but I think it’s a bit of an overkill).
  2. These feeds can all be subscribed to from the main blog page
  3. HOWEVER, if a visitor visits a category page, AND that page has a certain value in $_GET, eg “subblog=true”, then a different template/skin is applied, and only the sub-blog’s feed is available.

I’m gonna call it Sub-blogger as a working title, and set up the appropriate category. Eventually, I hope, it will be its own sub-blog.