This blog has moved.

The content here has been left available for historical purposes, and should be considered out of date. For the most part, comments have been closed. If you have questions, feel free to contact me at justin.henry(at)uvm.edu. Any new material can be found at http://greengaloshes.cc. Thanks for visiting!

Archive for the 'scripts' Category

Batch converting for Zoomify with ZoomifyImage

Thursday, February 9th, 2006

Zoomify is a pretty slick application that allows you to serve “fast, high-res images in flash”. These images can be zoomed in upon, and if you have the “Enterprise” version as we do, the images can be “annotated” with circles, arrows, labels, and more.

Recently I noticed that Wes, in a fantastic example of synergy in action, got Python upgraded on zoo so that it’s now possible to convert images into the necessary format from within a UNIX environment. This opens up some options that we hadn’t had before, such as being able to process images uploaded via a web interface, and provide web initiated batch processing of images.

Today we’ll look at how to get images converted to the “Zoomify” format, using a free, open source Python script. In short, we’ll be covering:

  • Installing the ZoomifyImage package
  • Using a PHP “wrapper” with ZoomifyImage to convert a directory of images
  • Using a PHP script to easily inspect the processed images

    (more…)

Simple Javascript Multiple Checkbox Selector

Monday, November 15th, 2004

Here’s a bit of code I use to automatically select/deselect checkboxes. I am pretty sure google brought me to the script in it’s original form in a thread at webmasterworld.

This is the function that goes in your script tag, or in your .js file:

function makeCheck(form,check) { var options = form.elements['filename[]'] for (var i = 0;i < options.length; i++)
options[i].checked = check }

Below is the HTML tag to use for the “selector” checkbox - that is, the checkbox the user clicks to select/deselect all the checkboxes. I put this within the form element. Note the second argument that gets passed to the function - most of the scripts I saw used two separate buttons to toggle the selection, but since this wasn’t as elegant as I wanted, I replaced the hard coded boolean value with this.form.selectorbox.checked.

<input type="checkbox" name="selectorbox" value="SelectAll" onClick="makeCheck(this.form, this.form.selectorbox.checked);">Select All</input>

Since I’m generally using sets of checkboxes that get passed into PHP arrays, note how the name of the checkboxes are appended with empty square brackets.

<input type="checkbox" name="itemNames[]" value="item1">Item 1 <input type="checkbox" name="itemNames[]" value="item2">Item 2 </input>

Simple Javascript Confirmation Box

Monday, November 15th, 2004

This is a quickie that pops up an alert box with the below message, with “Confirm” and “Cancel” buttons. This first snippet goes in an external javascript file, or within “script” tags in the header of the html file.

function confirmAction() { if (confirm ("Are you REALLY SURE you want to do that?")){ return true; } return false; }

To put that in a link or a button, use an onClick() call. Here’s an example of a delete link with a call to confirmAction in the onClick(). This is integrated into a php page.

<a class="delete" href="processData.php?delete=< ?php echo $idToDelete; ?>" onClick="return confirmAction();">delete</a>

Simple Javascript Pop-up Window

Tuesday, October 26th, 2004

This is one of those little tidbits of code I am always using, and which takes too much time to write from scratch every time I need it. This would normally be placed in an external .js file (i.e. <script src="validate.js" type="text/javascript"></script>), or placed within <script language="javascript"></script> tags in the head of an html file.

function openWin(filename) { var newWin = window.open(filename,'Window', 'width=750,height=700, left=40,top=40,scrollbars=1,menubar=1, status=0,location=0,resizable=1,directories=0'); }

To make a link that would use this function to pop up a window:

<a href="#" onClick="openWin('nameOfPageToOpenInNewWindow.html');return false;">Click here to open in a new window</a>

PHP Classes

Thursday, September 2nd, 2004

These classes tend to have the functions I use more often when writing applications with PHP. One mostly contains methods for interacting with a MySQL db, and the other has more general functions.