Creative Juices Bo. Co.

Satisfy Your Thirst For Something Refreshing!

U.S. Currency Conversion Using Javascript

A Small JavaScript U.S. Dollar Formatter

If you're like me and work on a lot of e-commerce sites, I'm sure you have come across the need to have a simple function to convert a number to a U.S. Dollar formatted string. If you have scoured Google looking for something, I'm sure you've come across the plethora of "currency" formatting libraries/functions out there. The problem is (at least with me) is that all these functions seem to be large, complicated, monstorous libraries that give you the ability to convert a number into a gazillion different localized currencies. That's fine and dandy if your customer plans on going global, but what if they just want to sell things in the U.S.? That pretty much sums up the majority of my customers.

I've come up with a very simple JavaScript prototype that will convert a number into a nice U.S. Dollar formated string. This function will add the thousands seprator (comma), add the dollar sign ($), add two decimal places and handle negative numbers.

read full article...

Easily Detect iPad, iPhone or iPod Using Javascript

An Simple Way Of Device Detection

I'm currently working on a website and one of the jQuery plug-ins I'm using is really just for eye candy and it only works with mouse overs (or mouse hover events). The problem is mouse over events don't work on the multitude of "touch" devices out there. I needed a quick little script to determine the device in order to stop this plug-in from activating, but also needed an easy way to add other devices down the line (like Android) when needed. Here's what I came up with...

// detect touch devices to turn off any mouseover only functions
window.is_touch_device = (/iPhone|iPod|iPad/i).test(navigator.userAgent);

We are using a regular expression (ignoring case) to determine if our product name is located in the navigator user agent string. If it is, then we set our touch variable to true. This method should be compatible with all major browsers (old and new)

I'm not 100% sure if I like using the userAgent to detect the device, but I couldn't think of an easier way of doing this. If you have some thoughts let me know.

read full article...

We're You Surprised?

At One Point I Wanted To Be A Cartoonist

I found this the other day looking through some of my older stuff. Not sure why, but I think this is funny. My younger self seems to have a whacked sense of humor.

we're you surprised?

read full article...

Using RegEx to Remove Line-Breaks, White-Space From HTML (Except PRE Tags)

Remove White-Space from HTML Except from <pre>'s

If you have ever used ColdFusion's function (<cfprocessingdirective suppresswhitespace="yes">), you may have noticed that it strips white-space formatting from any HTML <pre>'s you may have in the code. 99% of the time you would never have this problem, but if you have a programming blog, this can be some what of a hassle.

Well, as I was re-writing my site, I decided to take up the challenge and create a function using RegEx that ignore's anything in-between the <pre>'s. It will also remove any comments, but since I was using this to strip all the white-space out of my generated HTML, I soon realized this wasn't working to well with my conditional comments for Internet Explorer. Oh well, at least it's in here for future use. Let me know if you have any problems.

read full article...

HTML5, Sessions and LocalStorage... Hoorah!

HTML5 Tip: Using localStorage to Retain Form Data when Sessions Expire

Most of the websites I design have a pretty nifty Content Management System which allows my clients to edit a majority of their website content. One of the biggest problems I've been trying to address over the past few years has been the short session limit on some of the shared hosting plans we use. It seems like the ISP's only allow a maximum of 30 minutes when using session management. 90% of the time, this is fine, but if my client is in the middle of an edit and then takes a phone call or leaves the computer, it's possible the session will expire and then they will lose the form data they had entered.

read full article...
Page: 12345678910111213>22