CFJS Revisited (update)

I've successfully added HTMLCodeFormat() and HTMLEditFormat() functions to CFJS and have checked the new code into the repository as version 1.1.10.

But I've got more to do. Looking through some old notes, I found that I still needed to add the following:

  • NumberFormat()
  • ArrayAverage()
  • ArrayClear()
  • ArrayDeleteAt()
  • ArrayInsertAt()

I will of course, still be working on a demo page as well.

[More]

John Resig to Give Online jQuery/JavaScript Training?

It could happen. The jQuery team is trying to gauge the interest of the community at large in attending a fee based online training class on jQuery delivered live by John Resig himself.

To quote the post to the jQuery general mailing list:

"Nobody knows jQuery better than John and in terms of JavaScript, he's considered one of the best in the world. So a training class delivered by him would surely help anyone become more proficient in JavaScript and jQuery."

Realize now that they're just trying to gauge interest. No details have been hammered out. Some concerns that have been raised so far on the mailing list are:

  • cost
  • time/date
  • will it be recorded for later viewing

All are valid questions, but don't really have anything to do with the poll in which the jQuery team is asking that we participate. They're merely trying to ask the question: If John were to deliver a live, online class on the subject of jQuery (and by association JavaScript) would you pay to attend?

Do the community a favor and answer the poll. Answering the poll is not the same as making a commitment to attend or to pay any sum of money. It's a simple yes or no question. So head on over to the poll and give your yea or ney.

And in case you've missed it the three or so times above... here the link to the poll. :o)

CFJS Function Listing

It's been a long while since I've made any mention of CFJS in any of my blog posts. I had a look at the function listing linked to on the right hand side of the page under Projects, and noticed that the function listing wasn't quite up-to-date.

So, I decided that I'd post a fresh one. I'll replace the old link on the side with a new one to this post.

I've not gotten any requests for new functionality to be added to the library, and quite frankly, I've been too busy to devote too much time to it recently. I hope that will change later, but I think the library gets a good workout by everyone who uses it, and if something were wrong with it I'm sure I'd hear about it. ;o)

So without further ado, here's the most recent function listing. I may play around with the format of the listing, but the content shouldn't change. :o)

Array (5)
ArrayAppend
ArrayPrepend
ArraySort
ArrayToList
ArrayLen
Date/Time (8)
CreateDate
CreateDateTime
CreateTime
CreateODBCDate
CreateODBCDateTime
CreateODBCTime
DateDiff
DatePart

[More]

jQuery + AjaxCFC Tutorial Part 3: Debugging

If there's one thing that's for certain it's that Ajax is very cool stuff, and everyone it seems is using it. It allows us as developers to provide for that slick desktop app sort of feel inside of a browser.

On the other hand: debugging ajax calls can be a serious pain in the butt! There are tools out there to help us though: Fiddler, FireBug, GreaseMonkey, Venkmen, etc. and those are fine, but Rob Gonda has provided us ColdFusion programmers with even more functionality when it comes to debugging our XMLHttpRequest calls.

[More]

jQuery + AjaxCFC Tutorial Part 2: Handling Complex Data

Okay. It's late. Really late. But, I'm back -- I know you're thinkin' who the heck are you? -- and part two of my jQuery + AjaxCFC tutorial is finally here. I've been stressing over not having finished this sooner, but I hope some folks will still find it useful.

[More]

Where's Part Two of the jQuery + AjaxCFC Tutorial?

So it's 8:00am here in Texas, and I was about to get in the truck to make the hour (sometimes longer) trip into Dallas to start the work day at one of my clients. Then I get a voicemail from the boss reminding me that he and I have a sales call at 9:30am in Arlington -- an hour or so from Dallas.

[More]

jQuery + AjaxCFC Tutorial Part 1: Erratum 1

In part one of this tutorial series I noted the mechanism by which I enable/disable log4javascript using the CF variable 'JSIncludeList' along with a boolean 'ShowLog4JS'.

<CFSet ShowLog4JS = false>
<CFSet JSIncludeList = "">
<CFIf ShowLog4JS>
    <CFSet JSIncludeList = ListAppend(JSIncludeList, "log4j")>
</CFIf>

I also made mention of the following helper functions:

$.AjaxCFCHelper.setDebug(false);
$.AjaxCFCHelper.setBlockUI(true);
$.AjaxCFCHelper.setUseDefaultErrorHandler(true);
$.AjaxCFCHelper.setSerialization('json'); // json, wddx

I have to admit that I'd not used any of these functions before, but I wanted to at least make everyone aware of their existance. Well, I used the first one on the above list today while helping a friend to debug some code. It turns out that

$.AjaxCFCHelper.setDebug(true);

turns on log4javascript! So, basically I reinvented the wheel, and Rob already had us covered with a mechanism to turn on and off log4javascript.

If I learn anything new between now and when I finally get part two of this tutorial written (probably this weekend), I'll be sure to post another quick errata.

Cheers!

jQuery + AjaxCFC Tutorial Part 1: Setting Up Your AJAX Call

I've recently received a couple of emails from individuals on different mailing lists asking for help using Rob Gonda's AjaxCFC with jQuery. More specifically, what to do with complex data (i.e. a CF query object) once it's come back from the ajax call.

In the case of both the emails I received asking for help, the writers wanted to know (in general) how to update an on-screen table with new records based on the data returned from their AjaxCFC call.

It sounds like a bit of a tutorial is in order, and since I couldn't easily find one on the net, I thought I'd better write one.

[More]

jQuery 1.1.3 Released!

Just a quick note to say that jQuery 1.1.3 is now available for download using the following links.

This release is supposed to be more than 800% faster than the previous release! I personally, cannot wait to give this final release a test drive in my current production code!

The blog entry over at jquery.com has loads more information and I won't try to repeat it here.

The jQuery team has also released information about a secret project that has been in the works: jQuery UI.

I'm super excited about this and about the future of jQuery which is also discussed in the blog post over at jQuery.com.

If your a fan of jQuery and have a few bucks lyin' around, think about donating to the cause. It's a good one.

CFJS Ver. 1.1.6 Released

While I'm still struggling to find the time to work on new features for the CFJS libraries (IsValid, ArrayAverage, ArrayClear, ArrayDeleteAt, ArrayInsertAt, ArrayPrepend, and ArraySum), a bug in the DateFormat function had been brought to my attention by user Boyan Kostadinov. He then later pointed me to another DateFormat function written by Steve Levithan.

Steve's DateFormat function is very nice, and since Steve does some ColdFusion programming the syntax is very similar. Steve implemented his function as an extension of the JavaScript date object, but since I've incorporated his function into both branches of the CFJS library this is no longer the case. So the CFJS syntax of the function follows more closely to the syntax of CF's native function.

In Steve's implementation you could write a line of code like this:

date.format("Today is dddd");

Which should return something like, "Today is Thursday". But when using the CFJS implementation to get the same result you'd need to write it like this:

/*using CFJS for jQuery*/
$.DateFormat(new Date(), "Today is dddd");

/*using CFJS without jQuery*/
CFSJ.DateFormat(new Date(), "Today is dddd");

Following is a table of the different metacharacters available to the DateFormat function. (This table is almost a direct rip from Steve's blog post which discusses his function)

MaskDescription
d Day of the month as digits; no leading zero for single-digit days.
dd Day of the month as digits; leading zero for single-digit days.
dddDay of the week as a three-letter abbreviation.
dddd Day of the week as its full name.
m Month as digits; no leading zero for single-digit months.
mm Month as digits; leading zero for single-digit months.
mmm Month as a three-letter abbreviation.
mmmm Month as its full name.
yy Year as last two digits; leading zero for years less than 10.
yyyyYear represented by four digits.
h Hours; no leading zero for single-digit hours (12-hour clock).
hh Hours; leading zero for single-digit hours (12-hour clock).
H Hours; no leading zero for single-digit hours (24-hour clock).
HH Hours; leading zero for single-digit hours (24-hour clock).
M Minutes; no leading zero for single-digit minutes.
Unlike CF we use an uppercase M to avoid conflict with months.
MM Minutes; leading zero for single-digit minutes.
Unlike CF we use an uppercase MM to avoid conflict with months.
s Seconds; no leading zero for single-digit seconds.
ssSeconds; leading zero for single-digit seconds.
l or L Milliseconds. l gives 3 digits. L gives 2 digits.
t Lowercase time marker string: a or p.
No equivalent metasequence in CF.
tt Lowercase time marker string: am or pm.
No equivalent metasequence in CF.
T Uppercase time marker string: A or P.
This is equivlant to CF's t metacharacter.
TT Uppercase time marker string: AM or PM.
This is equivlant to CF's tt metacharacter.
Z Timezone abbreviation; e.g., EST, MDT
No eqivalent metacharacter in CF.
'…' or "…" Literal character sequence. Surrounding quotes are removed. Not necessary when using mask characters as part of larger words.
CF only supports single quotes for literal spans.

The most notable differences are that I've added the 't' and 'T' metacharacters to the function. While, Steve's function allowed for 'AM' or 'am' with TT and tt respectively, he did not allow for 'A' or 'a' which is what 'T' and 't' are used for.

The other major thing to note (if you haven't already) is that this new DateFormat function also handles the formatting of time. This means that there really isn't a reason to have a TimeFormat function. However, since this breaks with CF's dogma, I've written TimeFormat such that it's really just an alias of DateFormat. Someone might use DateFormat() for all their date formatting needs and TimeFormat() for all their time formatting needs, but in reality the two functions work interchangeably.

The nice thing about having one function that handles both date and time formatting is that it replaces two other functions that were quite long, and so the overall size of CFJS just went down by a bit. :o)

CFJS: IsValid()

A request was made for a reproduction of the IsValid() function to be added to CFJS, and after taking a cursory glance at the doc page for this function, I've decided that I'll probably be releasing this function in stages. There are lots of validation types. Some, I know exactly how to accomplish, other's either might take a little more time or just don't seem to make sense in the context of JavaScript (like query and veriableName). Below is the list of types from the livedocs page on IsValid(). I've starred the ones I figure I can do pretty easily. I'd like opinions on the validation types that people would like first. Of course, I'll try to get as many of them in the first release as I can.

Type Description
any any simple value. Returns false for complex values, such as query objects;; equivalent to the IsSimpleValue function.
array an ColdFusion array; equivalent to the IsArray function.
binary a binary value;; equivalent to the IsBinary function.
boolean a Boolean value: yes, no, true, false, or a number; equivalent to the IsBoolean function.
component a ColdFusion component (CFC).
creditcard a 13-16 digit number conforming to the mod10 algorithm.
date or time any date-time value, including dates or times;; equivalent to the IsDate function.
email a valid email address.
eurodate any date-time value, including US date formats and time values.
float or numeric a numeric value; equivalent to the IsNumeric function.
guid a Universally Unique Identifier of the form "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" where 'X' is a hexadecimal number.
integer an integer.
query a query object; equivalent to the IsQuery function.
range a numeric range, specified by the min and max attributes.
regex or regular_expression matches input against pattern attribute.
ssn or social_security_number A U.S. social security number.
string a string value, including single characters and numbers.
struct a structure; equivalent to the IsStruct function.
telephone a standard US telephone number.
URL an http, https, ftp, file, mailto, or news URL.
UUID a ColdFusion Universally Unique Identifier, formatted 'XXXXXXXX-XXXX-XXXX-XXXXXXXXXXXXXXX', where 'X' is a hexadecimal number. See CreateUUID.
USdate a U.S. date of the format mm/dd/yy, with 1-2 digit days and months, 1-4 digit years.
variableName a string formatted according to ColdFusion variable naming conventions.
zipcode U.S., 5- or 9-digit format ZIP codes.


CFJS Ver. 1.1.4 Released

Thanks to my good friend and co-worker, Steven Van Gemert, two new string functions have been added to both the jQuery and non-jQuery branches of the CFJS library!

Functions Added:

Pad(String [, Number] [, PadCharacter] [, PadDirection])

RepeatString(String, Number)

Since Pad() isn't a usual ColdFusion function, I'll update this blog post with some instructions and an example later this evening.

EDIT: So, here's the edit I promised for last night. I'll show here an example of how the Pad() function works.

var myString = "CFJS ROCKS!";
alert($.Pad(myString, 20, ">
", "Left"));
So this bit of code up here would alert the string:

>>>>>>>>>CFJS ROCKS!

Changing the direction of the pad would put the fill characters on the other side of the starting string. If the given string is longer than the length passed in (arg. 2), then the function just returns the original string.

The function will also accept R or L as directions in stead of Right or Left.

The addition of these two string functions brings the total number of functions in the library to 69!

CFJS Downloads (jQuery):
Download CFJS for jQuery (compressed) 9.5KB
Download CFJS for jQuery (uncompressed) 22.7KB
Download The CFJS ChangeLog 5.7KB

Downloads (non-jQuery):
Download CFSJ (compressed)
Download CFSJ (uncompressed)

Cheers, everyone!

AjaxCFC for jQuery Updated with New Version of CFJSON

I Found out today that Rob Gonda's AjaxCFC has just received a new update where CFJSON is concerned. Turns out that version cfjson v1.6b was buggy so he's moved it to v1.7.

Rob is strongly suggesting that we get the update.

One thing's for certain, I'm getting it. You should too. ;o)

Here's a link to the original post on Rob's Blog.

Cheers, everyone!

Left-to-Right Select ... A plug-in for jQuery

Ever wished you had a form element that emulated one of these?

For one of my clients we've got a need to have users assigned to groups, and we've employed some cool code written by my friend Steven Van Gemert that takes two standard select boxes to accomplish this sort of control.

It works, but we end up with lists that look like this:

Because of the nature of the select element, the width cannot be controlled -- at least in IE6, I'm honestly not sure about FF, IE7, Safari or any other browser.

I've been thinking about this problem for quite some time, and thought that a jQuery plug-in would be a nice way to solve the problem.

I've got some preliminary work done, but it's by no means finished. Look at demo that shows what I've got so far.

While I've not yet coded it, my plan is to automatically add and remove hidden form fields, one for each item. If it's moved over to the right: add a hidden field. If the item is moved over to the left: remove the hidden field corresponding to that item.

I figure, that doing this will allow the developer to simply submit the form as normal and handle the hidden fields as they normally would.

So, that's an idea for a plug-in that's been swimmin' around in my head for quite a while now. I've just been looking for the time to work on it. I've half expected someone to beat me to the punch.

Also, I'm not brilliant when it comes to CSS, so if anyone wanted to help out on that front, I probably wouldn't say no. :o)

CFJS - ColdFusionJavaScript (for jQuery)

Simply put: CFJS for jQuery is a set of ColdFusion functions written for JavaScript.

The CFJS for jQuery library is ment for ColdFusion programmers who might not be as accustomed to writing in JavaScript, or for anyone who just wants a set of nifty functions at their disposal! :o)

For a while now I've been keeping the latest version of the code for CFJS over at RIAForge.org. This project does not directly use an Adobe technology, but it emulates one and so I guess they thought it would be okay for me to host the project there. (Thanks Ray!)

The download links below now point to the code in the SVN repository. Also, if anyone finds a bug or would like a function added, please use the Issue Tracker on RIAForge or contact me via the jQuery google group. You could also leave a comment to this post.

The complete list of functions provided by CFJS is contained in the changelog which is in the root of the SVN repository.

EDIT:
A list of the the available functions, now totaling 67, is available outside of the ChangeLog.

As the list of functions grows, I think I may start to offer them in smaller packages like, jquery.cfjs.strings.js, and jquery.cfjs.lists.js but for now the packed version of the whole thing is around 9.5K, and that doesn't seem too big to me.

If there's more interest in a distribution method like I mentioned above, then I may just do it anyway.

CFJS Downloads:
Download CFJS for jQuery (compressed) 9.5KB
Download CFJS for jQuery (uncompressed) 22.7KB
Download The CFJS ChangeLog 5.7KB

BlogCFC was created by Raymond Camden. This blog is running version 5.9.4.001. Contact Blog Owner