<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>Official AzroTech Blog</title>
	<atom:link href="http://www.azrotech.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.azrotech.com/blog</link>
	<description>A glimpse into the world of AzroTech's development and technology</description>
	<lastBuildDate>Wed, 20 Jun 2007 01:07:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to emulate namespaces in Javascript</title>
		<link>http://www.azrotech.com/blog/2007/06/19/how-to-emulate-namespaces-in-javascript/</link>
		<comments>http://www.azrotech.com/blog/2007/06/19/how-to-emulate-namespaces-in-javascript/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 23:34:12 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/19/how-to-emulate-namespaces-in-javascript/</guid>
		<description><![CDATA[A common problem when coding very large Javascript applications is that the global namespace gets polluted, which causes the programmer to name their functions and variables something they don&#8217;t want to name them (just for the sake of uniqueness).  If Javascript had namespacing and classes, we wouldn&#8217;t have this problem. Good news, there is [...]]]></description>
			<content:encoded><![CDATA[<p>A common problem when coding very large Javascript applications is that the global namespace gets polluted, which causes the programmer to name their functions and variables something they don&#8217;t want to name them (just for the sake of uniqueness).  If Javascript had namespacing and classes, we wouldn&#8217;t have this problem. Good news, there is a solution to allow for classes and namespacing it goes a little like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> az <span style="color: #339933;">=</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> variable1 <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;test&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #003366; font-weight: bold;">var</span> variable2 <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;test2&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">function</span> testFunc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>variable1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
        init <span style="color: #339933;">:</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>
            testFunc<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">testFunc2</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
        testFunc2 <span style="color: #339933;">:</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: #000066;">alert</span><span style="color: #009900;">&#40;</span>variable2<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: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
az.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Let&#8217;s take a look at this in more detail!</p>
<p>You&#8217;ll notice that we have <code>variable1</code> and <code>variable2</code>. These variables can be thought of as <em>private</em> variables. Additionally, <code>testFunc</code> can be thought of as a private function.</p>
<p>Any of the code that lives within the <code>return</code> block can be thought of as public. These are the only functions that may be called externally. If you are calling a public function within the class, you must either put the full path to it (ex: <code>az.testFunc2()</code>) or prepend it with <code>this</code> (ex: <code>this.testFunc2()</code>).</p>
<p>So now you have a good example of how to represent a class in Javascript. But let&#8217;s take this a step further and emulate namespacing as well.</p>
<p>Let&#8217;s say we had the code above in addition to this code below:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> az.<span style="color: #660066;">util</span> <span style="color: #339933;">=</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: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>        
        gebi <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">return</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span>obj<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: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now we can call <code>az.util.gebi('id_to_get_element_of')</code>. </p>
<p>You can keep adding level after level to the namespacing so that you might have something like <code>az.util.date.convert.toSql()</code>.</p>
<p>Using this technique is great because you do not junk up your global namespace and you can organize your code very well.  In fact, each different &#8220;class&#8221; can live in its own file and you can create a mechanism to import the files as you need them (dramatically improving load time).</p>
<p><strong style="color:red">An interesting note:</strong> You may notice on the examples that there is not a line break between <code>return</code> and the opening brace. Adding a line break will cause the code to break (who knows why?!). Therefore, you will have to keep the opening brace on the same line as the return.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azrotech.com/blog/2007/06/19/how-to-emulate-namespaces-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamic Dojo Tooltips</title>
		<link>http://www.azrotech.com/blog/2007/06/19/dynamic-dojo-tooltips/</link>
		<comments>http://www.azrotech.com/blog/2007/06/19/dynamic-dojo-tooltips/#comments</comments>
		<pubDate>Tue, 19 Jun 2007 23:02:13 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[Dojo]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/19/dynamic-dojo-tooltips/</guid>
		<description><![CDATA[While messing with the dojo tooltip widget in one of our applications, I had the need to dynamically create a widget.  Below is a sample statement of dynamically creating a tooltip widget.

dojo.widget.createWidget&#40;'tooltip', 
	&#123; 
	caption: 'what you want the tooltip to say', 
	connectId: 'target_id_to_attach_tooltip' 
	&#125;&#41;;

However, this is not complete because we need to attach it [...]]]></description>
			<content:encoded><![CDATA[<p>While messing with the dojo tooltip widget in one of our applications, I had the need to dynamically create a widget.  Below is a sample statement of dynamically creating a tooltip widget.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">dojo.<span style="color: #660066;">widget</span>.<span style="color: #660066;">createWidget</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tooltip'</span><span style="color: #339933;">,</span> 
	<span style="color: #009900;">&#123;</span> 
	caption<span style="color: #339933;">:</span> <span style="color: #3366CC;">'what you want the tooltip to say'</span><span style="color: #339933;">,</span> 
	connectId<span style="color: #339933;">:</span> <span style="color: #3366CC;">'target_id_to_attach_tooltip'</span> 
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>However, this is not complete because we need to attach it to the body of the document like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> new_tooltip <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">widget</span>.<span style="color: #660066;">createWidget</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tooltip'</span><span style="color: #339933;">,</span>
	<span style="color: #009900;">&#123;</span> 
	caption<span style="color: #339933;">:</span> <span style="color: #3366CC;">'what you want the tooltip to say'</span><span style="color: #339933;">,</span> 
	connectId<span style="color: #339933;">:</span> <span style="color: #3366CC;">'target_id_to_attach_tooltip'</span> 
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
document.<span style="color: #660066;">body</span>.<span style="color: #660066;">attachChild</span><span style="color: #009900;">&#40;</span>new_tooltip.<span style="color: #660066;">domNode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>You&#8217;ll notice that the return value of <code>dojo.widget.createWidget</code> is an object and when we attach it to the body of the document, we use the <code>domNode</code> property of that object.</p>
<p>There is one more potential problem with dynamically creating these widgets. Let&#8217;s say that we have a dynamic table and each row of the table contains the target id for each tooltip. If the table gets reloaded with new data (rows have new ids), the old tooltips remain appended to the body. No big deal of you don&#8217;t mind a little trash left behind, but the problem comes into play when you load data back into that dynamic table that may have previously existed and generate a whole new set of tooltips to go along with it. Now you may have two or more of the same tooltip appended to the body that belong to the same target id. Some browsers might be fine with this and some might choke. To prevent these duplicates, we use the following code for each new tooltip widget that is created:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> createTooltip<span style="color: #009900;">&#40;</span>target_id<span style="color: #339933;">,</span> content<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//prepending 'tt_' to distinguish between target and tooltip id's</span>
	<span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tt_'</span><span style="color: #339933;">+</span>target_id<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>obj <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		obj.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span>obj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> tooltip <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">widget</span>.<span style="color: #660066;">createWidget</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'tooltip'</span><span style="color: #339933;">,</span> 
		<span style="color: #009900;">&#123;</span> 
		caption<span style="color: #339933;">:</span> content<span style="color: #339933;">,</span> 
		connectId<span style="color: #339933;">:</span> target_id 
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	tooltip.<span style="color: #660066;">domNode</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'tt_'</span><span style="color: #339933;">+</span>target_id<span style="color: #339933;">;</span>
	document.<span style="color: #660066;">body</span>.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span>tooltip.<span style="color: #660066;">domNode</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></div></div>

<p>You might notice that we are actually adding an ID to the tooltip. This allows us to check in the future if that tooltip has already been created. If it has, the code above will destroy it and create a new tooltip in its place.  This should assist those searching for answers about dynamically creating dojo tooltip widgets.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azrotech.com/blog/2007/06/19/dynamic-dojo-tooltips/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Apple, you beautiful company</title>
		<link>http://www.azrotech.com/blog/2007/06/12/apple-you-beautiful-company/</link>
		<comments>http://www.azrotech.com/blog/2007/06/12/apple-you-beautiful-company/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 07:51:48 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[News]]></category>
		<category><![CDATA[Web Standards]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/12/apple-you-beautiful-company/</guid>
		<description><![CDATA[Apple has done it again. They seem to be on a non-stop war path to take over every aspect of computing and make it just a little bit cooler.  This time, they are diving straight into the browser war with the release Safari 3 for Windows.  I have been using it all day [...]]]></description>
			<content:encoded><![CDATA[<p>Apple has done it again. They seem to be on a non-stop war path to take over every aspect of computing and make it just a little bit cooler.  This time, they are diving straight into the browser war with the release <a href="http://www.apple.com/safari">Safari 3 for Windows</a>.  I have been using it all day and am wowed at the correctness of its rendering.  It even passed the <a href="http://www.webstandards.org/action/acid2/">Acid2 Test</a> with flying colors.</p>
<p>The Acid2 Test was developed by the <a href="http://www.webstandards.org/">Web Standards Project</a> as a means to help vendors test their browsers so that they are compliant with Web Standards.  For a good laugh, try the Acid2 test with IE6 or IE7 (either one, they both render it terribly).</p>
<p>Also, Steve Jobs showed off the upcoming <a href="http://www.apple.com/macosx/leopard/">Mac OS 10.5 (Leopard)</a> at the WWDC and it looks absolutely incredible.  I need not explain it here, just check out the link and prepare to be amazed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azrotech.com/blog/2007/06/12/apple-you-beautiful-company/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Technological Brew</title>
		<link>http://www.azrotech.com/blog/2007/06/12/technological-brew/</link>
		<comments>http://www.azrotech.com/blog/2007/06/12/technological-brew/#comments</comments>
		<pubDate>Tue, 12 Jun 2007 07:37:52 +0000</pubDate>
		<dc:creator>rgillette</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Misc]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://www.azrotech.com/blog/2007/06/12/technological-brew/</guid>
		<description><![CDATA[So it&#8217;s been awhile since the last post and you may or may not be curious as to what the tech-savvy folks at AzroTech have been up to.
One of the key focuses of our research has been making the switch from PHP to one of the cool new Web 2.0 frameworks/languages for all of our [...]]]></description>
			<content:encoded><![CDATA[<p>So it&#8217;s been awhile since the last post and you may or may not be curious as to what the tech-savvy folks at AzroTech have been up to.</p>
<p>One of the key focuses of our research has been making the switch from PHP to one of the cool new Web 2.0 frameworks/languages for all of our future (and top secret) web apps.  The two contenders are <a href="http://www.djangoproject.com">Django</a> (Python-based) and <a href="http://www.rubyonrails.org">Ruby on Rails</a> (Ruby-based {as you might have assumed&#8230;}).  We are still torn, but a decision will be reached quite soon.</p>
<p>Also, we have been hard at work developing a new Javascript framework to clean up many of the namespace polluting functions that we already have.  Yes, we are ashamed it took this long, but at least we are making the leap.</p>
<p>Aside from the all of the projects we are working on for our many happy and wonderful clients, we have begun strategizing a fresh new AzroTech Update.  It is going to be even more amazingly simple to use and will also allow for portability.  That means you can still enjoy the benefits of AZ Update even if you don&#8217;t host with us.</p>
<p>Finally, do yourself a favor and add the AzroTech blog to your RSS aggregator.  We are launching a new initiative to blog every day with updates and technical issues we run into while doing what we do.  We will include topics from database development, new technologies, C#, PHP, Ruby, Python, CSS, and web standards. Tune in and enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azrotech.com/blog/2007/06/12/technological-brew/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
