Javascript Articles

August 15, 2007 – 3:25am Stereolabels released: updated labels.js for Prototype

Stereolabels unobtrusively places form input labels inside the form inputs themselves. Upon page load, the script crawls the DOM for labels with the specified class name (default is ‘inside’) and places the label text inside the input field. Upon clicking the field, the label is removed. When the element loses focus, if there is no input the label returns. This behavior is only applied to text, textarea, and password input fields.

Information and a download are available in our code section: Stereolabels

Posted in  Web Development   |     |  No Comments »   |  delicious  Digg

July 26, 2007 – 11:31am sfCombineFilterPlugin released: Combine js and css requests into single compressed files

The sfCombineFilter plugin automatically combines included js and css files in your web response into one request each, passing the string of file names to a special php file that concatenates them and compresses them for faster delivery. This file is then cached for future use.

Information and download instructions are available in our code section: sfCombineFilter

Posted in  Web Development   |     |  1 Comment »   |  delicious  Digg

July 23, 2007 – 8:45pm Prototype Tabs Script released, Scriptaculous Optional

We just released a small script that allows you to easily create tabbed content on your web sites with a nice fade effect. Having searched for a decent script that uses prototype.js and scriptaculous to quickly create tabbed inline content and not having found one, we were inspired to create our own, much as stickmanlabs did with the accordion script. Check out the prototype tabs demo.

Posted in  Web Development   |     |  3 Comments »   |  delicious  Digg

July 19, 2007 – 2:36am Javascript Array Merge: array_merge

Using protoype.js I discovered a quick way to merge to arrays in javascript:

function array_merge(one, two) {
  one.push(two);
  return one.flatten();
}

This definitely beats the alternative of iterating through the second array by hand and adding it to the first. Any comments or suggestions are welcome.

Posted in  Web Development   |     |  1 Comment »   |  delicious  Digg

May 14, 2007 – 2:14am javascript urlencode

In doing a google search for javascript urlencode, I realized I was using that terminology just because I was familiar with the PHP function of the same name. Javascript’s method is actually called encodeURI() which will encode all characters except:

, / ? : @ & = + $ #

But what I really wanted to do was get javascript to convert a string that would be okay to put into a query string of a URL. For this, use encodeURIComponent(). This will convert all characters except alphabetic, decimal digits, and:

- _ . ! ~ * ' ( )

That’s more like it. You can view the complete reference at mozilla or w3schools.

Posted in  Web Development   |     |  2 Comments »   |  delicious  Digg