<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>NeilMPatterson.com</title>
	
	<link>http://www.neilmpatterson.com/blog</link>
	<description />
	<lastBuildDate>Wed, 19 May 2010 02:32:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Neilmpatterson" /><feedburner:info uri="neilmpatterson" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Back to my roots</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/l9Q_c_8Ax1o/</link>
		<comments>http://www.neilmpatterson.com/blog/back-to-my-roots/#comments</comments>
		<pubDate>Wed, 19 May 2010 02:32:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.neilmpatterson.com/blog/?p=106</guid>
		<description><![CDATA[I recently created a flyer/poster design for my synagogue which gave me an opportunity to refresh my old graphic design skills. It&#8217;s not much, and since this was a non-profit I did it fairly quickly and used a business card design I found on adobe as the basis for the design. So really all I <a href="http://www.neilmpatterson.com/blog/back-to-my-roots/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.neilmpatterson.com/blog/wp-content/uploads/2010/05/thumb1.jpg"><img class="alignright size-medium wp-image-113" title="Beit Cafe Flyer" src="http://www.neilmpatterson.com/blog/wp-content/uploads/2010/05/thumb1-231x300.jpg" alt="Beit Cafe Flyer" width="231" height="300" /></a>I recently created a flyer/poster design for my synagogue which gave me an opportunity to refresh my old graphic design skills. It&#8217;s not much, and since this was a non-profit I did it fairly quickly and used a <a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&amp;loc=en_us&amp;extid=1810528">business card design</a> I found on adobe as the basis for the design. So really all I did was layout some typography, but it was fun nonetheless!</p>
<p>It was well received so I&#8217;m kind of impressed with it. I have done several of these flyers and posters for my Temple so far and it&#8217;s going pretty good.</p>
<p>On the other hand however, I have tried to help on the <a title="TempleBethHillel.com" href="http://templebethhillel.info">temple web site</a>, but they got that locked down pretty well. I would love to give that thing an overhaul though.</p>
<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/l9Q_c_8Ax1o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/back-to-my-roots/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/back-to-my-roots/</feedburner:origLink></item>
		<item>
		<title>Date string comparison in Coldfusion</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/_yo-0GV9PBY/</link>
		<comments>http://www.neilmpatterson.com/blog/date-comparison-in-coldfusion-8/#comments</comments>
		<pubDate>Sun, 16 May 2010 22:13:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.neilmpatterson.com/blog/?p=93</guid>
		<description><![CDATA[I discovered the other day an interesting tid-bit in cf 8 when comparing two date strings that were set as the following:

&#60;cfset date1 = '5/19/2010' /&#62;
&#60;cfset date2 = '19/5/2010' /&#62;
&#60;cfif date1 eq date2&#62;the same&#60;cfelse&#62;different&#60;/cfif&#62;

When doing so the strings are considered equal. I gather this is because it translates both strings as dates automatically but one <a href="http://www.neilmpatterson.com/blog/date-comparison-in-coldfusion-8/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>I discovered the other day an interesting tid-bit in cf 8 when comparing two date strings that were set as the following:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> date1 <span style="color: #0000FF;">=</span> <span style="color: #009900;">'5/19/2010'</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> date2 <span style="color: #0000FF;">=</span> <span style="color: #009900;">'19/5/2010'</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> date1 <span style="color: #0000FF;">eq</span> date2<span style="color: #0000FF;">&gt;</span></span>the same<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfelse</span><span style="color: #0000FF;">&gt;</span></span>different<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>When doing so the strings are considered equal. I gather this is because it translates both strings as dates automatically but one is in d/m/yyyy format and the other is m/d/yyyyy format. This was troublesome for me since I was comparing two dates that come from a possible user input, entering them into a text field of a form as an alternative to using the date picker.</p>
<p>DateCompare() results the same. In order to solve my issue without creating a brand new date using createDate(), I was able to use the compare() function as in the following:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> <span style="color: #0000FF;">compare</span><span style="color: #0000FF;">&#40;</span>date1,date2<span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">eq</span> <span style="color: #FF0000;">0</span><span style="color: #0000FF;">&gt;</span></span>the same<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfelse</span><span style="color: #0000FF;">&gt;</span></span>different<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Strange thing about cf but not really a bug.</p>
<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/_yo-0GV9PBY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/date-comparison-in-coldfusion-8/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/date-comparison-in-coldfusion-8/</feedburner:origLink></item>
		<item>
		<title>Loading images as they become available</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/lEzKokXjBVQ/</link>
		<comments>http://www.neilmpatterson.com/blog/loading-images-as-they-become-available/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 07:12:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://neilmpatterson.com/?p=62</guid>
		<description><![CDATA[Currently working on a project that required me to create an image upload and processing factory. Basically, it allows you to upload media (photos and video) and then processes media, encodes video, resize images etc.
The problem: After uploading a batch of images, the user is brought to a page where they may name each photo <a href="http://www.neilmpatterson.com/blog/loading-images-as-they-become-available/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Currently working on a project that required me to create an image upload and processing factory. Basically, it allows you to upload media (photos and video) and then processes media, encodes video, resize images etc.</p>
<p>The problem: After uploading a batch of images, the user is brought to a page where they may name each photo they just uploaded and add descriptions. However, since we allow them to upload many photos at once, the images are not available right away. So they will see a default placeholder image until the new one  is availble. When the new image is loaded, we use javascript to change the image on the page, without reloading.</p>
<p>The solution: a little javascript, a little jQuery.<br />
<span id="more-62"></span></p>
<p>Let&#8217;s start by creating a simple demo html:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;!doctype html&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js/jquery-1.4.1.min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
  <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">h1</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;loader&quot;</span>&gt;</span>Loading Images<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">h1</span>&gt;</span>
&nbsp;
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/default.gif&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dynImg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/default.gif&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dynImg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/default.gif&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dynImg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/default.gif&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dynImg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">p</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;images/default.gif&quot;</span> <span style="color: #000066;">border</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;dynImg&quot;</span> <span style="color: #66cc66;">/</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">p</span>&gt;</span>
&nbsp;
  <span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p>You should notice that there are six images that we will load and they all have unique id&#8217;s but the same class name. Our javascript will use the unique id to locate the file names. For the sake of this demo our loaded images will be named according to the id&#8217;s so we will be attempting to load 1.gif, 2.gif, 3.gif all the way up to 6.gif</p>
<p>Let&#8217;s begin to add our javascript. First let&#8217;s create a function to select the image collection and update each image. the function will be named updateDynImg().</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.dynImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// Do something.</span>
&nbsp;
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span>
&nbsp;
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Above shows how we use jQuery to select all class names of &#8220;dynImg&#8221; that happen to be img tags and loop over each one in the collection using the each function.</p>
<p>Now let&#8217;s set a few variables, create an image object, use that to check if the image exists and then create a new function to call when the image loads successfully.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.dynImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> EID <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> URL <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> tester<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            tester.<span style="color: #000066;">onload</span><span style="color: #339933;">=</span>isGood<span style="color: #339933;">;</span>
            tester.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>URL<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">function</span> isGood<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>EID<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>This is the meat of our script above. It&#8217;s pretty god damn basic. but it works. If you were to load images into your images directory now it will load. Of course after a page refresh since we have not set our interval yet.</p>
<p>There are a couple other things we will need to update as well. First, let&#8217;s create a new function to run this function when the page loads and set an interval to run every 5 seconds. We can paste this directly below the first function.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// run the kickoff update.</span>
    updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">//set the interval to run update.</span>
    setInterval<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;updateDynImg()&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Pretty straightforward, not gonna go into detail there. Now, to solve some problems with browser caching when attempting to load these images we will add a random number to each image.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.dynImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> randomnumber<span style="color: #339933;">=</span>Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">10001</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> EID <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> URL <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif?id=&quot;</span><span style="color: #339933;">+</span>randomnumber<span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> tester<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            tester.<span style="color: #000066;">onload</span><span style="color: #339933;">=</span>isGood<span style="color: #339933;">;</span>
            tester.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>URL<span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">function</span> isGood<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>EID<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span></pre></div></div>

<p>Easy enough. Now I want to make sure I am not running a check if the image is already loaded. So let&#8217;s just make sure that the src of the current image is the default.gif (must use absolute paths for this).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.dynImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> randomnumber<span style="color: #339933;">=</span>Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">10001</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> EID <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> URL <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif?id=&quot;</span><span style="color: #339933;">+</span>randomnumber<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> tester<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> myRoot <span style="color: #339933;">=</span> location.<span style="color: #660066;">href</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^.*\//</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">src</span> <span style="color: #339933;">==</span> myRoot<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;images/default.gif&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            tester.<span style="color: #000066;">onload</span><span style="color: #339933;">=</span>isGood<span style="color: #339933;">;</span>
            tester.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>URL<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #003366; font-weight: bold;">function</span> isGood<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>EID<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span></pre></div></div>

<p>Excellent! Nearly done. Now I just want to update the header to show how many images are loaded and the total number of images. I wont break that down so here is the full javascript block. Go ahead and test it locally, just rename your images or drag them in and out of the directory and watch them update automatically. Fun with Javascript!</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> numOfLoaded <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> totalImages <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.dynImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
&nbsp;
        $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.dynImg'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003366; font-weight: bold;">var</span> randomnumber<span style="color: #339933;">=</span>Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span>Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">10001</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> EID <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> URL <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif?id=&quot;</span><span style="color: #339933;">+</span>randomnumber<span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> tester<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Image<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #003366; font-weight: bold;">var</span> myRoot <span style="color: #339933;">=</span> location.<span style="color: #660066;">href</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/^.*\//</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">src</span> <span style="color: #339933;">==</span> myRoot<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;images/default.gif&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                tester.<span style="color: #000066;">onload</span><span style="color: #339933;">=</span>isGood<span style="color: #339933;">;</span>
                tester.<span style="color: #660066;">src</span><span style="color: #339933;">=</span>URL<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numOfLoaded <span style="color: #339933;">!=</span> totalImages<span style="color: #009900;">&#41;</span> updateLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #003366; font-weight: bold;">function</span> isGood<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>EID<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">src</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;images/&quot;</span><span style="color: #339933;">+</span>EID<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;.gif?id=&quot;</span><span style="color: #339933;">+</span>randomnumber<span style="color: #339933;">;</span>
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>numOfLoaded <span style="color: #339933;">!=</span> totalImages<span style="color: #009900;">&#41;</span> updateLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// This will update the h1 loader tag.</span>
            <span style="color: #003366; font-weight: bold;">function</span> updateLoader<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                numOfLoaded <span style="color: #339933;">=</span> numOfLoaded <span style="color: #339933;">+</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span>
                $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#loader&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replaceWith</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;h1 id=&quot;loader&quot;&gt;Loading Images '</span><span style="color: #339933;">+</span>numOfLoaded<span style="color: #339933;">+</span><span style="color: #3366CC;">' of '</span><span style="color: #339933;">+</span>totalImages<span style="color: #339933;">+</span><span style="color: #3366CC;">'&lt;/h1&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span>
&nbsp;
    $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Run the kickoff update.</span>
        updateDynImg<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// Set the interval to run update.</span>
        setInterval<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;updateDynImg()&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5000</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/lEzKokXjBVQ" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/loading-images-as-they-become-available/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/loading-images-as-they-become-available/</feedburner:origLink></item>
		<item>
		<title>Smurf You! launches to brighten up the week.</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/4p3RgsWrt-w/</link>
		<comments>http://www.neilmpatterson.com/blog/smurf-you-launches-to-brighten-up-the-week/#comments</comments>
		<pubDate>Fri, 20 Nov 2009 01:26:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Projects]]></category>
		<category><![CDATA[Social Networking]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://neilmpatterson.com/?p=44</guid>
		<description><![CDATA[Update: I let my domain expire. It was a fun expieriment, but time for more important things.
Been a long couple weeks for me and several others as we are dealing with some malicious site activity at work. However, Smurf You! is now live and I am very happy with the results.
Smurf You! is a micro <a href="http://www.neilmpatterson.com/blog/smurf-you-launches-to-brighten-up-the-week/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>Update: I let my domain expire. It was a fun expieriment, but time for more important things.</p>
<p>Been a long couple weeks for me and several others as we are dealing with some malicious site activity at work. However, Smurf You! is now live and I am very happy with the results.</p>
<p>Smurf You! is a micro blogging application that allows you to post your status to Twitter through SMS and all kinds of cool gadgets, some still in development. Using the open source micro-blogging service, <a href="">SatusNet</a>, and a javascript written by  <a href="">Adrian Speyer</a>, you can send status updates to your friends and family and translate those into smurf-talk using the translate function.</p>
<p>Just having a bit of fun with it, but eventually I can step through my experience using statusnet and implementing it in a blog series to come.</p>
<p>Enjoy. Now smurf off! <a href=""></a></p>
<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/4p3RgsWrt-w" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/smurf-you-launches-to-brighten-up-the-week/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/smurf-you-launches-to-brighten-up-the-week/</feedburner:origLink></item>
		<item>
		<title>The new www.ORLive.com has launched</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/cdmCkUmDioc/</link>
		<comments>http://www.neilmpatterson.com/blog/orlivecom/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 04:10:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://neilmpatterson.com/?p=24</guid>
		<description><![CDATA[June 1 the company I work for, ORLive, Inc. launched a total site redesign. I played a major role in developing this redesign and to architect the back end. I worked with one other developer and one designer and outsourced about 10-15% of the work to other vendors.
Although the working conditions for this project were <a href="http://www.neilmpatterson.com/blog/orlivecom/" class="more-link">More &#62;</a>]]></description>
			<content:encoded><![CDATA[<p>June 1 the company I work for, <a title="ORLive, Inc." href="http://www.orlive.com">ORLive, Inc</a>. launched a total site redesign. I played a major role in developing this redesign and to architect the back end. I worked with one other developer and one designer and outsourced about 10-15% of the work to other vendors.</p>
<p>Although the working conditions for this project were not ideal and the time line was shorter than we could have wanted, this was probably one of those projects where, if asked in an interview what my greatest challenge and/or accomplishment was&#8230;. this would be it.</p>
<p>Three months total to get a whole new back end in a Content Management System with limited documentation. I am still surprised we did it. Granted it launched minus some key features we intended to make, it was still a success. The design has flaws we are working out. Navigation is a problem. Countless other things need to happen but <a title="ORLive, Inc." href="http://www.orlive.com">www.orlive.com</a> is here and it launched June 1 as planned.</p>
<p>Let me know what you think?</p>
<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/cdmCkUmDioc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/orlivecom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/orlivecom/</feedburner:origLink></item>
		<item>
		<title>Google Wave Is Coming</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/UCZzO0RgR3Q/</link>
		<comments>http://www.neilmpatterson.com/blog/google-wave-is-coming/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 02:12:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Social Networking]]></category>

		<guid isPermaLink="false">http://neilmpatterson.com/?p=7</guid>
		<description><![CDATA[If you are looking for the new wave of social networking, watch this video from Google I/O 2009 conference. It shows a sneak peak at the new innovative communication tool. It will be open source and from the looks it can open up a huge role of possibilities. Very cool stuff.
http://www.youtube.com/watch?v=v_UyVmITiYQ




]]></description>
			<content:encoded><![CDATA[<p>If you are looking for the new wave of social networking, watch this video from Google I/O 2009 conference. It shows a sneak peak at the new innovative communication tool. It will be open source and from the looks it can open up a huge role of possibilities. Very cool stuff.</p>
<p><a title="Google Wave on youtube.com" href="http://www.youtube.com/watch?v=v_UyVmITiYQ" target="_blank">http://www.youtube.com/watch?v=v_UyVmITiYQ</a></p>
<p><!-- end top section --></p>
<div id="watch-this-vid" class="yt-rounded">
<div id="watch-player-div" class="flash-player"></div>
</div>
<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/UCZzO0RgR3Q" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/google-wave-is-coming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/google-wave-is-coming/</feedburner:origLink></item>
		<item>
		<title>Welcome to the site</title>
		<link>http://feedproxy.google.com/~r/Neilmpatterson/~3/JLEwzmi2Vlk/</link>
		<comments>http://www.neilmpatterson.com/blog/hello-world-2/#comments</comments>
		<pubDate>Sun, 14 Jun 2009 05:50:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://neilmpatterson.com/blog/?p=4</guid>
		<description><![CDATA[Welcome to Neilmpatterson.com. More good stuff to come!
]]></description>
			<content:encoded><![CDATA[<p>Welcome to <a href="http://neilmpatterson.com/">Neilmpatterson.com</a>. More good stuff to come!</p>
<img src="http://feeds.feedburner.com/~r/Neilmpatterson/~4/JLEwzmi2Vlk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://www.neilmpatterson.com/blog/hello-world-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://www.neilmpatterson.com/blog/hello-world-2/</feedburner:origLink></item>
	</channel>
</rss>
