<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Jonathan Bond-Caron - Ideas &amp; Experiments - JavaScript</title>
    <link>http://jbondc.openmv.com/</link>
    <description>Jonathan Bond-Caron - Ideas &amp; Experiments</description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.1.3 - http://www.s9y.org/</generator>
    <pubDate>Thu, 14 Feb 2008 20:52:56 GMT</pubDate>

    <image>
        <url>http://jbondc.openmv.com/templates/mv/img/s9y_banner_small.png</url>
        <title>RSS: Jonathan Bond-Caron - Ideas &amp; Experiments - JavaScript - Jonathan Bond-Caron - Ideas &amp; Experiments</title>
        <link>http://jbondc.openmv.com/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Running dojo or javascript tookit on the SERVER side?</title>
    <link>http://jbondc.openmv.com/archives/7-Running-dojo-or-javascript-tookit-on-the-SERVER-side.html</link>
            <category>JavaScript</category>
    
    <comments>http://jbondc.openmv.com/archives/7-Running-dojo-or-javascript-tookit-on-the-SERVER-side.html#comments</comments>
    <wfw:comment>http://jbondc.openmv.com/wfwcomment.php?cid=7</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://jbondc.openmv.com/rss.php?version=2.0&amp;type=comments&amp;cid=7</wfw:commentRss>
    

    <author>nospam@example.com (Jonathan Bond-Caron)</author>
    <content:encoded>
    If you are not familiar with .NET and the precious runat=&quot;server&quot; or runat=&quot;client&quot;, have a look a at: http://www.aptana.com/jaxer&lt;br /&gt;
&lt;br /&gt;
The idea is simple and very very practical. In some situations, you may want to run code on the server OR on the client. The problem with a lot of javascript frameworks is they do a LOT of work on the client side. What if we could make the server work a little harder?&lt;br /&gt;
&lt;br /&gt;
Based on John Resig&#039;s work, &lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://ejohn.org/blog/bringing-the-browser-to-the-server/&quot; &gt;http://ejohn.org/blog/bringing-the-browser-to-the-server/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
I convinced myself I could create a &quot;template parser&quot; for dijit widgets that would read the following tags:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;lt;dijit:form:CheckBox id=&quot;cb&quot; runat=&quot;server&quot;/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;dijit:form:CheckBox id=&quot;cb2&quot; runat=&quot;client&quot;/&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The first part was making sure that a dijit widget could be created on the server side.&lt;br /&gt;
Amazingly after some tweaks, this works:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
C:\Utils&gt;java -jar js.jar&lt;br /&gt;
Rhino 1.6 release 7 2007 08 19&lt;br /&gt;
js&gt; load(&#039;env.js&#039;);&lt;br /&gt;
js&gt; window.location = &#039;test.html&#039;;&lt;br /&gt;
test.html&lt;br /&gt;
js&gt; var djConfig = {baseUrl: &quot;Z:/GDECORE/js/OpenAjax/dojo/&quot;};&lt;br /&gt;
js&gt; load(&#039;Z:/GDECORE/js/OpenAjax/dojo/dojo.js&#039;);&lt;br /&gt;
js&gt; dojo.require(&#039;dojo._base.html&#039;);&lt;br /&gt;
[object Object]&lt;br /&gt;
js&gt; dojo.require(&#039;dijit.form.CheckBox&#039;);&lt;br /&gt;
[object Object]&lt;br /&gt;
js&gt; var widget = new dijit.form.CheckBox({id: &quot;cb&quot;, name: &quot;cb&quot;}, dojo.byId(&quot;test&quot;));&lt;br /&gt;
js&gt; print(dojo.body().innerHTML);&lt;br /&gt;
&amp;lt;div role=&#039;presentation&#039; waiRole=&#039;presentation&#039; class=&#039;dijitReset dijitInline dijitCheckBox&#039; widgetId=&#039;cb&#039;&amp;gt;&amp;lt;input dojoAttachEvent=&#039;onmouseover:_onMous&lt;br /&gt;
e,onmouseout:_onMouse,onclick:_onClick&#039; id=&#039;cb&#039; class=&#039;dijitReset dijitCheckBoxInput&#039; value=&#039;on&#039; tabindex=&#039;0&#039; type=&#039;checkbox&#039; dojoAttachPoint=&#039;focusNo&lt;br /&gt;
de&#039; name=&#039;cb&#039;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The template parser has now been written and several more tests are needed before a first release!&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Thu, 14 Feb 2008 15:30:43 -0500</pubDate>
    <guid isPermaLink="false">http://jbondc.openmv.com/archives/7-guid.html</guid>
    
</item>
<item>
    <title>Integrating jquery, dojo and Ext-js</title>
    <link>http://jbondc.openmv.com/archives/2-Integrating-jquery,-dojo-and-Ext-js.html</link>
            <category>JavaScript</category>
    
    <comments>http://jbondc.openmv.com/archives/2-Integrating-jquery,-dojo-and-Ext-js.html#comments</comments>
    <wfw:comment>http://jbondc.openmv.com/wfwcomment.php?cid=2</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://jbondc.openmv.com/rss.php?version=2.0&amp;type=comments&amp;cid=2</wfw:commentRss>
    

    <author>nospam@example.com (Jonathan Bond-Caron)</author>
    <content:encoded>
    I am sure a lot of you have often wondered: why can&#039;t open-source javascript frameworks like dojo, YUI, jquery, prototype and the gazillion number of other alternatives work together? Why should I have to choose one framework over another when all I want is nice widget X from framework A  and nice widget Y from framework B? How far apart are the frameworks and how complicated would it be to have some level of integration?&lt;br /&gt;
&lt;br /&gt;
First off, lets remember that each framework is built according to certain interests and goals in mind. This is fine and each framework is expected to take their own approach to solving similar problems. What really frustrates me is the energy and time that goes in open-source javascript toolkits / frameworks (call them whatever you like) and the lack of interoperability, collaboration between these competing toolkits. There&#039;s any amazing amount of (free) time that is wasted developing &quot;competing&quot; widgets while that time could be spent developing open-source components that are re-usable for other toolkits. &lt;br /&gt;
&lt;br /&gt;
Given the frustration, I finally decided to do something about it and looked at how most frameworks could be integrated. &lt;br /&gt;
The results of the first step can be seen here: &lt;a href=&quot;http://www.openmv.com/tests/dojo-ext-jquery.html&quot;  title=&quot;Integration of Dojo, Ext-Js, jquery&quot;&gt;&lt;b&gt;http://www.openmv.com/tests/dojo-ext-jquery.html&lt;/b&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;First Step?&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
The first step to me was clear, given the source of a javascript file, I needed to be able to figure out what this file needs to run successfully (its dependencies). After some research on a couple of frameworks, it appeared that Dojo had done a fair amount of good work in this area.&lt;br /&gt;
&lt;br /&gt;
In dojo, each javascript file has a: &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
dojo.provide(&#039;dijit.layout.ContentPane&#039;)&lt;br /&gt;
dojo.require(&quot;dijit._Widget&quot;);&lt;br /&gt;
dojo.require(&quot;dojo.parser&quot;);&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Mainly each javascript file declares what it provides (dojo.provide) and what it needs (dojo.require) -- its dependencies.&lt;br /&gt;
&lt;br /&gt;
This sounds like a great start! But can we force other frameworks to use a dojo.require? Would this mean that a piece of the dojo base would be required in other frameworks? This doesn&#039;t seem at all ideal, especially if all you want to use is jquery. What we need is some sort &quot;I play nice with other frameworks&quot; interface.  &lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Proposed Solution?&lt;/strong&gt;&lt;br /&gt;
The WTI (Web Toolkit Interface).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;&lt;a href=&quot;http://www.openmv.com/tests/resources/js/wti.js&quot;  title=&quot;WTI&quot;&gt;http://www.openmv.com/tests/resources/js/wti.js&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In short, by simply adding the following 5 lines to dojo:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
if(typeof window.wti == &quot;undefined&quot;) {&lt;br /&gt;
  var wti = dojo;&lt;br /&gt;
  var wti.require = dojo.require;&lt;br /&gt;
  var wti.provide = dojo.provide;&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
The toolkit now says &quot;Yes, I play nice other frameworks&quot; (by implementing the WTI interface). So now that we have 1 framework thats taken care of, we also want jquery and Ext-JS to play nice. &lt;br /&gt;
&lt;br /&gt;
We can do this by adding these 5 lines to jquery and Ext-JS:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
if(typeof window.wti == &quot;undefined&quot;) {&lt;br /&gt;
	var wti = {};&lt;br /&gt;
	wti.provide = function(resourceId) {};&lt;br /&gt;
	wti.require = function(resourceId, /*optional*/resourceType) {};&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
That&#039;s it?! This is going to work? Not quite, each javascript file must then declare what it provides and what it requires: &lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
wti.provide(&#039;jquery.interface.ifxscale&#039;);&lt;br /&gt;
&lt;br /&gt;
wti.require(&#039;jquery.base&#039;);&lt;br /&gt;
wti.require(&#039;jquery.interface.ifx&#039;);&lt;br /&gt;
wti.require(&#039;jquery.interface.iutil&#039;);&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Given these modifications, we now know enough information about each javascript files to integrate the frameworks / toolkits together. To give a small demo, I tweaked a little the dojo builder (to look for wti.require), and managed to compress jquery, Ext-js and dijit into 1 single file.   &lt;br /&gt;
&lt;br /&gt;
You can view the end result here&lt;br /&gt;
&lt;a href=&quot;http://www.openmv.com/tests/dojo-ext-jquery.html&quot;  title=&quot;Integration of Dojo, Ext-Js, jquery&quot;&gt;&lt;strong&gt;http://www.openmv.com/tests/dojo-ext-jquery.html&lt;/strong&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Basically this works: &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
		dojo.require(&quot;dijit.layout.ContentPane&quot;);&lt;br /&gt;
		dojo.require(&quot;dijit.layout.TabContainer&quot;);&lt;br /&gt;
		&lt;br /&gt;
		// Load jquery animations&lt;br /&gt;
		dojo.require(&#039;jquery.interface.ifxscale&#039;);&lt;br /&gt;
		dojo.require(&#039;jquery.interface.ifxshake&#039;);&lt;br /&gt;
&lt;br /&gt;
		// Use jquery as $ selector&lt;br /&gt;
		var $ = jQuery;&lt;br /&gt;
		&lt;br /&gt;
		// Load Ext resources&lt;br /&gt;
		dojo.require(&#039;Ext.ux.Accordion&#039;);&lt;br /&gt;
		dojo.require(&#039;Ext.widgets.DatePicker&#039;);&lt;br /&gt;
		dojo.require(&#039;Ext.widgets.layout.ContentPanels&#039;);&lt;br /&gt;
		dojo.require(&#039;Ext.widgets.layout.BorderLayout&#039;);&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
I will of course be making all work available online, and contributing patches to dojo, jquery, Ext-js. This is a simple proposal that I hope will motivate some level of interoperability between javascript frameworks in one form or another. &lt;br /&gt;
&lt;br /&gt;
Comments are very much welcome. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Step 2?&lt;/strong&gt;&lt;br /&gt;
The next step will consist of modifying javascript files so they declare other types of media / resources they depend on, for example: &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
wti.provide(&#039;dijit.layout.ContentPane&#039;)&lt;br /&gt;
&lt;br /&gt;
wti.require(&quot;dijit._Widget&quot;);&lt;br /&gt;
wti.require(&quot;dojo.parser&quot;);&lt;br /&gt;
wti.require(&quot;dijit.themes.dijit&quot;, &#039;.css&#039;);&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
 
    </content:encoded>

    <pubDate>Sun, 12 Aug 2007 13:37:20 -0400</pubDate>
    <guid isPermaLink="false">http://jbondc.openmv.com/archives/2-guid.html</guid>
    
</item>

</channel>
</rss>