<?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>uxebu » blog &#187; dojo</title>
	<atom:link href="http://uxebu.com/tag/dojo/feed/" rel="self" type="application/rss+xml" />
	<link>http://uxebu.com/blog</link>
	<description></description>
	<lastBuildDate>Mon, 23 Apr 2012 19:10:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>EmbedJS 0.2 and AMD</title>
		<link>http://uxebu.com/blog/2011/10/17/embedjs-0-2-and-amd/</link>
		<comments>http://uxebu.com/blog/2011/10/17/embedjs-0-2-and-amd/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 15:43:16 +0000</pubDate>
		<dc:creator>Jens Arps</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[html5apps]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[embedjs]]></category>

		<guid isPermaLink="false">http://uxebu.com/blog/?p=1843</guid>
		<description><![CDATA[During JSConf.eu, we released EmbedJS 0.2. That release was mainly about a fundamental architectural change: the move to the AMD pattern for our features. Let me explain why we decided to do this, why we think this is a big step forward and what this means for the user. Modules AMD stands for &#8220;Asynchronous Module [...]]]></description>
			<content:encoded><![CDATA[<p>During JSConf.eu, we released EmbedJS 0.2. That release was mainly about a fundamental architectural change: the move to the AMD pattern for our features. Let me explain why we decided to do this, why we think this is a big step forward and what this means for the user.<br />
<span id="more-1843"></span></p>
<h2>Modules</h2>
<p>AMD stands for &#8220;Asynchronous Module Definition&#8221;. So, what are modules? I&#8217;ll quote the definition from the <a href="http://wiki.commonjs.org/wiki/Modules/1.1" target="_blank">CommonJS Module specification</a>, as it describes it very well:</p>
<blockquote><p>This specification addresses how modules should be written in order to be interoperable among a class of module systems that can be both client and server side, secure or insecure, implemented today or supported by future systems with syntax extensions. These modules are offered privacy of their top scope, facility for importing singleton objects from other modules, and exporting their own API.</p></blockquote>
<p>So, modules are isolated parts of code that live in their own scope and are kind of self-contained. Well, that is pretty much how we see the individual Features in EmbedJS – we made our feature implementations as small as possible and reduced dependencies as much as possible. Many of EmbedJS&#8217; features are also browser-independent, so why not make it possible to use some of the tools in a non-browser environment?</p>
<p>(If you want to learn more on modules and why we need them, I recommend <a href="http://twitter.com/briancavalier" target="_blank">@briancavalier</a>&#8216;s <a href="http://briancavalier.com/presentations/pgh-js-amd-10-2011/" target="_blank">presentation on modules</a>.)</p>
<h2>Features in EmbedJS</h2>
<p>So far, I didn&#8217;t really explain what I mean with &#8220;Features&#8221;, so let me do another quote, this time from the <a href="http://uxebu.github.com/embedjs/" target="_blank">Project Page</a>:</p>
<blockquote><p>EmbedJS uses the concept of features: Functionalities are split up into features, as fine-grained as possible, and each feature might have multiple implementations.</p></blockquote>
<p>Our Features are kinda small and contain only few methods, sometimes even just one. The asyc-promise feature, for example, will get you Promises, and the transport-jsonp feature will get you a method for pull in data via jsonp – and that&#8217;s it.  If multiple methods are contained within one feature, this is because they are too closely related to each other to split them up, like the html-class feature, which contains the <code class="codecolorer text mac-classic"><span class="text">addClass</span></code>, <code class="codecolorer text mac-classic"><span class="text">removeClass</span></code>, <code class="codecolorer text mac-classic"><span class="text">toggleClass</span></code> and <code class="codecolorer text mac-classic"><span class="text">hasClass</span></code> methods.</p>
<h2>AMD vs CommonJS Modules 1.1</h2>
<p>Now that we knew modules were the way to go, there was another, quite important question to solve: There are two common patterns for modules, so which one do we want to apply? One pattern is described in the above mentioned CommonJS Wiki, the other pattern is described in the <a href="https://github.com/amdjs/amdjs-api/wiki/AMD" target="_blank">AMD wiki</a>.</p>
<p>Well, there have been <a href="http://tagneto.blogspot.com/2011/04/on-inventing-js-module-formats-and.html" target="_blank">some</a> <a href="http://unscriptable.com/index.php/2011/09/30/amd-versus-cjs-whats-the-best-format/" target="_blank">blog</a> <a href="http://blog.millermedeiros.com/2011/09/amd-is-better-for-the-web-than-commonjs-modules/" target="_blank">posts</a> lately that compare the pros and cons of each of them, so I don&#8217;t want to repeat all of this – but I&#8217;m hiving a similar tendency towards AMD. Besides this, there was another big reason to go with AMD: Remember, EmbedJS is based on the <a href="http://dojotoolkit.org/" target="_blank">Dojo Toolkit</a>, and it&#8217;s a <a href="http://dojofoundation.org/" target="_blank">Dojo Foundation Project</a> – and we hope that the efforts that went into making EmbedJS might flow back into the Dojo Toolkit one day. And as the Dojo Toolkit uses the AMD approach, the decision was quickly made to do so as well.</p>
<h2>Implications for EmbedJS</h2>
<p>There are several huge benefits for EmbedJS in using the AMD approach. The most noteworthy surely is the ease-of-use for developers. In your code, when you find you want an EmbedJS method, you <a href="http://uxebu.github.com/embedjs/docs/" target="_blank">look up the feature name</a> that provides this method, add it to the require statement and there you go. Man, easy.</p>
<p>A second important thing is that EmbedJS now plays really nice with AMD based projects. In fact, you could see EmbedJS now as a collection of small useful modules, that can be easily integrated – and also easily extended.</p>
<p>The third major benefit is that we can now get rid of all the custom tools we built around EmbedJS – you can load features with any AMD loader (though we use and recommend RequireJS) and build it with any AMD optimizer/builder (we recommend r.js).</p>
<p>Let&#8217;s have an extra word on</p>
<p><strong>Building</strong></p>
<p>It was always possible with EmbedJS to create a custom build that would contain only the features you wanted/needed in your project. But, you had to use our build tool that we created. And learning &amp; using Yet-Another-Build-Tool™ is always… well, let&#8217;s just say it would be cool to avoid it (and, not to forget, so is maintaining it). We did a lot to improve that, we created a GUI that allowed you to just &#8220;click together&#8221; the features you wanted, and we worked on a dynamic loader that would ease development. But still, the situation was far from ideal, and people just ended up going for our ready-made &#8220;kitchensink&#8221; builds that contained <em>all</em> of the features.</p>
<p>Now, we still provide those ready-made builds that contain only the implementations for a given platform (and are stripped of require/define calls), but I really hope that using the AMD approach and using an AMD optimizer to deploy will become the more adopted style.</p>
<h2>Q: Cross-target? A: The Feature Plugin</h2>
<p>One goal of EmbedJS is to allow for easy cross-device development. We got rid of run-time branching but instead went for an approach that held the different implementations for a given feature in separate files, so that one only has to deploy the actually needed code to a given device – and not all the alternate implementations, that sit useless in the device&#8217;s memory and never get used. We needed to achieve that with &#8220;in-house&#8221; means provided by the AMD approach. Lucky us, there&#8217;s the concept of <a href="https://github.com/amdjs/amdjs-api/wiki/Loader-Plugins" target="_blank">loader-plugins</a>, and so I created a <a href="https://github.com/jensarps/AMD-feature" target="_blank">feature-plugin for AMD loaders</a>. The idea is simple yet effective: You create an implementation map that maps a feature name to an implementation, and if there are multiple implementations, you supply tests that tells the plugin which feature to use.</p>
<p>When you&#8217;re ready to deploy, you have two choices: I f you really don&#8217;t know on what target your code is going to end up, you can use the dynamic implementation map containing the tests for the optimizer, and you&#8217;ll get a build that contains all of the available implementations. Then, during runtime, the feature plugin will run the tests and load the specific implementation. But, if you <em>do</em> know what target your code will run on, you provide a specific implementation map that doesn&#8217;t contain tests but directly maps to the according implementations, and you will only have those in your built file.</p>
<h2>Synopsis</h2>
<p>AMD is exactly what we needed to make EmbedJS more what we want it to be – an easy to use JavaScript toolbox that is especially handy for cross-target scenarios such as cross-platform mobile development. So, please don&#8217;t hesitate and check it out on Github, read the project page and check out the examples!</p>
<p>&nbsp;</p>
<p><strong>Resources / Further Reading</strong></p>
<ul>
<li><a href="https://github.com/uxebu/embedjs" target="_blank">EmbedJS on GitHub</a></li>
<li><a href="http://uxebu.github.com/embedjs/" target="_blank">EmbedJS Project Page</a></li>
<li><a href="http://uxebu.github.com/embedjs/docs/" target="_blank">EmbedJS API Docs</a></li>
<li><a href="https://github.com/jensarps/AMD-feature" target="_blank">AMD-Feature plugin</a></li>
<li><a href="https://github.com/amdjs/amdjs-api/wiki" target="_blank">AMD Wiki</a></li>
<li><a href="http://wiki.commonjs.org/wiki/CommonJS" target="_blank">CommonJS Wiki</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2011/10/17/embedjs-0-2-and-amd/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating a persistent Dojo Object Store</title>
		<link>http://uxebu.com/blog/2011/04/27/creating-a-persistent-dojo-object-store/</link>
		<comments>http://uxebu.com/blog/2011/04/27/creating-a-persistent-dojo-object-store/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 16:13:45 +0000</pubDate>
		<dc:creator>Jens Arps</dc:creator>
				<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[offline]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://uxebu.com/blog/?p=1540</guid>
		<description><![CDATA[As of version 1.6, dojo comes with the new Dojo Object Store API. This is an awesome thing, as it greatly simplifies the work with data stores in Dojo. Everybody who had to do with the traditional dojo.data API felt it was overly complex and hard to use – this has finally changed now. There [...]]]></description>
			<content:encoded><![CDATA[<p>As of version 1.6, dojo comes with the new <a href="http://docs.dojocampus.org/dojo/store" target="_blank">Dojo Object Store API</a>. This is an awesome thing, as it greatly simplifies the work with data stores in Dojo. Everybody who had to do with the traditional dojo.data API felt it was overly complex and hard to use – this has finally changed now. There are also wrappers from and to the old and new APIs, so that you can do stuff like using your traditional data-aware widgets with a new Object Store. And the goodness doesn&#8217;t end here; but more on this later. If you haven&#8217;t done so yet, you might want to read the <a href="https://www.sitepen.com/blog/2011/02/15/dojo-object-stores/" target="_blank">excellent post on the new Dojo Object Stores</a> by Kris Zyp where he explains all the awesomeness he created.</p>
<p>Dojo also comes with two fresh implementations for the API, a non-persistent memory store and a JsonRest store that interacts with a server through RESTful HTTP requests. You can also observe changes made to objects in the store. What is missing is a store that uses a client-side persistent backend, which would be useful for a couple of reasons (e.g., as one commenter in that post asks, to use it as chache store for dojo.store.Cache). As Kris already mentions, it&#8217;s a piece of cake to create one, so let&#8217;s go ahead and do it!<br />
<span id="more-1540"></span></p>
<h2>Choosing the Backend</h2>
<p>The post mentions two possible candidates: dojox.storage and <a href="https://github.com/jensarps/StorageJS" target="_blank">StorageJS</a>, both already having a similar API, so making them compliant to the Dojo Object Store API is fairly easy. For this tutorial I choose StorageJS – because it is very lightweight and still provides all we need (and, well, for a couple of other reasons that don&#8217;t belong in this post). So, what is the exact API we need to comply to? Check it out <a href="http://docs.dojocampus.org/dojo/store#id2" target="_blank">in the docs</a>. See the first sentence in that paragraph? <em>&#8220;Every method in the API is optional, it&#8217;s presence indicating support for that feature.&#8221;</em> Wow, that&#8217;s nice!</p>
<h2>Basic compliance</h2>
<p>Let&#8217;s start with the methods get(), put(), add() and remove(). That will make our store pretty usable for most store scenarios.</p>
<p>First, create a &#8216;store&#8217; object we can work with (StorageJS creates a global variable called <code class="codecolorer text mac-classic"><span class="text">storage</span></code> where all it&#8217;s methods reside):</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #003366; font-weight: bold;">var</span> store <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">delegate</span><span style="color: #009900;">&#40;</span>storage<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>&#8216;store&#8217; now contains everything that &#8216;storage&#8217; does, but we can leave the original &#8216;storage&#8217; object alone and modify our &#8216;store&#8217; object if needed. Time for the first method, let&#8217;s start with <code class="codecolorer text mac-classic"><span class="text">get()</span></code>. StorageJS works with Strings as keys and values only, so we need to parse what we get from it.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">store.<span style="color: #660066;">get</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Need to parse the string we get from backend:</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> dojo.<span style="color: #660066;">fromJson</span><span style="color: #009900;">&#40;</span>storage.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Easy one, now move on to <code class="codecolorer text mac-classic"><span class="text">put()</span></code>. The Object Store API allows user to do stuff like this: <code class="codecolorer text mac-classic"><span class="text">store.put({foo: 'bar'}, {id: 3})</span></code> as well as <code class="codecolorer text mac-classic"><span class="text">store.put({id: 3, foo: 'bar'})</span></code>. Also, StorageJS only has the method set() instead of put() and add().</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">store.<span style="color: #660066;">put</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>object<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Get the id, wherever it comes from</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> options <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> options.<span style="color: #660066;">id</span> <span style="color: #339933;">||</span> object.<span style="color: #660066;">id</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Stringify data -- remember, StorageJS is a key/value backend wrapper.</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">toJson</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Now save the data away</span><br />
&nbsp; &nbsp; storage.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span>id<span style="color: #339933;">,</span> data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>Easy, as well – you could write this as a one-liner. Now, <code class="codecolorer text mac-classic"><span class="text">add()</span></code>. It&#8217;s close to put, except that it won&#8217;t overwrite data that already exists. So we just need to check if something with the given id already exists and throw an error if so.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">store.<span style="color: #660066;">add</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>object<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Get the id</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> id <span style="color: #339933;">=</span> options <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> options.<span style="color: #660066;">id</span> <span style="color: #339933;">||</span> object.<span style="color: #660066;">id</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Check if something exists under the given</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// id -- StorageJS always returns null when</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// there's no data for a certain key.</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>storage.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span>id<span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">throw</span> <span style="color: #003366; font-weight: bold;">new</span> Error<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Object already exists&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// We're save to go now! So hand over the</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// request to the put() method.</span><br />
&nbsp; &nbsp; store.<span style="color: #660066;">put</span><span style="color: #009900;">&#40;</span>object<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>What about <code class="codecolorer text mac-classic"><span class="text">remove()</span></code>? Nothing to do there, it already has the desired signature and functionality.</p>
<p>That&#8217;s it, we&#8217;re done with basic compliance. Our &#8216;store&#8217; object now implements the basic methods of the Dojo Object Store API and can be used by anything that can work with a Dojo Object Store – and it will keep it&#8217;s state persistent in the browser.</p>
<h2>More compliance? Querying!</h2>
<p>There&#8217;s one interesting thing in the API: the <code class="codecolorer text mac-classic"><span class="text">query()</span></code> method. Uh, yeah, we want that! Lucky us, Dojo already provides a query engine as well as a method that makes sure there are iterative methods and a <code class="codecolorer text mac-classic"><span class="text">total</span></code> property containing the number of hits available in our result (well, it also abstracts away the differences between sync and async results, but as StorageJS is purely synchronous, this is not important to us). First, define a queryEngine:</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// Let's take the provided queryEngine :)</span><br />
store.<span style="color: #660066;">queryEngine</span> <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">store</span>.<span style="color: #660066;">util</span>.<span style="color: #660066;">SimpleQueryEngine</span><span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>So, if we want our store to be able to run queries, all we need to do is to take the store&#8217;s data and hand it over to the query engine. We use StorageJS&#8217; getAll() method to acquire the data. It will return an array of objects in the form { key: &#8216;theKey&#8217;, value: &#8216;theValue&#8217;}, but the queryEngine wants an array containing only the objects, so we need to do a conversion.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">store.<span style="color: #660066;">query</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>query<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Get all data from the backend</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> rawData <span style="color: #339933;">=</span> storage.<span style="color: #660066;">getAll</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// And convert it into a format that the</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// queryEngine can work with</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> data <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> l <span style="color: #339933;">=</span> rawData.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> l<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #339933;">=</span> rawData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> dataObject <span style="color: #339933;">=</span> dojo.<span style="color: #660066;">fromJson</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; data.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>dataObject<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// Now call the queryEngine on the data</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> results <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">queryEngine</span><span style="color: #009900;">&#40;</span>query<span style="color: #339933;">,</span> options<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// And return the result, after it has been</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// enhanced.</span><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> dojo.<span style="color: #660066;">store</span>.<span style="color: #660066;">util</span>.<span style="color: #660066;">QueryResults</span><span style="color: #009900;">&#40;</span>results<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>Now we can query our store for specific data, like so: <code class="codecolorer text mac-classic"><span class="text">var results = store.query({ prime: true });</span></code> This will give us all objects in the store that have a property called &#8216;prime&#8217; and have that property set to true.</p>
<h2>Hierarchie and Transactions</h2>
<p>The API also mentions methods about data hierarchie and transactions, but I&#8217;m not going to cover these in this tutorial.</p>
<h2>Convenience and Optimization</h2>
<p>Currently, every time we run a query, we fetch all data again from our storage engine. So, if you don&#8217;t have a massive amount of data and want to query the store a lot, it might be wise to maintain a copy of all data in memory. There are other things you could optimize as well – or you could write your own queryEngine.</p>
<p>For your convenience,  <a href="http://statis.uxebu.com/~jens/dojo.store/PersistentLocal.js" target="_blank">here&#8217;s a wrapper</a> that creates a Dojo Object Store like we did above and accepts a useMemory parameter during instantiation that denotes whether a copy of the data should be kept in memory or not. It uses the traditional require/provide instead of the AMD format. If you want to use it, make sure you use the right namespace in the declare() call! (Or, not recommended, copy it in the /dojo/store directory.)</p>
<p>If you want to fool around with it in the console first, you can go <a href="http://static.uxebu.com/~jens/dojo.store/index-persistent-nomemory.html" target="_blank">here (non-memory-using)</a> or <a href="http://static.uxebu.com/~jens/dojo.store/index-persistent-usememory.html" target="_blank">here (memory-using)</a>, check out the source and fire up the console and try things out.</p>
<h2>Getting StorageJS</h2>
<p>The above code uses the features base and getAll, so you could do a specific build of StorageJS with these features or just <a href="https://github.com/jensarps/StorageJS/tree/master/builds?raw=true" target="_blank">grab a full build</a> of it for your desired storage engine (the storage-full-[engine].js files). If you don&#8217;t know about storage engines, all modern browser support localStorage, so <a href="https://github.com/jensarps/StorageJS/raw/master/builds/storage-full-localStorage.js" target="_blank">this is the one</a> what you might want.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2011/04/27/creating-a-persistent-dojo-object-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Explaining EmbedJS</title>
		<link>http://uxebu.com/blog/2011/01/31/explaining-embedjs/</link>
		<comments>http://uxebu.com/blog/2011/01/31/explaining-embedjs/#comments</comments>
		<pubDate>Mon, 31 Jan 2011 14:02:28 +0000</pubDate>
		<dc:creator>Jens Arps</dc:creator>
				<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[frontend engineering]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[embedjs]]></category>
		<category><![CDATA[memory usage]]></category>
		<category><![CDATA[optimize]]></category>
		<category><![CDATA[performance]]></category>

		<guid isPermaLink="false">http://uxebu.com/blog/?p=1366</guid>
		<description><![CDATA[Last week, we tagged the current state of EmbedJS 0.1. This is a large step for us, and something we have been waiting for and wanting to do for a long time. And with doing so, the need arises to answer a lot of questions – and we better start sooner than later. So, here [...]]]></description>
			<content:encoded><![CDATA[<p>Last week, we tagged the current state of EmbedJS 0.1. This is a large step for us, and something we have been waiting for and wanting to do for a long time. And with doing so, the need arises to answer a lot of questions – and we better start sooner than later. So, here it is, the first part of „Explaining EmbedJS“.</p>
<h2>What is it?</h2>
<p>It‘s a JavaScript Toolkit, especially aimed at embedded devices. Embedded devices, that is phones, tablet devices, TVs, car dashboards and the like. Devices that are capable of running JavaScript. We are sure that this list is going to grow over time – and will hopefully one day also include devices like your fridge. EmbedJS is based on the Dojo Toolkit.<br />
<span id="more-1366"></span></p>
<h2>Why?</h2>
<p>Because the toolkits and frameworks that exist focus on desktop browsers and therefore have a different approach – an approach we didn‘t find that suitable for embedded/mobile development. And the JS frameworks that target mobile devices are flawed, too: either they target only a specific device or platform, or they provide far more than we do need and want.</p>
<p>What we wanted was a toolkit that offered a unified API across different platforms, but with the best implementation that was available for each platform. And we didn‘t want to ship code that implemented a certain feature for, say, an old Blackberry device to an iPhone. Plus, we wanted that API to be small – enough to assist us in our daily work, but not that bloated that we would ship code to a phone that we wouldn‘t need in most of our projects.</p>
<h2>The Dojo Toolkit</h2>
<p>We at uxebu have a strong affinity to the <a href="http://dojotoolkit.org/" target="_blank">Dojo Toolkit</a> – most of us are committers – for a good reason: we believe that it has done many things right, and that it has an excellent code quality. Thus, finding a starting point for our venture to what was later to be EmbedJS was pretty easy: It was the very core of the Dojo Toolkit, dojo._base.</p>
<p>We examined the code and split it into its smallest parts (features, how we call them in EmbedJS). After having the features all nicely separated, we could look for the best implementation for each of the platforms we wanted to support, and put it into a separate file. Then we optimized our code, tweaking here and there, but also using the code from dojo._base as it was, because it already was the best implementation.</p>
<p>And we needed to find means to put all these tiny parts together again, respecting any given dependecies, to create a file that then contained all the feature‘s implementations for a given platform – so the EmbedJS Tools were born, including our highly flexible build system.</p>
<h2>API</h2>
<p>EmbedJS‘ API is a small subset on Dojo‘s API. It provides around 70 methods, from the fields language enhancement (like Array manipulation or JSON), OO (like classes and inheritance), transport (like JSONP or XHR), event system (like connecting to DOM events or methods), DOM manipulation (like style or node creation) and misc things like Promises or pub/sub.</p>
<p>We kept the method signatures intact so that you can import your existing knowledge from working with the Dojo Toolkit to EmbedJS. There are only a few minor changes where we<br />
a) found a new name highly useful, e.g <code class="codecolorer text mac-classic"><span class="text">dojo.io.script.get()</span></code> is <code class="codecolorer text mac-classic"><span class="text">embed.jsonp()</span></code><br />
b) we needed to strip given functionality for the sake of code size.</p>
<p>All methods in EmbedJS are available under the embed namespace as well as under the dojo namespace. I.e. to call the connect method you can use <code class="codecolorer text mac-classic"><span class="text">dojo.connect()</span></code> and <code class="codecolorer text mac-classic"><span class="text">embed.connect()</span></code>.</p>
<p>The full API documentations is <a href="http://embedjs.org/apidocs/dools/app/apidoc/embedjs/" target="_blank">here</a>, though it‘s undergoing some updates right now.</p>
<h2>Summary</h2>
<p>I didn‘t want to dig too deep in the first article on EmbedJS, but I guess you got the point: EmbedJS is a highly optimized Dojo core, and offers you a specialized, optimal build for a given platform. To explain how the build system works, how we manage dependencies, how we separate our features and our implementations and how one can create a project-oriented custom build will need another blog post – but if you are too curious, you are invited to take a look at <a href="https://github.com/uxebu/embedjs" target="_blank">the source code at github</a>; a lot is self-explenatory there. A further source of information is the <a href="http://uxebu.github.com/embedjs/" target="_blank">EmbedJS project page</a>, as well as the <a href="https://github.com/uxebu/embedjs-tools" target="_blank">EmbedJS Tools source</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2011/01/31/explaining-embedjs/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dojo.workshop(&#8220;Haifa&#8221;) &#8211; the summary</title>
		<link>http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/</link>
		<comments>http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 11:11:18 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[dojo]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[frontend engineering]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[w3c widgets]]></category>
		<category><![CDATA[dojo.beer()]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=624</guid>
		<description><![CDATA[August 9th was the day for the first Dojo event in Israel and thanks to Yoav Rubin from IBM Research Labs in Haifa, we were able to hold the event in the great Auditorium of the amazingly located IBM building in Haifa. To give you a little impression of what kind of working environment the [...]]]></description>
			<content:encoded><![CDATA[<p>August 9th was the day for the first Dojo event in Israel and thanks to <a href="http://yoavrubin.blogspot.com">Yoav Rubin</a> from IBM Research Labs in Haifa, we were able to hold the event in the great Auditorium of the amazingly located IBM building in Haifa.<br />
To give you a little impression of what kind of working environment the folks at IBM have, I uploaded a panorama image from Yoav&#8217;s office.</p>
<p><center><a href="http://hub.uxebu.com:33550/wp-content/uploads/2009/08/1411050085_9690da53f7_o.jpg"><img src="http://hub.uxebu.com:33550/wp-content/uploads/2009/08/1411050085_9690da53f7_o-1024x142.jpg" alt="IBM Haifa" title="IBM Haifa" width="50%" class="alignnone size-large wp-image-625" /></a></center><br />
<span id="more-624"></span></p>
<p>The day started as planned with coffee and snacks and a <a href="http://www.slideshare.net/nonken/dojo-introduction-1844594">Dojo introduction</a> giving everybody who wasn&#8217;t really familiar with the Dojo Toolkit a better idea of what it actually is. A few demos such as <a href="http://code.google.com/p/xray-project">xRay</a> where shown to show some of the advanced features of Dojo such as live charting, custom themeing and much more.<br />
After a short break we continued with a talk on how to <a href="http://www.slideshare.net/nonken/event-list">design mobile architectures with the Dojo Toolkit</a> for platforms such as <a href="http://www.phonegap.com">PhoneGap</a>, W3C widgets and other mobile platforms supporting JavaScript/HTML and CSS. This is a very interesting topic and it was great to share the experience we made at uxebu on finding viable solutions for the challenges we face.  The third talk was a quick overview of the current documentation efforts for Dojo and different ways of finding the information you need when you are stuck or simply looking for API docs or similar.<br />
Before the break, Tomer Mahlin from IBM in Jerusalem, who is working on the BIDI implementation in Dojo, gave a very interesting talk on the challenges, developers face when writing applications supporting BIDI. Not having to deal with the issues you get confronted with when having to develop BIDI applications, this talk was eye opening and very interesting.<br />
After a great lunch we jumped into a hands on session building a very simple mobile app running on both PhoneGap and devices with a widget runtime supporting W3C widgets installed. This gave the audience a glimpse into mobile development and the challenges but also really exciting features.</p>
<p>In total there were about 45 people attending the event which is an amazing amount of people for such a first time event, thanks again to everyone attending and especially to Yoav Rubin and the folks at IBM to make this happen.</p>
<p>I am already looking forward to the next Dojo event in Israel and hope that we can be part of it again.</p>

<a href='http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/1411050085_9690da53f7_o/' title='IBM Haifa'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/08/1411050085_9690da53f7_o-150x150.jpg" class="attachment-thumbnail" alt="IBM Haifa" title="IBM Haifa" /></a>
<a href='http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/nikolaionken_dojo2/' title='nikolaionken_dojo2'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/08/nikolaionken_dojo2-150x150.jpg" class="attachment-thumbnail" alt="nikolaionken_dojo2" title="nikolaionken_dojo2" /></a>
<a href='http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/img_0131/' title='img_0131'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/08/img_0131-150x150.jpg" class="attachment-thumbnail" alt="img_0131" title="img_0131" /></a>
<a href='http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/img_0130/' title='img_0130'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/08/img_0130-150x150.jpg" class="attachment-thumbnail" alt="img_0130" title="img_0130" /></a>
<a href='http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/img_01311/' title='img_01311'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/08/img_01311-150x150.jpg" class="attachment-thumbnail" alt="img_01311" title="img_01311" /></a>
<a href='http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/img_0133/' title='img_0133'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/08/img_0133-150x150.jpg" class="attachment-thumbnail" alt="img_0133" title="img_0133" /></a>

<p>Following are the slides to give you a little impression of the events content. </p>
<div style="width:425px;text-align:left" class="mhx" id="__ss_1844597"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/nonken/event-list" title="EventNinja, Dojo and mobile">EventNinja, Dojo and mobile</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=eventlist-090811111712-phpapp01&#038;stripped_title=event-list" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=eventlist-090811111712-phpapp01&#038;stripped_title=event-list" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/nonken">nonken</a>.</div>
</div>
<div style="width:425px;text-align:left" class="mhx" id="__ss_1844594"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/nonken/dojo-introduction-1844594" title="Dojo Introduction">Dojo Introduction</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dojointroduction-090811111614-phpapp02&#038;stripped_title=dojo-introduction-1844594" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=dojointroduction-090811111614-phpapp02&#038;stripped_title=dojo-introduction-1844594" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">documents</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/nonken">nonken</a>.</div>
</div>
<div style="width:425px;text-align:left" class="mhx" id="__ss_1848277"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/guest0176bf4/bidi-support-in-dojo14" title="Bidi Support In Dojo1.4">Bidi Support In Dojo1.4</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=bidisupportindojo1-406august2009-090812072918-phpapp02&#038;stripped_title=bidi-support-in-dojo14" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=bidisupportindojo1-406august2009-090812072918-phpapp02&#038;stripped_title=bidi-support-in-dojo14" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View more <a style="text-decoration:underline;" href="http://www.slideshare.net/">presentations</a> from <a style="text-decoration:underline;" href="http://www.slideshare.net/guest0176bf4">guest0176bf4</a>.</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/08/12/dojoworkshophaifa-the-summary/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dojo.workshop in Haifa, Israel &#8211; August 9th</title>
		<link>http://uxebu.com/blog/2009/07/30/dojoworkshop-in-haifa-israel-august-9th/</link>
		<comments>http://uxebu.com/blog/2009/07/30/dojoworkshop-in-haifa-israel-august-9th/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 11:08:04 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[dojo.workshop]]></category>
		<category><![CDATA[israel]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=607</guid>
		<description><![CDATA[The news have been announced already on the Dojotoolkit.org and Dojocampus.org blogs but I nevertheless wanted to mention the dojo.workshop in Haifa, Israel on August 9th. Already now we have more than 50 signups and thanks to Yoav Rubin from IBM research labs we can have a full day of Dojo-ness. It is interesting to [...]]]></description>
			<content:encoded><![CDATA[<p>The news have been announced already on the <a href="http://dojotoolkit.org/2009/07/27/dojo-workshop-haifa-israel-august-9th-more-info-and-schedule">Dojotoolkit.org</a> and <a href="http://dojocampus.org/content/2009/07/09/dojoworkshophaifa-august-9th/">Dojocampus.org</a> blogs but I nevertheless wanted to mention the dojo.workshop in Haifa, Israel on August 9th.<br />
Already now we have more than 50 signups and thanks to <a href="http://yoavrubin.blogspot.com">Yoav Rubin</a> from IBM research labs we can have a full day of Dojo-ness.<br />
<span id="more-607"></span><br />
It is interesting to hear that many attending people are interested in how to write mobile applications with the Dojo Toolkit and we will try to spend some time on giving people insight about where things currently stand.<br />
As I am discussing in the upcoming issue of the <a href="http://www.jsmag.com/">JSMag</a>, using JavaScript libraries on mobile environments is something you have to do with caution since most of the libraries were not written intentionally for mobile platforms.<br />
Dojo at this point is a very good choice (yes I am biased ;) and yes, Dojo needs a lot of optimization for mobile) especially if you are working on delivering applications both to mobile devices and desktop clients. It is no fun having to use different tools for similar environments. So I am looking forward to lots of mobile hacking in Haifa.</p>
<p>Following some more details for the event. You can find all info also at the <a href="http://dojocampus.org/content/2009/07/09/dojoworkshophaifa-august-9th/">DojoCampus.org event page</a> and things are still subject to change.</p>
<p><strong>Location:</strong></p>
<p>IBM Haifa Research Lab<br />
Haifa University Campus</p>
<p><a href="http://maps.google.com/maps?f=q&#038;source=s_q&#038;hl=en&#038;geocode=&#038;q=Israel,+Haifa,+Haifa+University&#038;sll=32.763315,35.004501&#038;sspn=0.2096,0.176811&#038;ie=UTF8&#038;z=14&#038;iwloc=A">Google map</a></p>
<p><strong>Time:</strong></p>
<p>09:30 &#8211; 15:00</p>
<p><strong>Schedule</strong></p>
<p>09:30 &#8211; 10:00 &#8211; Gathering</p>
<p>10:00 &#8211; 10:15 &#8211; Welcome and introduction</p>
<p>10:15 &#8211; 10:45 &#8211; Overview of Dojo Dijit and Dojox</p>
<p>11:00 &#8211; 12:00 &#8211; Dojo and Mobile</p>
<p>12:00 &#8211; 12:30 &#8211; Dojo based JavaScript API Docs generator</p>
<p>12:30 &#8211; 13:00 &#8211; Hacking mobile (this session might be extended)</p>
<p>13:00 &#8211; 14:00 &#8211; Lunch</p>
<p>14:10 &#8211; 14:30 &#8211; Support for bidirectional languages in Dojo</p>
<p>14:30 &#8211; 15:00 &#8211; Projects demonstration </p>
<p>If you want to give a talk about your experience with Dojo or anything Web related, leave a comment at the <a href="http://dojocampus.org/content/2009/07/09/dojoworkshophaifa-august-9th/">DojoCampus.org event page</a> or send an email to nonken(_at_) dojotoolkit.org and we&#8217;ll make sure you get added to the schedule.</p>
<p>After the main event we will either continue hacking or go for food/drinks/dojo.beers() into town.</p>
<p>If you would like to attend, please add your name to the list below, so we can be sure that we will have enough space.</p>
<p><iframe width="300" height="250" frameborder="0" src="http://doodle.com/summary.html?pollId=d6y8m9mfarzd3xwc"> </iframe></p>
<p>Looking forward to being in Haifa and meeting lots of Dojo, web, JavaScript folks.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/07/30/dojoworkshop-in-haifa-israel-august-9th/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>EventNinja: A mobile must-have Widget for the mobile2.0</title>
		<link>http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/</link>
		<comments>http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/#comments</comments>
		<pubDate>Tue, 16 Jun 2009 08:31:43 +0000</pubDate>
		<dc:creator>wolfram</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[w3c widgets]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[mobile2.0]]></category>
		<category><![CDATA[phonegap]]></category>
		<category><![CDATA[w3c]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=493</guid>
		<description><![CDATA[We have been writing and talking about EventNinja already for a bit. Now you can have it! Just visit EventNinja.net and test it on your iPhone and other mobile devices. EventNinja is on its way into the different AppStores and we will keep you updated on new versions coming out. What will you get? At [...]]]></description>
			<content:encoded><![CDATA[<p>We have been writing and <a href="http://twitter.com/EventNinja_app">talking about EventNinja</a> already for a bit. <strong>Now you can have it!</strong> Just visit <a href="http://www.eventninja.net">EventNinja.net</a> and test it on your iPhone and other mobile devices. EventNinja is on its way into the different AppStores and we will keep you updated on new versions coming out.<br />
What will you get? At first, you&#8217;re getting the best app out there to lead you around a conference like the <a href="http://mobile20.eu">mobile2.0 in Barcelona</a> in a few days on the 18th and 19th of June 2009. If you are attending be sure to have EventNinja on your mobile! So that you have all the info at hand when searching for the next talk to attend. It&#8217;s not just a list of all relevant upcoming web developer events on your phone (and browser). It is even more, you can get in depth info about the events, their schedule, all the twitter messages for an event, directions and many more features.<br />
If you are at the <a href="http://mobile20.eu">mobile2.0</a> be sure to visit us to get even more!</p>
<p>Enjoy the short video we prepared to give you an impression of what EventNinja can do</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/DClZnEaBHLI&#038;hl=en&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/DClZnEaBHLI&#038;hl=en&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p><span id="more-493"></span></p>
<h2>EventNinja in Action</h2>
<p>The EventNinja widget contains multiple pages, as you are used to from mobile applications. The <em>home page</em> shows all the events, allows you to search and filter them. Along the top bar you have the search bar, the &#8220;Help&#8221; and the &#8220;About&#8221; pages linked.<br />
Clicking on the icon to the right of each event takes you to <em>the details page</em> of the event, from where you can go to multiple other places, like <em>the map</em>, to see where it exactly takes place,<em> the schedule</em> of the event. If the event has twitter tags saved for it can go to a page which shows you all <em>the latest twitter messages</em> flying in. Try it on <a href="http://www.eventninja.net">EventNinja.net</a> and explore the features.</p>
<h2>EventNinja Features</h2>
<h3>User Features</h3>
<ul>
<li>List of web developer events</li>
<li>Searchable and filterable by tags, location and full-text search</li>
<li>Exact location of the event</li>
<li>Watch all twitter messages for each event</li>
<li>Find out about details of an event</li>
</ul>
<h3>Technology Features</h3>
<ul>
<li>Events are stored, retrieved and filtered by a Google Calendar</li>
<li>Everything built on top of the <a href="http://www.dojotoolkit.org">Dojo Toolkit</a></li>
<li>pure HTML, CSS, JavaScript based widget</li>
<li>using <a href="http://www.phonegap.com">PhoneGap</a> to run on <a href="http://www.apple.com/iphone/">iPhone</a>, <a href="http://www.android.com/">Android</a> and <a href="http://www.blackberry.nl/">Blackberry</a></li>
<li>Plugin architecture, allows for a modular enhancement of the widget</li>
<li><strong>Fully</strong> customizable via client-side templates and CSS of course</li>
</ul>
<p>As you figure right from the list of features and cleverly combining them we can hook this widget onto any calendar, customize the features (via plugins), style and brand it the way we like it and have your custom widget.</p>
<p>This gives customization a far broader meaning. Just imagine combining the two components 1) base of the widget and 2) the twitter plugin. You get a widget which shows you all tweets for a certain event -that&#8217;s just a new widget itself, without writing a line of new code. Which again is a very different use case, than the widget you get here. Just hook in another plugin which allows replying via twitter and you get a full blown twitter client in the context of events.<br />
The limits of what is thinkable is just limited by the plugins you can write.</p>
<h2>EventNinja for the mobile2.0 Conference</h2>
<p>Mobile2.0 is the first conference where you can really use EventNinja to get all the info possible, the schedule, twitter messages, etc. There surely will follow many more conferences and events that EventNinja can and will be used at. See the screenshots below to get a feeling of what it looks like for this conference.</p>

<a href='http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/screenshot-20090612-150714/' title='screenshot-20090612-150714'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/06/screenshot-20090612-150714-150x150.png" class="attachment-thumbnail" alt="screenshot-20090612-150714" title="screenshot-20090612-150714" /></a>
<a href='http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/screenshot-20090612-150809/' title='screenshot-20090612-150809'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/06/screenshot-20090612-150809-150x150.png" class="attachment-thumbnail" alt="screenshot-20090612-150809" title="screenshot-20090612-150809" /></a>
<a href='http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/screenshot-20090612-150819/' title='screenshot-20090612-150819'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/06/screenshot-20090612-150819-150x150.png" class="attachment-thumbnail" alt="screenshot-20090612-150819" title="screenshot-20090612-150819" /></a>
<a href='http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/screenshot-20090612-150840/' title='screenshot-20090612-150840'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/06/screenshot-20090612-150840-150x150.png" class="attachment-thumbnail" alt="screenshot-20090612-150840" title="screenshot-20090612-150840" /></a>
<a href='http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/screenshot-20090612-150917/' title='screenshot-20090612-150917'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/06/screenshot-20090612-150917-150x150.png" class="attachment-thumbnail" alt="screenshot-20090612-150917" title="screenshot-20090612-150917" /></a>
<a href='http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/cap/' title='cap'><img width="150" height="150" src="http://uxebu.com/blog/wp-content/uploads/2009/06/cap-150x150.png" class="attachment-thumbnail" alt="cap" title="cap" /></a>

<h2>Are events missing?</h2>
<p>EventNinja for webdevelopers is driven by the great amount of community events.<br />
If you see that events are missing, please contact us and we will add them immediately. If you organize events yourself let us know as well. You can send any kind of info about the event, e.g. name, location, tags, speakers, twitter tags, schedule details, price, and much more.</p>
<h2>You want an EventNinja?</h2>
<p>Send an email to eventninja _ at _ uxebu.com if you are interested in a customized version of EventNinja, are interested in the technology or simply want to chat. At the <a href="htt[://www.mobile20.eu">mobile2.0</a> conference you will recognize us easily when you look for the guys with those caps, hurry, because we are spreading caps and maybe there will be many more wearing this cap :-).</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/06/16/eventninja-a-mobile-must-have-widget-for-the-mobile20/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mobile days in Spain</title>
		<link>http://uxebu.com/blog/2009/05/28/mobile-days-in-spain/</link>
		<comments>http://uxebu.com/blog/2009/05/28/mobile-days-in-spain/#comments</comments>
		<pubDate>Thu, 28 May 2009 11:55:24 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojango]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[mobile]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[dojo.beer()]]></category>
		<category><![CDATA[mobile2.0]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=440</guid>
		<description><![CDATA[As Wolfram already has posted in the last blog post, we are currently involved quite a bit in the mobile world and especially in investigating on how Dojo can be used best to develop for mobile devices. Taking this as an opportunity we want to announce the next dojo.beer() in Barcelona on June 17th. You [...]]]></description>
			<content:encoded><![CDATA[<p>As Wolfram already has posted in the last <a href="http://blog.uxebu.com/2009/05/27/mobile-weeks-wrap-up/">blog post</a>, we are currently involved quite a bit in the mobile world and especially in investigating on how <a href="http://www.dojotoolkit.org">Dojo</a> can be used best to develop for mobile devices.</p>
<p>Taking this as an opportunity we want to announce the next dojo.beer() in Barcelona on June 17th.<br />
You can get all info about the event on the <a href="http://dojocampus.org/content/2009/05/28/dojobeer-barcelona-june-17th/">DojoCampus event site</a>.</p>
<p>The day after, we are speaking at the <a href="http://mobile20.eu/developer-day/">Mobile2.0 developer day</a> and will give a detailed introduction in how to write mobile applications using the Dojo Toolkit and making sure they are running on different platforms such as <a href="http://phonegap.com/">PhoneGap</a> and the W3C widgets being <a href="http://www.betavine.net">supported by Vodafone</a>.</p>
<p>If you are in Barcelona that week, feel free to get in touch and if you have time to join for drinks during the dojo.beer or the mobile 2.0 conference let us know. Please sign up using the poll below.</p>
<p><strong>Para los españoles :-)</strong></p>
<p>Como Wolfram ha escrito en su último <a href="http://blog.uxebu.com/2009/05/27/mobile-weeks-wrap-up">artículo de blog</a>, nosotros estamos muy involucrados en el mundo de los móviles y estamos especialmente investigando como desarollar de la mejor manera para dispositivos móviles con Dojo.</p>
<p>Aprovechamos esta oportunidad para anunciar el próximo dojo.beer() en Barcelona el 17 de junio de 2009.<br />
Puedes encontrar toda la información en inglés sobre el evento en la <a href="http://dojocampus.org/content/2009/05/28/dojobeer-barcelona-june-17th">página de eventos de DojoCampus</a>.</p>
<p>Al día siguiente vamos a dar una ponencia en el <a href="http://mobile20.eu/developer-day/">Mobile2.0 developer day</a> y vamos a explicar como escribir aplicaciones moviles usando el Dojo Toolit y como asegurarse de que funcionan en múltiples plataformas como <a href="http://phonegap.com">PhoneGap</a> y como W3C Widget  <a href="http://www.betavine.net">apoyado por Vodafone</a> entre otros.</p>
<p>Si estás en Barcelona durante esa semana y te apetece contactar con nosotros  no dudes en venir a tomar una copa  al dojo.beer o a la conferencia mobile2.0. Por favor participa en el poll abajo si quieres ir.</p>
<p><iframe width="300" height="250" frameborder="0" src="http://doodle.com/summary.html?pollId=zw4ui9kraiw8cgt3"> </iframe></p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/05/28/mobile-days-in-spain/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>uxebu &amp; SitePen &#8211; Dojo training in Europe, May 7th/8th</title>
		<link>http://uxebu.com/blog/2009/03/19/uxebu-sitepen-dojo-training-in-europe-may-7th8th/</link>
		<comments>http://uxebu.com/blog/2009/03/19/uxebu-sitepen-dojo-training-in-europe-may-7th8th/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 06:30:43 +0000</pubDate>
		<dc:creator>Nikolai Onken</dc:creator>
				<category><![CDATA[business]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[sitepen]]></category>
		<category><![CDATA[training]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=136</guid>
		<description><![CDATA[Important note: Training Program changed! For details visit: [UPDATE] &#8211; uxebu &#038; SitePen &#8211; Dojo training in Europe, May 8th SitePen and uxebu are pleased to announce their first joint Dojo workshop in Munich, Germany. Come join some of the co-creators of Dojo on the 7th and 8th of May, 2009 to learn how to [...]]]></description>
			<content:encoded><![CDATA[<p><br/></p>
<div style="padding:10px;background:#DDDDDD">
<p style="margin-top:0px;font-size:1.5em;font-weight:bold;">Important note: Training Program changed!</p>
<p>For details visit: <a href="http://blog.uxebu.com/2009/04/20/update-uxebu-sitepen-dojo-training-in-europe-may-8th/">[UPDATE] &#8211; uxebu &#038; SitePen &#8211; Dojo training in Europe, May 8th</a>
</div>
<p><br/></p>
<p><a href="http://sitepen.com/">SitePen</a> and <a href="http://uxebu.com/">uxebu</a> are pleased to announce their first joint Dojo workshop in Munich, Germany. Come join some of the co-creators of Dojo on the 7th and 8th of May, 2009 to learn how to build great web sites and applications with Dojo.   </p>
<p>This new workshop will be an engaging experience for anyone wanting to learn more about Dojo!</p>
<p style="margin: 30px; text-align: center"><img src="http://blog.uxebu.com/wp-content/uploads/2009/03/uxebu-sitepen-training.gif" /></p>
<p><span id="more-136"></span></p>
<p>Dojo has an incredible set of features&mdash;from the essential tools to build AJAXy Web2.0 applications, to a rich set of widgets, layout components and to &#8220;edge of the web&#8221; extensions, Dojo has you covered. If you or your team members are already using Dojo, this workshop can help you strengthen your skills and also learn about the latest tricks and tips around JavaScript and Dojo in particular.  Raise your productivity by learning techniques to optimize applications and learn best practices for the development process by better knowing your tool set.</p>
<table border="0">
<tr>
<td style="vertical-align: top; width: 150px;">Course: 	</td>
<td style="font-weight: bold">Dojo Workshop</td>
</tr>
<tr>
<td style="vertical-align: top">Date: 	</td>
<td style="font-weight: bold">May 7-8, 2009</td>
</tr>
<tr>
<td style="vertical-align: top">Time: 	</td>
<td style="font-weight: bold">9:00 AM &#8211; 6:00 PM GMT+1 daily</td>
</tr>
<tr>
<td style="vertical-align: top">Language: 	</td>
<td style="font-weight: bold">English</td>
</tr>
<tr>
<td style="vertical-align: top">Location: 	</td>
<td style="font-weight: bold">Munich TBD</td>
</tr>
<tr>
<td style="vertical-align: top">Price: 	</td>
<td style="font-weight: bold">700 € (incl. food/drinks)<br />Hotel costs/lodging are separate</td>
</tr>
<tr>
<td style="vertical-align: top">Skill Level: 	</td>
<td style="font-weight: bold">Intermediate: some web development and JavaScript experience is expected.</td>
</tr>
<tr>
<td style="vertical-align: top">Trainers:
	</td>
<td style="font-weight: bold">Pete Higgins, Dylan Schiemann, Nikolai Onken,<br />
Tobias von Klipstein, Wolfram Kriesing</td>
</tr>
<tr>
<td style="vertical-align: top">Language:
	</td>
<td style="font-weight: bold">English</td>
</tr>
</table>
<h2>Course Description</h2>
<p>Ajax and Web 2.0 development are easy to learn but take significant effort to master. This workshop accelerates the process by teaching you the essential knowledge and best practices needed to quickly become more productive with Dojo, the most widely used Ajax toolkit in enterprise application development.</p>
<h3>Day 1, May 7, 2009</h3>
<ul>
<li>Kickoff
<ul>
<li>Course overview, getting set.</li>
<li>Getting comfortable with the development environment,<br />
tools including FireBug to do efficient Dojo development</li>
<li>Dojo core/base in depth: all the essentials for any web<br />
application or web site</li>
</ul>
</li>
<li>Building applications the Dojo way
<ul>
<li>How do I structure my Dojo app?</li>
<li>Code architecture</li>
<li>Taking some shortcuts using functional approaches, AOP and other<br />
modern techniques.</li>
</ul>
</li>
<li>Improving the User Experience with Dijit
<ul>
<li>dojo.fx, Dojo&#8217;s on-board effects system</li>
<li>Using Dijit</li>
<li>Customizing and styling existing widgets</li>
<li>Creating a custom widget using the DTL template language</li>
</ul>
<li>Applied Dojo
<ul>
<li>Hands-on session to apply the lessons learned in Day 1 to start<br />
building an application</li>
</ul>
</li>
</ul>
<h3>Day 2, May 8, 2009</h3>
<ul>
<li> Creating your own Dijit
<ul>
<li>Understanding the widget system in depth</li>
<li>Creating a new Dijit</li>
<li>Creating a Dijit theme</li>
</ul>
</li>
<li>Real-time Dojo
<ul>
<li>Grids, Charts and dojo.data</li>
<li>How to use cometD</li>
</ul>
</li>
<li>Optimization
<ul>
<li>Verify your functionality using DOH testing</li>
<li>Getting the application into production &#8211; the Dojo build system</li>
<li>Profiling, Analyzing and Optimization of your application</li>
</ul>
</li>
<li>Applied Dojo
<ul>
<li>Hands on session to create an application based on the lessons<br />
learned in this workshop</li>
</ul>
</li>
</ul>
<p>Though 16 hours is not enough time to cover every feature, we will show you the features that help you get the most out of Dojo and make you immediately productive with Dojo. At the end of the course, armed with your knowledge of the core Dojo features and many of the extras, you&#8217;ll know how to best leverage Dojo in your project. Throughout the workshop you will be guided through best practices and approaches for using Dojo, gaining insight from the SitePen and uxebu teams&#8217; years of building web apps and creating the Dojo Toolkit.</p>
<h2>By the end of this comprehensive workshop, you will know:</h2>
<ul>
<li>How to set up a Dojo application and use the Dojo Toolkit<br />
efficiently</li>
<li>The Core Dojo APIs and proper selection of APIs essential to<br />
development goals</li>
<li>How to debug your source code and optimize application<br />
performance</li>
<li>Secrets of expert developers in pragmatic and effective<br />
Dojo-based web development</li>
</ul>
<h2>Bonus</h2>
<p>All attendees will receive a copy of <a target="_blank" href="http://dojocampus.org/content/2008/09/07/dojo-the-definitve-guide/">Dojo: The Definitive Guide</a>.  Additionally, if you stick around for another day, and join us for the next free dojo.beer() on May 9th, 2009, this time with two special guests (guess who). A separate announcement will be made later with more details.</p>
<h2>About the Instructors</h2>
<p>You will get an excellent set of instructors for this event: Pete Higgins (Dojo Project Lead), Dylan Schiemann (co-founder of Dojo and SitePen), Nikolai Onken (co-founder of uxebu, Dojo community evangelist, and Dojo widget themes and CSS maestro), Tobias von Klipstein and Wolfram Kriesing (both co-founders of uxebu).</p>
<h2>Sign-up</h2>
<p>If you want to sign-up for the Dojo course, please send an email to workshop ( at ) uxebu.com and we will send you more information.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/03/19/uxebu-sitepen-dojo-training-in-europe-may-7th8th/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Pure Client-side Dojo API Docs</title>
		<link>http://uxebu.com/blog/2009/03/12/pure-client-side-dojo-api-docs/</link>
		<comments>http://uxebu.com/blog/2009/03/12/pure-client-side-dojo-api-docs/#comments</comments>
		<pubDate>Thu, 12 Mar 2009 20:43:26 +0000</pubDate>
		<dc:creator>wolfram</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[development tools]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[uxebu]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[documentation]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=125</guid>
		<description><![CDATA[It was a project last year, where yet another inline documentation syntax was &#8220;created&#8221; and suggested to be used. That triggered our brains and they started spinning caused by the unhappiness of reinventing the wheel, especially for something that is still too much of a step-child for frontend engineers and doesn&#8217;t get the necessary dedication [...]]]></description>
			<content:encoded><![CDATA[<p>It was a project last year, where yet another inline documentation syntax was &#8220;created&#8221; and suggested to be used. That triggered our brains and they started spinning caused by the unhappiness of reinventing the wheel, especially for something that is still too much of a step-child for frontend engineers and doesn&#8217;t get the necessary dedication anyway, the JavaScript inline docs. So let&#8217;s give them some love :-).</p>
<p>Fast forwarding &#8230; what came out of it is the <a href="http://dojodocs.uxebu.com" target="_blank">API docs viewer</a> which, we here at uxebu, built over the christmas holidays. It is completely client-based, for creating the documentation and retreiving all the information, no server-side code is needed anymore, it&#8217;s all done in <a href="http://dojotoolkit.org" target="_blank">dojo</a>.<br />
<span id="more-125"></span></p>
<p>If you want to see a detailed introductional video, sit back, relax and enjoy the following screencast:</p>
<p><center><br />
<object width="600" height="375"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3600935&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3600935&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="375"></embed></object><br /><a href="http://vimeo.com/3600935">JavaScript API Docs preview video</a> from <a href="http://vimeo.com/uxebu">uxebu</a> on <a href="http://vimeo.com">Vimeo</a>.<br />
</center></p>
<p style="margin-top: 30px;"><center><a href="http://dojodocs.uxebu.com/" target="_blank"><img src="http://hub.uxebu.com:33550/wp-content/uploads/2009/03/apidocslaunch.gif" /></a></center></p>
<h2>Inline doc styles</h2>
<p>There are a couple of JavaScript inline documentation tools and styles out there, but no real standard has evolved yet. Maybe because of JavaScript&#8217;s dynamic nature it&#8217;s hard to fix it to just one style. Though this just makes the task more interesting, actually. </p>
<p>Let&#8217;s take a step back and take a look at just three of the various different inline doc styles.</p>
<p>The <em>jQuery way</em>, pretty much textual.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">// Execute a callback for every element in the matched set.</span><br />
<span style="color: #006600; font-style: italic;">// (You can seed the arguments with an array of args, but this is</span><br />
<span style="color: #006600; font-style: italic;">// only used internally.)</span><br />
each<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> callback<span style="color: #339933;">,</span> args <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></td></tr></tbody></table></div>
<p>The <em>YUI way</em>, as you will see it&#8217;s very JavaDoc like, the method is documented above the actual definition and uses the @ sign for identifiers.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #006600; font-style: italic;">/**<br />
&nbsp;* Returns a string without any leading or trailing whitespace. &nbsp;If <br />
&nbsp;* the input is not a string, the input will be returned untouched.<br />
&nbsp;* @method trim<br />
&nbsp;* @since 2.3.0<br />
&nbsp;* @param s {string} the string to trim<br />
&nbsp;* @return {string} the trimmed string<br />
&nbsp;*/</span><br />
trim<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span></div></td></tr></tbody></table></div>
<p>The <em>dojo way</em>, with proprietary identifiers, inside the function code!</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dojo.<span style="color: #660066;">trim</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; summary:</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; &nbsp; &nbsp; Trims whitespace from both sides of the string</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; str: String</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; &nbsp; &nbsp; String to be trimmed</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; returns: String</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; &nbsp; &nbsp; Returns the trimmed string</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; description:</span><br />
&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">//&nbsp; &nbsp; &nbsp; This version of trim() was selected for inclusion into the base due ...</span></div></td></tr></tbody></table></div>
<p>We see that there are different levels of depth and explicitness in the inline comments. But they all have in common, that important and interesting information are contained inside the source code, that should be exposed to the users of those APIs.</p>
<h2>The __doc__ approach</h2>
<p>In python, a certain type of comments is available as the docstring property __doc__ of the function it is in. This was actually the initial idea, to provide the docs in this kind of way:</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">dojo.<span style="color: #660066;">trim</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span><br />
dojo.<span style="color: #660066;">trim</span>.__doc__ <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; summary<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Trims whitespace from both sides of the string&quot;</span><span style="color: #339933;">,</span><br />
&nbsp; &nbsp; returns<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>type<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;String&quot;</span><span style="color: #339933;">,</span> summary<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Returns the trimmed string&quot;</span><span style="color: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>It&#8217;s is pretty obvious, that this is is pretty ugly source code in the first place and secondly a comment is not a comment anymore but becomes source code. Prone to errors, and not really leading to higher productivity, we realized that this approach was actually just a learning stage.<br />
Still it is pretty handy to use the command line in FireBug and have the docs at hand via autocompletion e.g. just typing <em>dojo.trim.__doc__</em> and the docs are there (this feature is currently also implemented, but the __doc__ property must be generated by a function call afterwards and it is not in the main focus for the current state of the project).</p>
<h2>The less disruptive approach</h2>
<p>Since the __doc__ approach has the ugly side effect that library authors would have to change all their source code it was dismissed pretty quickly. New ways had to be explored. Driven by the flexibility of JavaScript and it&#8217;s dynamic nature we found a nice mix of reflection and minimal file parsing that allows us to extract the information from the existing raw (unpacked and not minified!) source code, without the need to modify it upfront.</p>
<p>First comes <strong>the reflection</strong>. Using the simple for-in loop over the prototype and the object itself allows us to extract all the methods and properties. Applying a little bit of logic using toString() and alikes and we know if the implementation of this object overrides, inherites or creates this method, we find out the default value of properties and a lot more. In the special case of dojo we can also easily find out the parent class(es). The reflection is actually worth a separate article, since it is quite powerful and allows deep insights into a class&#8217;s inner values.</p>
<p>Second step is <strong>simple file parsing</strong>. Since we know that object &#8220;foo&#8221; has the method &#8220;bar&#8221;, we know that in the source code we can find the definition by looking for the following patterns:</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">foo.<span style="color: #660066;">bar</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: #009900;">&#125;</span><br />
<span style="color: #006600; font-style: italic;">// OR</span><br />
foo <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span><br />
&nbsp; &nbsp; bar<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: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span><br />
<span style="color: #006600; font-style: italic;">// OR</span><br />
foo <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</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><br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">bar</span> <span style="color: #339933;">=</span> &nbsp;<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: #009900;">&#125;</span><br />
<span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>
<p>There are a couple of special but rare other cases, but the patterns are very simple to detect as you can see. So our FileParser doesn&#8217;t really need to understand the JavaScript syntax, it is just looking for exact patterns and is therefore quite fast (we can surely still improve on the performance!).<br />
Using regular expressions we also find out the parameters and the actual docstring itself, which then is parsed by the DocStringParser.</p>
<p>Let&#8217;s summarize. We have an object&#8217;s/class&#8217;s (if you want to call it a class) methods, properties, their according docstring and the docstrings of the class itself. We know the inheritance structure, can determine the type (public, private, etc.) from the name (for now we assume it is private when it starts with an &#8220;_&#8221;) or soon we will use the docstring identifier &#8220;tags&#8221; (which was just shortly introduced into dojo as <a href="http://bugs.dojotoolkit.org/browser/dijit/trunk/_Widget.js?rev=16933#L301">you can see it used here</a>). And we have example code, which is contained in a lot of docstrings. So this is already quite an amount of useful data. Let&#8217;s make them useable.</p>
<h2>Plugging it all together</h2>
<p>The pieces are there, they just need to be plugged together and hopefully a useful API docs viewer will arise. For this special dojo use case, we also had to build a mapper which enables the mapping of a namespace to the correct file(s). E.g. dojo.query() is actually a function inside the <em>dojo</em> object, which would naturally mean it is inside <em>dojo.js</em>, but in this case this method is in a separate file <em>query.js</em> which is &#8220;the knowledge&#8221; of the mapper.</p>
<p>Building the namespace tree was another challenge, loading all the files in the browser and inspecting the entire namespace via JavaScript would just be an aweful waste of resources. So currently there is a small python script which generates the JSON files which contain the contents of the tree to the left. But the high flexibility of using dynamic extending of objects (like e.g. <a href="http://bugs.dojotoolkit.org/browser/dojo/trunk/NodeList-fx.js?rev=12797#L10">NodeList-fx does</a>) mixins and other things make it hard to rely purely on the generated contents of the tree, so they are partly hand-crafted too.</p>
<p><a href='http://blog.uxebu.com/wp-content/uploads/2009/03/dojo-ui.jpg' style="float:right; padding:5px"><img src="http://blog.uxebu.com/wp-content/uploads/2009/03/dojo-ui.jpg" alt="dojo UI example" title="dojo-ui" width="192" height="49" class="size-full wp-image-127" /></a>The UI is purely dojo, showing off some of the neat features, like the slick ExpandoPane. In my eyes it looks very nice, with a lot of attention to the detail. The UI was actually the part that needed the least time to build, thanks to Nikolai&#8217;s deep knowledge it was a piece of cake. There are of course a couple of glitches like the wrapping of the tabs, but hopefully this is just another kick in the right direction to speed up those kind of fixes. Because what is there is already much more than just the base of a GUI toolkit with some widgets, it is a full-fledged-ready-to-go-batteries-included-kick-ass set of UI components. (Ok, enough wallowing, yes I am biased :-).) So look for yourself and let us know what you think.</p>
<h2>The future</h2>
<p>As you know it too, working on those kind of projects always spins off a lot of new ideas. So we want to share some with you and maybe even get some help on some of them. First: we will put the source code out on google code (or alike) and it will be open for contributions, of course. We just need to do some renaming to ensure future-proof enhancements won&#8217;t just clobber this thing and make it unmaintainable.</p>
<p>Another idea is to configure the API docs viewer for custom namespaces and as long as the inline comments are dojo style it should be just a snap of a finger to get your own project&#8217;s API docs out. Well, actually the snap of a finger is the creation of the above mentioned JSON file, which contains the tree structure. But one day we will also have an auto-detector which builds the tree initially out of traversing through a given existing namespace (given that it is entirely loaded).</p>
<p>Idea No. 734 :-) was to provide the API viewer for other libraries too. The architecture is made this way, that the reflection and file parsing are separated and could be extended to work with another inline doc style syntax (we made first experiments with it). In order to do this right we think about having a common interface where to put and get the apidoc data from. A json-schema for API doc data is required. I have started on one, but this task really is huge when done right.</p>
<p>Of course the __doc__ property will be provided. Currently when working with libraries or function that I don&#8217;t know I mostly use toString() on it and learn from the source code. I could also very well imagine myself using __doc__ if it was there. So keep looking for that, I think it can change the way one uses the FireBug console and learns about libraries.</p>
<p>Since we know all the objects, methods on the one hand and the according docs on the other hand we can tell how good the doc coverage is. This heads into the direction of continuous integration and imho that is really where JavaScript still has a long way to go.</p>
<p>And there are a couple more ideas, like running the inline doctests in the UI, integrating the API viewer with Bespin and allowing to throw the api viewer onto any page using a bookmarklet, which would nicely let you browse the JavaScript API of any site, no matter if you want to learn, fix something or whatever. To mention just some of the ideas &#8230;</p>
<p>Now if you want to get your hands dirty and play with the code, see how it can integrate with your own code or just have offline dojo api documentation, drop us an email ( labs (a t) uxebu.com ) and we will make sure a copy of the code lands in your mailbox. Also, if you find bugs, have ideas, want to contribute, contact us and we will exchange ideas to make this tool the best available javascript api viewer out there.</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/03/12/pure-client-side-dojo-api-docs/feed/</wfw:commentRss>
		<slash:comments>32</slash:comments>
		</item>
		<item>
		<title>dojo.map and jQuery.map</title>
		<link>http://uxebu.com/blog/2009/01/27/dojomap-and-jquerymap/</link>
		<comments>http://uxebu.com/blog/2009/01/27/dojomap-and-jquerymap/#comments</comments>
		<pubDate>Tue, 27 Jan 2009 16:32:03 +0000</pubDate>
		<dc:creator>wolfram</dc:creator>
				<category><![CDATA[dojo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[functional]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[map]]></category>

		<guid isPermaLink="false">http://blog.uxebu.com/?p=117</guid>
		<description><![CDATA[In one of our current customer&#8217;s projects we are working with jQuery. And I am glad that the functional programming basics are already kind of standard across JS libraries. Especially with dojo I started to love the functional approaches and realized that they are really helpful in a lot of situations, especially when doing data [...]]]></description>
			<content:encoded><![CDATA[<p>In one of our current customer&#8217;s projects we are working with jQuery. And I am glad that the functional programming basics are already kind of standard across JS libraries. Especially with dojo I started to love the functional approaches and realized that they are really helpful in a lot of situations, especially when doing data processing. One of the best known functions is the map function, which &#8220;creates a new array with the results of calling a provided function on every element in this array&#8221; [from <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Array/map">Mozilla's Core JS References</a>]. Though dojo and jQuery implement this function there are slight differences.<br />
<span id="more-117"></span></p>
<p>The root of all evil was a simple function that was searching for certain information in some data and returning me a piece of those, it looked like this:</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&gt;&gt;&gt;</span> jQuery.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> n.<span style="color: #660066;">id</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">?</span> n.<span style="color: #660066;">id</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
&nbsp; &nbsp; .<span style="color: #660066;">filter</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> n<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>Looks pretty simple, but it failed in IE. There is some problem with the filter() function in IE, it just barks when I run the following</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&gt;&gt;&gt;</span> jQuery.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</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: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">filter</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: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
Object doesn<span style="color: #3366CC;">'t support this property or method</span></div></td></tr></tbody></table></div>
<p>May be I oversaw some really simple error I made. But anyway, that lead me to debugging this thing and trying stuff out and I discovered that the following happens.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&gt;&gt;&gt;</span> jQuery.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</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: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>But I was very sure that dojo would return an array of three elements with null each. So I tried that of course.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&gt;&gt;&gt;</span> dojo.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</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: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#91;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>Aha, that&#8217;s what I expected. So jQuery just does it a little different. Ok, good to know, this again means that I can cut my initial script shorter, by just removing the filter() call. Good thing.</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&gt;&gt;&gt;</span> jQuery.<span style="color: #660066;">map</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> n.<span style="color: #660066;">id</span><span style="color: #339933;">&gt;</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">?</span> n.<span style="color: #660066;">id</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#91;</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>So that this works and only returns the id if it is larger than 1, which is actually the case that I need. While I find this quite handy and had wished for it a lot of times in dojo too, I see it as rather inconsistent, simply because it is a special case, you would need to know about.<br />
Since Firefox3 comes with the map() function already implemented (so it must be at least JavaScript 1.6) I tried the native method:</p>
<div class="codecolorer-container javascript twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="javascript codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">&gt;&gt;&gt;</span> <span style="color: #009900;">&#91;</span><span style="color: #CC0000;">1</span><span style="color: #339933;">,</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span><span style="color: #CC0000;">3</span><span style="color: #009900;">&#93;</span>.<span style="color: #660066;">map</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: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #009900;">&#91;</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#93;</span></div></td></tr></tbody></table></div>
<p>And as I expected it does return the elements in the array, just like dojo does.<br />
So note jQuery does it differently. Which is kind of ok, since the map() function is implemented in it&#8217;s own namespace and does not override the native map() function but I find it confusing.<br />
And dojo just does it as the map() function which is defined in the JavaScript spec.<br />
Just in case someone else stumbles over it &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://uxebu.com/blog/2009/01/27/dojomap-and-jquerymap/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

