Posts tagged code

Hacking A Little Javascript

I’ve been having fun over the weekend hacking some javascript.  I needed something that would auto summarize some form fields and then pass the total along to another page.  Enter formtotal: http://github.com/lance/formtotal

Usage

Add this to your HTML file:

<script type=”text/javascript” src=”scripts/mootools.js” charset=”utf-8”></script>
<script type=”text/javascript” src=”scripts/formtotal.js” charset=”utf-8”></script>

Give the fields you want to have added up a class name of ‘addend’.  Add a ‘total’ field, and you’re done.  Simple - but it’s fun hacking JS.

How to Know if That Code is Cut and Paste

While doing some work for a client whose site has nothing to do with home furnishings I stumbled across this in the code:


$meta = array();
$meta['keywords'] = array(
'furniture', 'home', 'furnishings', 'home furnishings',
'accessories', 'bedroom furniture', 'living room furniture',
'dining room furniture', 'sofas', 'furniture styles',
'north carolina', 'high point', 'upholstery',
'kid\'s rooms', 'home entertainment', 'home office'
);

$meta['description'] = "Sherrill's exacting standards of
workmanship and exceptional attention to detail assure
the very finest upholstery available. New product
introductions at least twice annually offer Sherrill
customers an up-to-date selection of upscale looks and
the opportunity to choose from a variety of style
preferences.";


$brandsArray = array( "SHERR"=>"Sherrill",
"CTH"=>"CTH",
"WS"=>"Whittemore",
"MC"=>"MotionCraft",
"PREC"=>"Precedent",
"HW"=>"Hickory White"
);

Ugh.  Time to raise the bar folks.