Regular Expressions are your friend. Once you’ve learn the dark art, you’ll wonder how you ever got by without. It does take a little time and some mastering however. Here are a few links to get you started on your way.
Author Archives:
One of the most frustrating things developing in older version of FarCry was retrieving friendly urls. That’s all in the past now, as its really simple using FarCry 5.
If you’re happy to make the most of FarCry components that live in application.factory, you can use the code below:
<cfset sFU = application.factory.oFu.getFu(objectid=application.navid.navid_here) />
Javascript is a fantastic tool as a developer, it allows you to add some really nice functionality to your website, that you would otherwise be unable to achieve. But when it comes to meeting accessibility requirements, you can’t always rely on javascript to be available and Writing accessible javascript isn’t always that easy.
But in most situations you can provide alternatives so that your website still works with javascript turned off.
I threw together a quick example to demonstrate how you can code a simple log-in form, that works with and without javascript. Granted, the non-javascript version is not as slick as the javascript version, but at least it works; and the javascript version simply kicks-in when possible.
The example uses the href parameter of an a tag, to provide the base requirement functionality, and the onclick parameter to provide the enhanced javascript version. The simple log-in example; with javascript turned off it loads a new page containing the log-in form, with javascript turned on it shows the log-in without reloading a new page.
The key to having javascript take over where it can and overide the default href browser behaviour (but degrade back to the default browser behaviour, i.e. visit the linked page) is the return statement in the onclick parameter:
<a href="login.html" onclick="return doSomething();">Login</a>
You can also download the accessible javascript example files.
I’ve been programming more and more jQuery in a recent project, and I’m loving it. However, I’m not quite sure how I should best invoke javascript, in response to user actions.
I’ve found myself using <a /> tags, but with no href and using onclick to invoke my javascript. I thought it was much cleaner than <a href=”#” onclick=”…”></a>, or using <a href=”javascript:…”></a> to respond to actions.
I’m not really sure if it is the best way to do it? But I have found a downside to this method. The browser doesn’t always render the text within the <a /> tag as a full link (featuring the hand cursor upon rollover, and sometimes not even displaying the underline). So I wrote a quick line of jQuery to fix this across the board.
Place the following code in your javascript, and it will make any <a /> tag in your page, that doesn’t have a href, look like a regular old link!
<script type="text/javascript">
jQuery(document).ready (function () {
jQuery('a[href=""][onclick]').css('cursor', 'pointer').css('text-decoration', 'underline');
});
</script>
Ever wanted to shorten a string, but keep the word intact?
With inspiration from Ben Nadel, I’ve created a ColdFusion 7 friendly UDF to get the job done.
<cffunction name="midWord" returntype="string" output="false">
<cfargument name="string" type="string" required="true" />
<cfargument name="characters" type="numeric" required="true" />
<cfset var sReturn = '' />
<cfset var stExcerpt = StructNew() />
<cfset stExcerpt = reFindNoCase(".{1,#arguments.characters#}(?=([\s\-:]|$))", arguments.string, 1, true) />
<cfset sReturn = mid(arguments.string, stExcerpt.pos[1], stExcerpt.len[1]) />
<cfreturn sReturn />
</cffunction>
I’ve been reading a book on Microformats, written by John Allsop. I’m not very far into the book yet, but so far it sounds very interesting.
I’ve read a fair bit about Microformats in many blog posts, and the microformats website itself is very informative. While I understand and appreciate that microformats are important for the greater good of the internet infrastructure, as a business owner and manager of the development team, I’ve been struggling to find a business proposition as to why we should start using them in our website development.
I assumed they would make coding more complex and perhaps increase client budgets (through development time) for no real gain for the client. I’m still tossing around the idea in my head, of how can the client really benefit from the use of microformats on their website.So I decided to play with a few microformats and dreamed up a hCard and jQuery combination (or mashup?).
Using jQuery it was really easy to dig into the body of the page and pull out address information, which is exactly what microformats are all about, creating markup that firstly humans can read and second computers can read.
Once you have the data using jQuery, your imagination is the limit really. I came up with a few trivial examples. The first example demostrates mining for the address and simply linking it to maps.google.com.au. The second example mines for the addresses and then as you click on them, plots them on a Google Map. I was amazed at how quickly and easy it was to program these examples using jQuery.
With this expirmentation I’ve found the business proposition and argument as to why we should start programming using microformats where possible; they make development easier and faster all the while increasing the infrastructure of the web!
You can download the source for the microformat and jQuery examples.
I’m at it again! We had another tree problem the other day which I was involved in fixing. However, this wasn’t a standard sized tree, it was huge!
I whipped out the tree inspector and starting working away on the tree. Everything was going smoothly, but with such a large tree and so many levels deep, it became really confusing, really fast!
I’ve updated the tree inspector with +, – and | placed strategically so it looks a little more like the trees as displayed in Explorer (on Windows). I will update this to use images at some point, but I didn’t want to make the distribution of the tree inspector hard (at the moment it is one file, and nice and easy to install). I’ll look into embedding images into the HTML using base64 encoding.
I’ve also encountered a seemingly common problem with the basic HTTP authentication that I added in the last version. On a couple of windows based servers the basic http controlled authentication (using the WWW-Authenticate header) wasn’t working properly (better described here).
If you’re working with a shared host, this is not always so easy to fix. In this instance, it was easier to comment the authentication code out of the script, upload, use it and then delete the file. I decided to make it easier to disable the authentication, and now you can turn it on or off by changing the bUseAuthentication variable at the top of the script.
Happy tree fixing.
I had a situation this morning, in which I had to whip out the Tree Inspector to resolve a problem with a FarCry tree. Some of the nlevel values were wrong, but Tree Inspector didn’t allow me to fix those; so now it does!
I’ve added a version number to the top (along with a h1 title), and you can now modify the nlevel values by checking the checkbox appearing next to each node.
It also occurred to me, that if this file sits unprotected on a website, someone who knows the name of the file can do some real damage. So I’ve added basic Authentication support to the script so it is now protected by default.
You should change the username and password before using the script, and I suggest you upload the file, use it and then remove it. Just like the install directory (that comes with FarCry), this is a file that shouldn’t be sitting on a production server.
I really like Cairngorm, I think it is an excellent framework to build RIAs in. I just don’t like all the work, memory involved in setting it up all the time.
I’m not really sure how others do this, but I usually grab an example application (such as the Advanced Cairngorm Store) and start ripping out all the bits and pieces I don’t need. This is a laborious and boring task, so I decided to do something about it.
I created a set of Cairngorm Stub Files (setup under the com.example path). They contain stub-code/files for most of the Cairngorm infrastructure that you would usually use in a Cairngorm project.
The files make a nice starting point, and because there are so many bits and pieces to the Cairngorm Framework, they also act as a nice cheat sheet to all of the classes, and patterns in Cairngorm.
Let me know if you find any bugs and I’ll update the stub files.