<?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>VinylFox &#187; JavaScript</title>
	<atom:link href="http://www.vinylfox.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.vinylfox.com</link>
	<description>The Playground of VinylFox (Shea Frederick)</description>
	<lastBuildDate>Thu, 29 Jul 2010 16:37:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Each Second Counts, or Not</title>
		<link>http://www.vinylfox.com/each-second-counts-or-not/</link>
		<comments>http://www.vinylfox.com/each-second-counts-or-not/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 16:37:06 +0000</pubDate>
		<dc:creator>Shea Frederick</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS Tutorials]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.vinylfox.com/?p=741</guid>
		<description><![CDATA[Every once and a while I glance upon a chunk of code that just screams at me to be optimized. From that point on, all I can do is think about how much faster it would be if I just did this or that. Today I had one of those moments when looking at a [...]]]></description>
			<content:encoded><![CDATA[<p>Every once and a while I glance upon a chunk of code that just screams at me to be optimized. From that point on, all I can do is think about how much faster it would be if I just did this or that. Today I had one of those moments when looking at a co-workers code &#8211; I noticed that they had scoped an <em>each</em> loop that did not use scope (context). This got me wondering if there were any optimizations within the each loop that made it run faster without scope, so I took a look.</p>
<h2>Call &#038; Scope</h2>
<p>So as it turns out, the simple answer is no. The <em>each</em> method uses the <em>call</em> method of the <em>Function</em> constructor to apply scope to the function executed on each pass of the loop. When no scope is provided to the each method, it uses the current item as the scope &#8211; which is kinda strange, but whatever.</p>
<h2>No Scope</h2>
<p>Here is my smart idea &#8211; don&#8217;t use the <em>call</em> method if there is no scope provided. Simple, and it seems like it would help speed things up, so let&#8217;s give it a shot.</p>
<p><textarea class="js" cols="100" name="code">Ext.each = function(array, fn, scope){<br />
    if(Ext.isEmpty(array, true)){<br />
        return;<br />
    }<br />
    if(!Ext.isIterable(array) || Ext.isPrimitive(array)){<br />
        array = [array];<br />
    }<br />
    for(var i = 0, len = array.length; i < len; i++){<br />
        if((scope) ? fn.call(scope, array[i], i, array) : fn(array[i], i, array) === false){<br />
            return i;<br />
        }<br />
    }<br />
};</textarea></p>
<p>The basic change here is on line 9 where I check to see if scope was passed in, and decide to either <em>call </em>the function to apply scope or just execute it directly.</p>
<p><textarea class="js" cols="100" name="code">// original<br />
fn.call(scope || array[i], array[i], i, array)<br />
// my version<br />
(scope) ? fn.call(scope, array[i], i, array) : fn(array[i], i, array)</textarea></p>
<p>Using my current web app as the guinea pig, this version ran between <strong>5-18% faster</strong> in Firefox than it&#8217;s non scope checking predecessor. Internet Explorer&#8217;s results were so far scattered across the board that I could not draw a conclusion &#8211; in some tests 50% faster, in others 350% slower. As usual, IE left me confused, so im just going to ignore that for now.</p>
<h2>Can We Do Better?</h2>
<p>The next thing that caught my eye was the fact that when a single item is passed into the <em>each </em>method, it is shoved into an array and sent through the <em>for </em>loop &#8211; this seemed like a place for improvement.</p>
<p><textarea class="js" cols="100" name="code">Ext.each = function(array, fn, scope){<br />
    if(Ext.isEmpty(array, true)){<br />
        return;<br />
    }<br />
    if (!Ext.isIterable(array) || Ext.isPrimitive(array)) {<br />
	if ((scope) ? fn.call(scope, array, 0, array) : fn(array, 0, array) === false) {<br />
		return 0;<br />
	}<br />
    } else {<br />
	for (var i = 0, len = array.length; i < len; i++) {<br />
		if ((scope) ? fn.call(scope, array[i], i, array) : fn(array[i], i, array) === false) {<br />
			return i;<br />
		}<br />
	}<br />
    }<br />
};</textarea></p>
<p>In this case I have simply taken any single non array item that is passed in and executed the function immediately, bypassing the <em>for </em>loop. Results of this change were not noticeable, and matched almost identically with my previous version. Upon closer inspection, it turns out that this case is never reached, in other words, there is always an array passed in. Go figure.</p>
<h2>Summary</h2>
<p>The moral of the story here is to think simple when trying to optimize code, otherwise we end up going to far into optimizing and actually make the code more complex and likely slower, but this does not mean that the code with the fewest characters or lines will be the quickest. Experimenting is fun, so I would encourage everyone to try things like this just to see how they work and in turn gain a better understanding of how the methods you use every day actually work. Priceless.</p>
<p>Code for these tests can be downloaded from my <a href="http://github.com/VinylFox/ExtJS.ux.Misc">Ext.ux.Misc</a> Git repo on Github.</p>
<p>My next step is to test each loop &#8220;unrolling&#8221; to see what the effect is&#8230;let me know what you have tried on your own, and how it has worked out for you.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinylfox.com/each-second-counts-or-not/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>What&#8217;s the Word &#8211; Meetup Videos and More</title>
		<link>http://www.vinylfox.com/whats-the-word-meetup-videos-and-more/</link>
		<comments>http://www.vinylfox.com/whats-the-word-meetup-videos-and-more/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 17:35:54 +0000</pubDate>
		<dc:creator>Shea Frederick</dc:creator>
				<category><![CDATA[ExtJS News]]></category>
		<category><![CDATA[General News]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[HtmlEditor]]></category>
		<category><![CDATA[JSConf]]></category>
		<category><![CDATA[Meetup]]></category>

		<guid isPermaLink="false">http://www.vinylfox.com/?p=676</guid>
		<description><![CDATA[Every once and a while I like to post a summary of what Ive been up to lately. The past few months have been busy, so I have a ton to talk about, but I will try to summarize. DC Meetup Videos We held the first in a series of meetups that will happen in [...]]]></description>
			<content:encoded><![CDATA[<p>Every once and a while I like to post a summary of what Ive been up to lately. The past few months have been busy, so I have a ton to talk about, but I will try to summarize.</p>
<h1>DC Meetup Videos</h1>
<p>We held the first in a series of <a href="http://www.meetup.com/NoVa-Javascript-Ext-JS-Users-Group/">meetups that will happen in the DC/NoVA</a> area last week, a sprout of our <a href="http://www.meetup.com/baltimore-dc-javascript-users/" target="_blank">Baltimore area Meetup</a> for our southern friends, and I have to say that it was a huge hit. The meetups are going to be managed by Pat Sheridan from <a href="http://threepillarsoftware.com/" target="_blank">Three Pillar Global</a>, and we are hoping it will be a way to get JavaScript developers from the DC area more involved in the community. <a href="http://tdg-i.com/" target="_blank">Jay</a> was kind enough to bring video equipment and record our presentations, along with editing the videos and posting them to the intertubes.</p>
<p><a href="http://tdg-i.com/262/ext-js-meetup-1192010-meetup-videos" title="Jonathan Julian"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/02/2010-01-19_1941-150x150.png" alt="Jonathan Julian" title="Jonathan Julian" width="150" height="150" class="alignnone size-thumbnail wp-image-658" /></a><a href="http://tdg-i.com/262/ext-js-meetup-1192010-meetup-videos" title="Shea Frederick"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/02/extjsmeetup-150x150.jpg" alt="Shea Frederick" title="Shea Frederick" width="150" height="150" class="alignnone size-thumbnail wp-image-659" /></a><a href="http://tdg-i.com/262/ext-js-meetup-1192010-meetup-videos" title="Pat Sheridan"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/02/2010-01-19_1932-150x150.png" alt="Pat Sheridan" title="Pat Sheridan" width="150" height="150" class="alignnone size-thumbnail wp-image-660" /></a></p>
<p>There are some <a href="http://www.meetup.com/baltimore-dc-javascript-users/photos/807828/" target="_blank">photos</a> and other information about the event on its <a href="http://www.meetup.com/baltimore-dc-javascript-users/calendar/12219819/" target="_blank">meetup page</a>.</p>
<p>If you are in the <a href="http://www.meetup.com/baltimore-dc-javascript-users/">Baltimore area and into JavaScript</a> with a fury, you should visit our Meetup that happens the first Wednesday of each month at 6:30PM in the <a href="http://www.beehivebaltimore.com/">Beehive Baltimore</a>. This month&#8217;s meetup has a presentation from <a href="http://paulbarry.com/">Paul Barry</a> about <a href="http://nodejs.org/">Node.js</a> &#8211; it&#8217;s gonna be bad ass.</p>
<h1>Speed Testing</h1>
<p>My little addiction I like to call speed testing has rolled into full swing. Now that I have the tools in place to create and launch tests, along with run reporting on the results with ease, I can pretty much just sit down and spend 30 minutes or so to design and launch the test. <a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/inchworm.jpg"><img src="http://www.vinylfox.com/wp-content/uploads/2010/01/inchworm-150x150.jpg" alt="" title="inchworm" width="150" height="150" class="alignright" style="border: 1px solid rgb(0, 0, 0); margin: 10px 0 0 10px;" /></a> I have two tests currently gathering data, one is testing the speed of rendering an image with and without a data URL, the other has to do with the speed of code wrapped in a try catch statement. Should be some interesting results, which I will be posting a summary on soon. My first test was for <a href="http://www.vinylfox.com/json-decoding-speed-comparison/">JSON decoding speed</a>, which I posted results for a couple of weeks ago.</p>
<h1>HtmlEditor Plugins</h1>
<p>The Ext JS team has expressed an interest in including my <a href="http://code.google.com/p/ext-ux-htmleditor-plugins/" target="_blank">HtmlEditor Plugins</a> as a UX in the SDK. This will mark the third development of mine that has become part of the Ext JS SDK download, first it was the <a href="http://code.google.com/p/ext-ux-gmappanel/" target="_blank">GMapPanel UX</a>, then the Grid Filter backend PHP code, now it seems that the Ext JS SDK will finally come with a more robust HtmlEditor example. A few updates have been committed recently that add the option to change the language in these plugins, along with some general code cleanup. Also starting to move my code over to <a href="http://github.com/VinylFox/ExtJS-HtmlEditor-Plugins">Github</a> as <a href="http://twitter.com/christocracy/status/8593793204">suggested</a> by <a href="http://twitter.com/jonathanjulian/status/8595481114">many</a>.</p>
<h1>Books</h1>
<p>Soon we will have <a href="http://tdg-i.com/" target="_blank">Jay Garcia&#8217;s</a> <a href="http://www.extjsinaction.com" target="_blank">Ext JS in Action</a> book released in print, and the 2nd edition of <a href="http://www.learningextjs.com" target="_blank">Learning Ext JS</a> should be released later this year, titled &#8220;Learning Ext JS 3.0&#8243;. <a href="http://blog.cutterscrossing.com/index.cfm/2010/1/1/Out-With-The-Old-In-With-The-New-2009--2010">Cutter</a>, <a href="http://colinramsay.co.uk/diary/">Colin</a> and I got together to update the book, fix some errors, and add new chapters to take advantage of new features in Ext JS 3.0. It&#8217;s gonna be an awesome resource for anyone just getting started with Ext JS.</p>
<h1>JSConf</h1>
<p>Again, <a href="http://jsconf.us/2010/" target="_blank">JSConf</a> is being held in the DC area, which makes it incredibly cheap for me to attend, but this year I decided to try my hand at submitting a talk proposal. I can&#8217;t wait to find out if I will be chosen. My submission was for an introduction to rapid application prototyping using the Ext JS library. Here is my submission:</p>
<p><textarea class="js" cols="100" name="code">{<br />
    &#8220;name&#8221;:&#8221;Shea Frederick&#8221;,<br />
    &#8220;email&#8221;:&#8221;________@________.com&#8221;,<br />
    &#8220;twitter&#8221;:&#8221;VinylFox&#8221;,<br />
    &#8220;location&#8221;:&#8221;Baltimore, MD&#8221;,<br />
    &#8220;topic_title&#8221;:&#8221;Rapid Web Application Development with Ext JS&#8221;,<br />
    &#8220;topic_description&#8221;:&#8221;Discuss general principles of the Ext JS library<br />
    and show how easy it can be to rapidly prototype a web application<br />
    using the library.&#8221;,<br />
    &#8220;claim_to_fame&#8221;:&#8221;One of the core contributors to the Ext JS library<br />
    along with other Open Source JavaScript projects. Author of<br />
    &#8216;Learning Ext JS&#8217; published in December 2008. Observed &#8216;Talk Like<br />
    a Pirate Day&#8217;. Maintain a Blog of JavaScript fun at<br />
    http://www.vinylfox.com&#8221;<br />
}</textarea></p>
<p>Did I mention that all submissions have to be in the form of valid JSON? Yeah, geeky, but good &#8211; very good. With any luck, I will <a href="http://jsconf.posterous.com/the-soon-to-be-awkward-moment">find out later this week</a> if ive been accepted.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinylfox.com/whats-the-word-meetup-videos-and-more/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JSON Decoding Speed Comparison</title>
		<link>http://www.vinylfox.com/json-decoding-speed-comparison/</link>
		<comments>http://www.vinylfox.com/json-decoding-speed-comparison/#comments</comments>
		<pubDate>Tue, 12 Jan 2010 14:09:31 +0000</pubDate>
		<dc:creator>Shea Frederick</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.vinylfox.com/?p=602</guid>
		<description><![CDATA[Meet Karl &#8211; Karl is a very cute wind up Inchworm that my wife put in my stocking for x-mas. What does Karl have to do with JSON? Probably nothing, but he is very photogenic, and I like having a picture in my blog posts. Now that our new buddy Karl has been properly introduced, [...]]]></description>
			<content:encoded><![CDATA[<p><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/inchworm.jpg"><img src="http://www.vinylfox.com/wp-content/uploads/2010/01/inchworm-150x150.jpg" alt="" title="inchworm" width="150" height="150" class="alignleft" style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" /></a>Meet Karl &#8211; Karl is a very cute wind up Inchworm that my wife put in my stocking for x-mas. What does Karl have to do with JSON? Probably nothing, but he is very photogenic, and I like having a picture in my blog posts.</p>
<p>Now that our new buddy Karl has been properly introduced, lets move on to the boring stuff. I have been trying to optimize decoding of a large chunk of JSON data by testing decoding speeds between the three main methods of decoding JSON and how that applied to the type of data that was being decoded, along with the environment, ie: the browser. My data has been gathering for over a month now, and has run on 3500 unique clients, so I feel like I can come to a decent conclusion.</p>
<h2>The Decoded Data</h2>
<p>I figured for my testing purposes that there were five main types of data that would be commonly decoded.</p>
<ul>
<li>Empty Array</li>
<li>Empty Object</li>
<li>Array Data Only</li>
<li>Object Data Only</li>
<li>Mixed Array and Object Data</li>
</ul>
<h2>The Decoding Methods</h2>
<p>Generally speaking, you will find three methods of decoding JSON used in the wild, though <em>eval </em>is by far the most common. I am not using any decoding/encoding libraries because I don&#8217;t want to taint the results with any browser targeted workarounds that might be present in them, I just want to know what the actual browser does.</p>
<p><textarea class="js" cols="100" name="code">o = eval( &#8220;(&#8221; + testData + &#8220;)&#8221; );</textarea></p>
<p><b>eval</b> &#8211; This is the old standard for decoding JSON, which is considered dangerous to use because of its ability to create functions.</p>
<p><textarea class="js" cols="100" name="code">o = JSON.parse( testData );</textarea></p>
<p><b>native</b> &#8211; The latest and greatest method of decoding JSON, recent browsers include this built in feature. The &#8216;safe&#8217; way to decode data.</p>
<p><textarea class="js" cols="100" name="code">o = new Function( &#8220;return &#8221; + testData )();</textarea></p>
<p><b>new function</b> &#8211; This method is essentially the same as eval, but uses the evaluating mechanism of the Function constructor to decode data.</p>
<h2>In The Wild</h2>
<p>I wanted my testing to represent actual usage in the wild, so I used a tool that allowed my tests to run in the browsers of unsuspecting internet surfers. So the results I have can be considered an accurate depiction of what will actually be encountered on the intertubes. If you&#8217;re creating intranet sites targeted to a particular browser, then these results should be interpreted differently. Any browser that cannot handle all three methods of decoding JSON was not included in the test, so you IE6/7 guys are out of luck. Also, any browser that has an active console (console object present) was excluded.</p>
<h2>The Outcome</h2>
<p>The results are quite interesting, and confusing in some cases. Im guessing there is room for some browsers to optimize their JSON decoding routines here. This first chart shows results grouped by browser make.</p>
<p><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-test-results3.gif"><img src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-test-results3.gif" alt="" title="json-test-results" width="546" height="420" class="alignnone size-full wp-image-620" style="position: relative; left: -65px;"/></a></p>
<p>This is all good and fine if your a browser vendor and want to know how you&#8217;re browser stacks up against others, but in web development we don&#8217;t have the option of picking our clients browser. What we want to see is what programming techniques we can use to take advantage of browser efficiency across the board. Which leads us to the next chart, showing results grouped by decoding method</p>
<p><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-test-results21.gif"><img src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-test-results21.gif" alt="" title="json-test-results2" width="546" height="333" class="alignnone size-full wp-image-621" style="position: relative; left: -65px;"/></a></p>
<p>That&#8217;s more like it, I now have a clearer idea of how the methods themselves stack up against each other, the red line indicates the average of all the data types.</p>
<h2>The Conclusion</h2>
<p>Even though the results seem to indicate that <em>native </em>JSON decoding is only mildly faster than <em>eval</em>, its actually a bit faster if you exclude the strange handling of empty <em>objects </em>in <a href="http://www.mozilla.com/firefox/" target="_blank">Firefox</a>. For the purpose of choosing a method, I think we can draw the conclusion that <em>native </em>JSON decoding is the clear winner here, followed closely by <em>eval</em>, and the <em>function constructor</em> being a general bad idea.</p>
<p>Comparing the browsers for <em>native </em>decoding, <a href="http://www.apple.com/safari/" target="_blank">Safari</a> is a clear winner here, with our new buddy <a href="http://www.google.com/chrome" target="_blank">Chrome</a> losing the race by quite a lot.</p>
<h2>Quirks</h2>
<p>By far the biggest quirk is <a href="http://www.mozilla.com/firefox/" target="_blank">Firefox</a>&#8216;s slowness in decoding an empty <em>Object </em><em>natively</em>, which skews the results, making it appear that <em>native </em>JSON decoding is only mildly faster than <em>eval</em>.</p>
<p>Another interesting result was decoding using <em>eval </em>ran 500% slower with <a href="http://getfirebug.com/" target="_blank">FireBug</a> enabled, while <em>native </em>decoding suffered no degradation at all when <a href="http://getfirebug.com/" target="_blank">FireBug</a> was enabled.</p>
<p><a href="http://www.apple.com/safari/" target="_blank">Safari</a> apparently does not handle the <em>function constructor</em> very efficiently.</p>
<p>As a general rule of thumb the straight <em>array </em>data decoded the slowest, so when considering system design, <em>array </em>data should only be used when there is a clear benefit to it.</p>
<h2>Feedback</h2>
<p>If there are any particular ways you would like to see the data broken out, just let me know in the comments and ill see what I can do.</p>
<p><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-firefox.gif" title="Firefox 3.1 &#038; up"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-firefox-150x150.gif" alt="Firefox 3.1 &#038; up" title="Firefox 3.1 &#038; up" width="150" height="150" class="alignnone size-thumbnail wp-image-658" /></a><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-chrome.gif" title="Chrome"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-chrome-150x150.gif" alt="Chrome" title="Chrome" width="150" height="150" class="alignnone size-thumbnail wp-image-659" /></a><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-msie.gif" title="MSIE 8"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-msie-150x150.gif" alt="MSIE 8" title="MSIE 8" width="150" height="150" class="alignnone size-thumbnail wp-image-660" /></a><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-safari.gif" title="Safari"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-safari-150x150.gif" alt="Safari" title="Safari" width="150" height="150" class="alignnone size-thumbnail wp-image-661" /></a><a class="lightbox" href="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-all.gif" title="Combined"><img style="border: 1px solid rgb(0, 0, 0); margin: 0 10px 10px 0;" src="http://www.vinylfox.com/wp-content/uploads/2010/01/json-result-all-150x150.gif" alt="Combined" title="Combined" width="150" height="150" class="alignnone size-thumbnail wp-image-662" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinylfox.com/json-decoding-speed-comparison/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Three Pillars, Four Geeks and Ext JS</title>
		<link>http://www.vinylfox.com/three-pillars-four-geeks-and-ext-js/</link>
		<comments>http://www.vinylfox.com/three-pillars-four-geeks-and-ext-js/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 17:54:01 +0000</pubDate>
		<dc:creator>Shea Frederick</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS News]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.vinylfox.com/?p=611</guid>
		<description><![CDATA[I will be presenting along side some other Ext JS geeks at this quarters Three Pillar Tech Meetup. The following is a summary of the event details posted on the Three Pillar News Blog and Jay Garcia&#8217;s Blog. Hope to see you there! At 6:30PM on 1/19/2010, Three Pillar Global will be hosting a gathering [...]]]></description>
			<content:encoded><![CDATA[<p>I will be presenting along side some other Ext JS geeks at this quarters Three Pillar Tech Meetup. The following is a summary of the event details posted on the <a href="http://threepillarglobal.com/three-pillar-global-tech-meetup-january-19-2010" target="_blank">Three Pillar News Blog</a> and <a href="http://tdg-i.com/219/three-pillar-global-plays-host-to-an-extjs-gathering" target="_blank">Jay Garcia&#8217;s Blog</a>. Hope to see you there!</p>
<p>At 6:30PM on 1/19/2010, Three Pillar Global will be <a href="http://www.meetup.com/baltimore-dc-javascript-users/calendar/12219819/" target="_blank">hosting a gathering</a> of industry leading minds in the metro DC area to discuss and share development practices, ideas, tips and tricks revolving around the Ext JS framework. There will be four presentations that are jam-packed with information that can aid to your success in developing applications with the Ext JS framework</p>
<h2>About the presentations:</h2>
<p>Patrick Sheridan will kick off the meeting, where he will explain how analysis-driven development can aid in the success of your application construction, reducing time from conception to production. Shea Frederick will be guiding us through advanced JavaScript debugging techniques, demonstrating some of the best tricks for the latest and greatest JavaScript development tools. Jonathan Julian is going to share and elaborate on five areas to improve your Ext JS applications, which range from defining your own components to properly overriding the framework. Lastly, Jay Garcia will discuss how to build extensible applications using a two-tiered approach with Ext JS.</p>
<p>Food and refreshments to be provided. We look forward to <a href="http://www.meetup.com/baltimore-dc-javascript-users/calendar/12219819/" target="_blank">seeing you there</a>!</p>
<h2>About the presenters:</h2>
<p><img class="borderimg" style="margin: 15px 15px 0 0;" width="75" height="75" align="left" src="http://www.extjs.com/forum/image.php?u=3054&amp;dateline=1247548690" alt="" /> Pat Sheridan is a successful Ext JS developer that leverages his user experience background to accelerate successful development with RIA JavaScript frameworks, including Ext JS.  With success stories such as the complete rewrite of the U.S. Treasury&#8217;s Pay.gov website and the production of four large RIA applications for the Financial Regulatory Authority (FINRA), he continues to dominate this space with a progressive thought process that enhances the development and user experience alike.  He demonstrated his UX leadership with the release of an <a href="http://www.extjs.com/forum/showthread.php?t=31514" target="_blank">Ext JS 2.0 OmniGraffle template</a> that has garnered over 50,000 downloads world wide.</p>
<p><img class="borderimg" style="margin: 15px 15px 0 0;" width="75" height="75" align="left" src="http://www.vinylfox.com/wp-content/uploads/2008/09/newyork-288x300.jpg" alt="" />Shea Frederick is an active community member for ExtJS.  His expertise is drawn from community forum participation, work with the core development team, and his own experience as the architect of several large ExtJS-based web applications.   Shea is also an author for <a href="http://jsmag.com" target="_blank">JavaScript</a> Magazine, his own blog (<a href="http://vinylfox.com">http://vinylfox.com</a>), and the <a href="http://www.extjs.com/blog/2008/07/21/using-yahoos-boss-api-to-search-the-web/" target="_blank">Ext JS blog.</a>  He is the lead author of the <a href="http://learningextjs.com" target="_blank">Learning Ext JS</a> book and is the organizer for the <a href="http://www.meetup.com/baltimore-dc-javascript-users/" target="_blank">Baltimore JavaScript developers</a> meetup group. </p>
<p><img class="borderimg" style="margin: 15px 15px 0 0;" width="75" height="75" align="left" src="http://www.gravatar.com/avatar/519e2fdbde9ac0662f8c82438e3b4d6c?s=75" alt="" />While not very well known in the Ext JS community, Jonathan Julian is successful independent web developer specializing in Rails and Ext JS applications with extensive experience in Java and related technologies. He occasionally blogs about software and web  development at <a href="http://jonathanjulian.com/" target="_blank">jonathanjulian.com</a> and tweets as @jonathanjulian.  He has presented at the <a href="http://www.meetup.com/baltimore-dc-javascript-users/" target="_blank">Baltimore JavaScript developers</a> meetup group. </p>
<p><img class="borderimg" style="margin: 15px 15px 0 0;" width="75" height="75" align="left" src="http://media.linkedin.com/mpr/mpr/shrink_80_80/p/1/000/012/3f1/1719f93.jpg" alt="" />Jay Garcia, author of the up and coming book, Ext JS in Action (<a href="http://extjsinaction.com/" target="_blank">http://extjsinaction.com/</a>), provides daily support on the Ext JS forums as well as free extensions and widgets to the library.  He is an author for  <a href="http://tdg-i.com/213/november-2009-js-magazine-now-available" target="_blank">JSMagazine</a>, the <a href="http://www.extjs.com/blog/2009/09/13/5-steps-drag-and-drop-with-ext-js/" target="_blank">Ext JS blog</a> and his own blog at <a href="http://tdg-i.com" target="_blank">http://tdg-i.com</a>.  He&#8217;s developed enterprise-level applications using Ext JS since early 2006, when it was known as &#8220;yui-ext&#8221; and has continued to support and assist in the expansion of the product ever since.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinylfox.com/three-pillars-four-geeks-and-ext-js/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Forwarding Mouse Events Through Layers</title>
		<link>http://www.vinylfox.com/forwarding-mouse-events-through-layers/</link>
		<comments>http://www.vinylfox.com/forwarding-mouse-events-through-layers/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 15:05:46 +0000</pubDate>
		<dc:creator>Shea Frederick</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS Plugins]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ExtJS Overrides]]></category>

		<guid isPermaLink="false">http://www.vinylfox.com/?p=499</guid>
		<description><![CDATA[Anyone who has worked with web apps has likely created a masking element at some point, and the great thing about a masking element is that it intercepts user interaction, letting us create a pseudo-modal user interface. The masking element enables us to mask the entire screen, bringing focus to a particular element, or just [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who has worked with web apps has likely created a masking element at some point, and the great thing about a masking element is that it intercepts user interaction, letting us create a pseudo-modal user interface. The masking element enables us to mask the entire screen, bringing focus to a particular element, or just create a window like effect. This behavior is demonstrated in the ExtJS libraries <em>Ext.Window</em> when <em>modal </em>is set to true, among other places.</p>
<h3>Yeah, so what?</h3>
<p><img src="http://www.vinylfox.com/wp-content/uploads/2009/09/layers-masked1.png" alt="layers-masked1" title="layers-masked1" width="250" height="163" class="alignright size-full wp-image-543" />The problem comes when we want to mask a part of the screen, but also want the elements behind that mask to continue responding to user interaction. This behavior is counter to most native behavior. What we are left with, is having to forward mouse events through the masking layer to the layer below, an option that simply does not exist in the standard JavaScript/DOM API.</p>
<h3>Why do this?</h3>
<p>A plugin that I recently wrote &#8211; <a href="http://code.google.com/p/ext-ux-datadrop/" target="_blank">DataDrop </a>- used a <em>textarea </em>overlaying a grid to act as the receiver of dragged data from spreadsheet type programs. One of the limitations that I was not so happy about was the fact that this overlay could only exist in the &#8216;empty&#8217; area of the grid, not over rows of data, headers, toolbars, etc. otherwise it would cause all of those elements below to become unresponsive to user input. If our <em>textarea</em> that receives the data were positioned over the entire grid area, our <em>GridPanel</em> could not be controlled using the mouse anymore.</p>
<h3>How to fix this?</h3>
<p>This is where my friend Nige White (Animal) came in to help, it turns out that he had an idea about how to forward these mouse events using a couple of not well understood methods in the JavaScript/DOM API used for creating mouse events. Here are the steps taken:</p>
<ol>
<li>The <em>textarea </em> (my masking element) that is positioned over the grid receives <em>mouseover</em>, <em>mousemove</em>, <em>mousedown </em>, <em>mouseup </em> and other events.</li>
<li>The top masking layer is hidden for a moment, so we can figure out what element is below the mask at the event location.</li>
<li>The event is re-fired &#8211; this is where the <a href="http://www.w3.org/TR/DOM-Level-2-Events/ecma-script-binding.html" target="_blank">W3 DOM Event model</a> and the simpler <a href="http://msdn.microsoft.com/en-us/library/ms536423(VS.85).aspx" target="_blank">Microsoft equivalent</a> come into play.</li>
<li>Start the process again &#8211; ready for the next event.</li>
</ol>
<p><img src="http://www.vinylfox.com/wp-content/uploads/2009/09/layers-steps1.png" alt="layers-steps1" title="layers-steps1" width="500" height="326" class="alignright size-full wp-image-557" /></p>
<h3>What&#8217;s element to fire upon?</h3>
<p>Knowing the cursor position and event that occurred, the only obstacle now is determining what DOM element to fire the simulated event through. It turns out that finding which element is the topmost element at a certain document coordinate position is quite simple in modern browsers. The <b>document.elementFromPoint</b> method is supported in <a href="http://msdn.microsoft.com/en-us/library/ms536417(VS.85).aspx" target="_blank">IE</a>, <a href="https://developer.mozilla.org/en/DOM/document.elementFromPoint" target="_blank">Mozilla</a>, Webkit and Opera.</p>
<p>So it is possible to capture the document coordinates of a mouse event fired on the masking element, momentarily hide that masking element, and then ask the document what is under that coordinate position before showing the mask again.</p>
<p>A new event can be then fired on the found element. Obviously there are some complexities such as firing <em>mouseover </em>and <em>mouseout </em>events when the found element is different from the last time, but that is the gist of the technique. To <a href="http://screencast.com/t/4bZevAUwEuj" target="_blank">see it in action, check out the screencast</a> or play with the <a href="http://www.vinylfox.com/lib/latest/examples/grid/array-grid-datadrop.html" target="_blank">live Grid DataDrop example</a> or <a href="http://www.vinylfox.com/lib/latest/examples/core/evt-forwarding.html" target="_blank">simple DOM element example</a> yourself.</p>
<p>I have posted an <a href="http://code.google.com/p/ext-ux-datadrop/source/browse/trunk/src/Override.js"target="_blank">override of Ext.Element that Nigel created</a> on my Google Code site for all to enjoy, it is now a requirement for the ExtJS <a href="http://code.google.com/p/ext-ux-datadrop/"target="_blank">DataDrop plugin</a>. A big thanks goes out to Nige (Animal) for digging into the nuts and bolts of JavaScript to find a solution to my problem.</p>
<h3>The Next Step</h3>
<p>Having the data that is dropped into the grid automatically insert into the grids rows at the correct position is my next task for the ever-improving <a href="http://code.google.com/p/ext-ux-datadrop/"target="_blank">DataDrop plugin</a>. Should be fun :/</p>
<p>UPDATE (12-1-09): Seems that <a href="http://hacks.mozilla.org/2009/12/pointer-events-for-html-in-firefox-3-6/">Mozilla has also noticed this issue</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinylfox.com/forwarding-mouse-events-through-layers/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Some Common ExtJS Error Messages Explained</title>
		<link>http://www.vinylfox.com/some-common-extjs-error-messages-explained/</link>
		<comments>http://www.vinylfox.com/some-common-extjs-error-messages-explained/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 13:05:18 +0000</pubDate>
		<dc:creator>Shea Frederick</dc:creator>
				<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[ExtJS Tutorials]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.vinylfox.com/?p=434</guid>
		<description><![CDATA[Its Monday morning, and it truly feels like it today. My coffee is not even finished yet, and I already found myself making a dumb mistake and spending too much time troubleshooting it, so I thought I would share with you a few common errors that we might run across when writing ExtJS applications. With [...]]]></description>
			<content:encoded><![CDATA[<p>Its Monday morning, and it truly feels like it today. My coffee is not even finished yet, and I already found myself making a dumb mistake and spending too much time troubleshooting it, so I thought I would share with you a few common errors that we might run across when writing ExtJS applications. With any luck, these will stick to the inside of your cranium &#8211; and hopefully mine as well.</p>
<h2>this.config[col] is undefined</h2>
<p>The <i>autoExpandColumn</i> feature of the ColumnModel accepts an &#8216;id&#8217; as the argument, this &#8216;id&#8217; needs to match the &#8216;id&#8217; given to the Column configuration. </p>
<p><textarea class="js" cols="100" name="code">{<br />
	columns: [{<br />
		id: 'not_so_super_column_id',  // column id defined<br />
		header: 'Super Duper',<br />
		dataIndex: 'superduper'<br />
	}],<br />
	&#8230;,<br />
	autoExpandColumn: &#8216;super_duper_column_id&#8217;  // wrong column id used &#8211; fail!<br />
}</textarea></p>
<p>Another thing to keep in mind, is that while it works sometimes, the value for <em>autoExpandColumn </em>should NOT be a column index &#8211; the id of the column should always be used.</p>
<h2>types[config.xtype || defaultType] is not a constructor (b[d.xtype || e] is not a constructor)</h2>
<p>This happens when trying to instantiate (create) a component that does not exist, the most common reason is a typo or spelling error. For instance, using &#8216;gridpanel&#8217; as the xtype instead of &#8216;grid&#8217; &#8211; which is a mistake I make often myself. Sometimes we can forget a level of namespacing, like using <em>Ext.FormPanel</em> instead of the proper <em>Ext.form.FormPanel</em>.</p>
<p><textarea class="js" cols="100" name="code">{<br />
	xtype: &#8216;formpanel&#8217;  // fail<br />
},{<br />
	xtype: &#8216;form&#8217;  // win!<br />
}</textarea></p>
<p>Another one I always run into is typing &#8216;combobox&#8217; instead of the correct &#8216;combo&#8217; for the xtype &#8211; a list of xtypes can be found in the <a href="http://www.extjs.com/deploy/dev/docs/?class=Ext.Component">ExtJS documentation under Ext.Component</a>.</p>
<h2>this.addEvents is not a function</h2>
<p>This is not a <em>new </em>problem (you like that pun?) but unfortunately the error message sends us off in the wrong direction. When this message appears it sounds like its an event related problem, but what it simply means is that we have forgotten to preface a constructor with the &#8216;new&#8217; operator.</p>
<p><textarea class="js" cols="100" name="code">Ext.form.TextField({}); // fail<br />
new Ext.form.TextField({}); // win!</textarea></p>
<h2>el is null</h2>
<p>So with this one, its a little easier to figure out what went wrong just from the error message. In shorthand variable naming, a couple of letters are picked out of a longer word that phonetically make sense, and do not spell something else or sound like other commonly used words. So in this case &#8216;el&#8217; is short for <strong>EL</strong>ement. As the error message says &#8216;el is null&#8217;, which if we translate from geek speak to English it says &#8216;html  element does not exist&#8217;.</p>
<p><textarea class="js" cols="100" name="code"></p>
<div id="sweet_dude"></div>
<p>new Ext.Button({<br />
	text: &#8216;Clicky&#8217;,<br />
	renderTo: &#8216;dude_sweet&#8217; // does not match the id!<br />
});</textarea></p>
<h2>f.convert is not a function</h2>
<p>This one is not so common, but still happens every once and a while. It means that your data reader was trying to read the data you passed to your store with a particular data type that did not exist. Thats allot to take in, so lets take a look at this example.</p>
<p><textarea class="js" cols="100" name="code">var myStore = new Ext.data.ArrayStore({<br />
	fields: [{<br />
		name:'fullname',<br />
		type:'badass'<br />
	}, {<br />
		name:'first',<br />
		type:'string'<br />
	}]<br />
});</textarea></p>
<p>In this example the &#8216;fullname&#8217; column has a datatype of &#8216;badass&#8217;, which does not exist. On the flip side, the datatype for &#8216;first&#8217; of &#8216;string&#8217; does exist.</p>
<h2>Summary</h2>
<p>Now if we can just keep these in our memory, we might be able to have a productive day  -or just drink more coffee and see how that pans out.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.vinylfox.com/some-common-extjs-error-messages-explained/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
