jQuery autocomplete, packed with packer!

I’ve been using this autocomplete plugin for a while, it works great. For almost every jQuery plugin there is a packed version supplied, but not for this one, so I decided to pack it myself.

JQuery Logo

But whoops… Javascript errors occured when using the packed version of the plugin. After adding a few semicolons the file got packed correctly and my FireFox 3 is eating it without spitting out errors.

If you have a bunch of javascript that won’t correctly pack, please make sure your code follows this “packer standard”:

// sample code
var input, output;

// notice the semi-colon at the END of function declarations
onload = function() {
 input = document.getElementById("input");
 output = document.getElementById("output");
 clearAll(true);
};

function packScript() {
 output.value = pack(input.value);
};

function clearAll(focus) {
 output.value = input.value = "";
 // the "if" statement is NOT terminated with a semi-colon
 if (focus) {
  input.focus();
 }
};

Packer follows all javascript standards nicely, except for one thing: funtion declarations must also be terminated with a semicolon. More information about this is available at the usage page of Dean Edward’s packer-website.

Download the source here, and the packed version here.