<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>Javascript</title><link>http://blogs.acceleration.net/russ/category/41.aspx</link><description>JS jizzajazza</description><managingEditor>Russ</managingEditor><dc:language>en-US</dc:language><generator>.Text Version 0.95.2004.102</generator><item><dc:creator>Russ</dc:creator><title>Javascript Shell Server</title><link>http://blogs.acceleration.net/russ/archive/2005/08/01/1925.aspx</link><pubDate>Mon, 01 Aug 2005 21:26:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/08/01/1925.aspx</guid><description>So it finally happened...  We have had our own version of the &lt;a href="http://www.squarefree.com/shell/"&gt;javascript shell&lt;/a&gt; brewing over here for quite a while.  Our version has been growing more and more divergent from the &lt;a href="http://ted.mielczarek.org/code/mozilla/extensiondev/"&gt;Extension Developer&lt;/a&gt; version.  &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; &lt;a href="http://blogs.acceleration.net/birdman/archive/2005/06/02/1210.aspx"&gt;mentioned that he had incorporated Emacs&lt;/a&gt; into the mix a while back.  Today we I spent a few hours rewriting the autocomplete, so that it is much more readable, and hopefully, much easier to modify in the future.  Our goal being to bring the results back to Emacs, thus giving us intelligent emacs autocomplete for javascript. 
&lt;br /&gt;&lt;br /&gt;

&lt;a href="http://birdman.acceleration.net/JsShellServer/shellserver.xpi"&gt;
This is our shell packaged up as a standalone extension&lt;/a&gt; (that can be run along side of the extension developer if you wish).  The xpi contains &lt;a href="http://birdman.acceleration.net/JsShellServer/js-mode.el"&gt;js-mode.el&lt;/a&gt; (thanks a bunch Helmut Eller) which needs to be installed in emacs.

Check Nathan's &lt;a href="http://blogs.acceleration.net/birdman/archive/2005/06/02/1210.aspx"&gt;post&lt;/a&gt; for more instructions.  &lt;br /&gt;&lt;br /&gt;

Now that we have taken the initiative to separate our version of the shell, I foresee more improvements in the future.  I plan on posting an actual page about the extension and how to get it properly installed in emacs and what not tomorrow.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1925.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">So it finally happened...  We have had our own version of the <a href="http://www.squarefree.com/shell/">javascript shell</a> brewing over here for quite a while.  Our version has been growing more and more divergent from the <a href="http://ted.mielczarek.org/code/mozilla/extensiondev/">Extension Developer</a> version.  <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> <a href="http://blogs.acceleration.net/birdman/archive/2005/06/02/1210.aspx">mentioned that he had incorporated Emacs</a> into the mix a while back.  Today we I spent a few hours rewriting the autocomplete, so that it is much more readable, and hopefully, much easier to modify in the future.  Our goal being to bring the results back to Emacs, thus giving us intelligent emacs autocomplete for javascript. 
<br /><br />

<a href="http://birdman.acceleration.net/JsShellServer/shellserver.xpi">
This is our shell packaged up as a standalone extension</a> (that can be run along side of the extension developer if you wish).  The xpi contains <a href="http://birdman.acceleration.net/JsShellServer/js-mode.el">js-mode.el</a> (thanks a bunch Helmut Eller) which needs to be installed in emacs.

Check Nathan's <a href="http://blogs.acceleration.net/birdman/archive/2005/06/02/1210.aspx">post</a> for more instructions.  <br /><br />

Now that we have taken the initiative to separate our version of the shell, I foresee more improvements in the future.  I plan on posting an actual page about the extension and how to get it properly installed in emacs and what not tomorrow.<img src ="http://blogs.acceleration.net/russ/aggbug/1925.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>IE bug in dynamically added select options</title><link>http://blogs.acceleration.net/russ/archive/2005/07/27/1849.aspx</link><pubDate>Wed, 27 Jul 2005 17:16:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/27/1849.aspx</guid><description>If you add options to a select dynamically via javascript, IE will not render this correctly until you have opened and closed the select menu a few time.  To get around this you just need to remove the select from the DOM then add it back.  Setting the innerHTML will not help things :(  Unfortunatly, setting the innerHTML causes bugs in both major browsers.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1849.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">If you add options to a select dynamically via javascript, IE will not render this correctly until you have opened and closed the select menu a few time.  To get around this you just need to remove the select from the DOM then add it back.  Setting the innerHTML will not help things :(  Unfortunatly, setting the innerHTML causes bugs in both major browsers.<img src ="http://blogs.acceleration.net/russ/aggbug/1849.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Oh Spider Monkey why doest thou keep secrets from me</title><link>http://blogs.acceleration.net/russ/archive/2005/07/21/1834.aspx</link><pubDate>Thu, 21 Jul 2005 17:46:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/21/1834.aspx</guid><description>There are so many hidden things inside of the javascript implementations that it is a constant frustration.  I happen to like javascript an awful lot, but damn this language/environment for being so fickle.
&lt;br /&gt;&lt;br /&gt;
The magic functions/properties I found are listed below.  They solve one of my biggest problems with the javascript getter/setter system that &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; &lt;a href="http://blogs.acceleration.net/birdman/archive/2005/04/28/1055.aspx"&gt;wrote about here&lt;/a&gt;, which is that by doing what &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; was doing, we couldn't find a way to get a reference to the actual function doing the getting/setting.  I really hate that these are totally hidden.
&lt;br /&gt;&lt;br /&gt;
__proto__ : a reference to the current instances prototype (deprecated in Rhino)&lt;br /&gt;
__defineGetter__('propName', func) :  creates a getter function with the name provided as the first argument&lt;br /&gt;
__defineSetter__('propName', func) :  creates a Setter function with the name provided as the first argument&lt;br /&gt;
__lookupGetter__('propName') :  gets a reference to the getter function of a given property (whose name is passed as an argument)&lt;br /&gt;
__lookupSetter__('propName') :  gets a reference to the setter function of a given property (whose name is passed as an argument)&lt;br /&gt;
&lt;br /&gt;
__parent__ seems to return the scope that something is defined in, but we cant really get this to do anything reliably and its also deprecated.  &lt;a title="Birdman" href="http://blogs.acceleration.net/birdman/"&gt;Nathan&lt;/a&gt; seems to think that this is what a closure uses to keep track of its scope.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1834.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">There are so many hidden things inside of the javascript implementations that it is a constant frustration.  I happen to like javascript an awful lot, but damn this language/environment for being so fickle.
<br /><br />
The magic functions/properties I found are listed below.  They solve one of my biggest problems with the javascript getter/setter system that <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> <a href="http://blogs.acceleration.net/birdman/archive/2005/04/28/1055.aspx">wrote about here</a>, which is that by doing what <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> was doing, we couldn't find a way to get a reference to the actual function doing the getting/setting.  I really hate that these are totally hidden.
<br /><br />
__proto__ : a reference to the current instances prototype (deprecated in Rhino)<br />
__defineGetter__('propName', func) :  creates a getter function with the name provided as the first argument<br />
__defineSetter__('propName', func) :  creates a Setter function with the name provided as the first argument<br />
__lookupGetter__('propName') :  gets a reference to the getter function of a given property (whose name is passed as an argument)<br />
__lookupSetter__('propName') :  gets a reference to the setter function of a given property (whose name is passed as an argument)<br />
<br />
__parent__ seems to return the scope that something is defined in, but we cant really get this to do anything reliably and its also deprecated.  <a title="Birdman" href="http://blogs.acceleration.net/birdman/">Nathan</a> seems to think that this is what a closure uses to keep track of its scope.<img src ="http://blogs.acceleration.net/russ/aggbug/1834.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Writing HTML in Javascript</title><link>http://blogs.acceleration.net/russ/archive/2005/07/08/1752.aspx</link><pubDate>Fri, 08 Jul 2005 17:35:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/08/1752.aspx</guid><description>Lately Ive been writing alot of HTML as javascript using a function Ive named createNode in my &lt;a href="http://blogs.acceleration.net/russ/articles/1751.aspx"&gt;Controls Library&lt;/a&gt;
&lt;br /&gt;&lt;br /&gt;
example:
&lt;div style="padding:5px; border:1px solid black;background-color:#EFEFFF;white-space:pre"&gt;// The strings with curly braces are binding points with names matching the columns of my datasource
var cn = Controls.createNode;
var template = cn('tr', {}, 
               cn('td', {'class':"topCell", style:'width:75;'}, 
                  '{StoreNumber}'),
               cn('td', {'class':"topCell", style:'width:100;'}, 
                  '{Name}'),
               cn('td', {'class':"topCell", style:'width:100;' }, 
                  '{Metro}'),
               cn('td', {'class':"topCell", style:'width:250;'}, 
                  "{Address}",
                  cn('br'),
                  "{City}, {State} {Zip}"),
               cn('td', {'class':"topCell", style:'width:150;'}, 
                  cn('textarea', {'class':"displayBox", style:"width:100%;", readonly:"true"},
                     '{PublicPhoneNumbers}')),
               cn('td', {'class':"topCell", style:'width:100;'}, 
                  '{ConnectionType} - {Speed}'),
               cn('td', {'class':"topCell", style:'width:100;'}, 
                  '{UserName}'),
               cn('td', {'class':"topCell", style:'width:150;'}, 
                  '{DateEnteredHistory}'))

&lt;/div&gt;

I was curious how this would square up against redering plain HTML.  I had a feeling that it might be faster since parsing XML is incredibly slow and direct interaction with the DOM is something that JS should theoretically be good at.  In my test I average the rendering time of a 10 column 100 row table over a few page refreshes.  &lt;br /&gt;
The following were the result data:&lt;br /&gt;&lt;br /&gt;
&lt;table border="1" cellpadding="3" cellspacing="0"&gt;
&lt;tr&gt;
   &lt;td align="center"&gt;&lt;a title="Go get Firefox" href="http://www.mozilla.org/products/firefox/" target="_blank"&gt;firefox&lt;/a&gt; - Static&lt;/td&gt;
   &lt;td align="center"&gt;&lt;a title="Go get Firefox" href="http://www.mozilla.org/products/firefox/" target="_blank"&gt;firefox&lt;/a&gt; - JS&lt;/td&gt;
   &lt;td align="center"&gt;IE - static&lt;/td&gt;
   &lt;td align="center"&gt;IE - dynamic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
   &lt;td align="center"&gt;ave: 54.5ms&lt;/td&gt;
   &lt;td align="center"&gt;ave: 39.125ms&lt;/td&gt;
   &lt;td align="center"&gt;ave: 17.25ms&lt;/td&gt;
   &lt;td align="center"&gt;ave: 52.875ms&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;&lt;br /&gt;

Of note, in this test, is the IE static HTML rendering times, which is much faster than any of the other results.&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1752.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">Lately Ive been writing alot of HTML as javascript using a function Ive named createNode in my <a href="http://blogs.acceleration.net/russ/articles/1751.aspx">Controls Library</a>
<br /><br />
example:
<div style="padding:5px; border:1px solid black;background-color:#EFEFFF;white-space:pre">// The strings with curly braces are binding points with names matching the columns of my datasource
var cn = Controls.createNode;
var template = cn('tr', {}, 
               cn('td', {'class':"topCell", style:'width:75;'}, 
                  '{StoreNumber}'),
               cn('td', {'class':"topCell", style:'width:100;'}, 
                  '{Name}'),
               cn('td', {'class':"topCell", style:'width:100;' }, 
                  '{Metro}'),
               cn('td', {'class':"topCell", style:'width:250;'}, 
                  "{Address}",
                  cn('br'),
                  "{City}, {State} {Zip}"),
               cn('td', {'class':"topCell", style:'width:150;'}, 
                  cn('textarea', {'class':"displayBox", style:"width:100%;", readonly:"true"},
                     '{PublicPhoneNumbers}')),
               cn('td', {'class':"topCell", style:'width:100;'}, 
                  '{ConnectionType} - {Speed}'),
               cn('td', {'class':"topCell", style:'width:100;'}, 
                  '{UserName}'),
               cn('td', {'class':"topCell", style:'width:150;'}, 
                  '{DateEnteredHistory}'))

</div>

I was curious how this would square up against redering plain HTML.  I had a feeling that it might be faster since parsing XML is incredibly slow and direct interaction with the DOM is something that JS should theoretically be good at.  In my test I average the rendering time of a 10 column 100 row table over a few page refreshes.  <br />
The following were the result data:<br /><br />
<table border="1" cellpadding="3" cellspacing="0">
<tr>
   <td align="center"><a title="Go get Firefox" href="http://www.mozilla.org/products/firefox/" target="_blank">firefox</a> - Static</td>
   <td align="center"><a title="Go get Firefox" href="http://www.mozilla.org/products/firefox/" target="_blank">firefox</a> - JS</td>
   <td align="center">IE - static</td>
   <td align="center">IE - dynamic</td>
</tr>
<tr>
   <td align="center">ave: 54.5ms</td>
   <td align="center">ave: 39.125ms</td>
   <td align="center">ave: 17.25ms</td>
   <td align="center">ave: 52.875ms</td>
</tr>
</table><br />

Of note, in this test, is the IE static HTML rendering times, which is much faster than any of the other results.<img src ="http://blogs.acceleration.net/russ/aggbug/1752.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Object Keyed Hashtable in Javascript</title><link>http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx</link><pubDate>Wed, 06 Jul 2005 19:50:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx</guid><description>

In the last couple days I have had the need to put keys (that are objects) into a hashtable. Since the default js hashtable only allows string keys (see &lt;a href="http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx"&gt;my last post on this topic&lt;/a&gt;), I decided to check the internet.  &lt;a href="http://m.synovic.home.att.net/hashtable/hashtable.html"&gt;Synovic &lt;/a&gt; is most highly rated by google, and pretty much every other refernce to javascript hashtable points to either his implementation or notes that {key:value}  creates an object/array/hashtable in javascript.  Because Synovic's hashtable is just a java like wrapper around the default hashtable, his suffers from the same built in flaw that the normal hashtable suffers.  I seem to be the only one with the need to hash based off objects.  One of the requirements I had was that I didnt want to modify the key (which would greatly simplify the problem).  If I could just add a hashcode to every object passed in as a key this whole problem again becomes trivial.  The only problem is that, since objects == hashtable in javascript, I could be accidently adding things to a collection that I dont want to be modified.  Also it just seems like a horrible practice to have random functions adding properties to your objects.   My solution was basically to create a hash code that I could use to identify objects.  Then, using that hashcode, I look into an internal string-keyed hashtable.  In that value slot,  I store an array of {key: objectKey, value: valPassedIn} objects.  Then it is linear look up to go through the array.  If I can improve the Hashcode function I can improve the overall performance of my Hashtable object, but right now I havn't a clue how to do this.

and now, the moment youve all been waiting for:
&lt;h2&gt;&lt;a href="http://blogs.acceleration.net/russ/articles/1743.aspx"&gt;Hashtable Source&lt;/a&gt;&lt;/h2&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1744.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">

In the last couple days I have had the need to put keys (that are objects) into a hashtable. Since the default js hashtable only allows string keys (see <a href="http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx">my last post on this topic</a>), I decided to check the internet.  <a href="http://m.synovic.home.att.net/hashtable/hashtable.html">Synovic </a> is most highly rated by google, and pretty much every other refernce to javascript hashtable points to either his implementation or notes that {key:value}  creates an object/array/hashtable in javascript.  Because Synovic's hashtable is just a java like wrapper around the default hashtable, his suffers from the same built in flaw that the normal hashtable suffers.  I seem to be the only one with the need to hash based off objects.  One of the requirements I had was that I didnt want to modify the key (which would greatly simplify the problem).  If I could just add a hashcode to every object passed in as a key this whole problem again becomes trivial.  The only problem is that, since objects == hashtable in javascript, I could be accidently adding things to a collection that I dont want to be modified.  Also it just seems like a horrible practice to have random functions adding properties to your objects.   My solution was basically to create a hash code that I could use to identify objects.  Then, using that hashcode, I look into an internal string-keyed hashtable.  In that value slot,  I store an array of {key: objectKey, value: valPassedIn} objects.  Then it is linear look up to go through the array.  If I can improve the Hashcode function I can improve the overall performance of my Hashtable object, but right now I havn't a clue how to do this.

and now, the moment youve all been waiting for:
<h2><a href="http://blogs.acceleration.net/russ/articles/1743.aspx">Hashtable Source</a></h2><img src ="http://blogs.acceleration.net/russ/aggbug/1744.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Javascript Hashtable</title><link>http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx</link><pubDate>Tue, 05 Jul 2005 16:23:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/07/05/1736.aspx</guid><description>First, I recognize that an Array is an Object is an Hashtable in javascript.  The problem is that only strings can act as a key in an Object.  
Meaning:
&lt;pre&gt;
 var x = new Object()  
 var y = new Object()  
&lt;i&gt;&amp;gt;&amp;gt; [object Object] &lt;/i&gt;
 z = new Object()  
&lt;i&gt;&amp;gt;&amp;gt; [object Object] &lt;/i&gt;
 x[y] = 'test' ;
&lt;i&gt;&amp;gt;&amp;gt; test&lt;/i&gt;
 x[z]  
&lt;i&gt;&amp;gt;&amp;gt; test &lt;/i&gt;
&lt;/pre&gt;

Since alot of the objects in javascript return [Object] as their toString(), this means that I cannot key a hashtable off objects.  I guess I'll get to work writing an actual Hashtable instead of just relying on the built in stuff.  I will post this when I am done.  For now, off to class.
&lt;br /&gt;&lt;br /&gt;
UPDATE: &lt;a href="http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx"&gt; The Exciting Conclusion &lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1736.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">First, I recognize that an Array is an Object is an Hashtable in javascript.  The problem is that only strings can act as a key in an Object.  
Meaning:
<pre>
 var x = new Object()  
 var y = new Object()  
<i>&gt;&gt; [object Object] </i>
 z = new Object()  
<i>&gt;&gt; [object Object] </i>
 x[y] = 'test' ;
<i>&gt;&gt; test</i>
 x[z]  
<i>&gt;&gt; test </i>
</pre>

Since alot of the objects in javascript return [Object] as their toString(), this means that I cannot key a hashtable off objects.  I guess I'll get to work writing an actual Hashtable instead of just relying on the built in stuff.  I will post this when I am done.  For now, off to class.
<br /><br />
UPDATE: <a href="http://blogs.acceleration.net/russ/archive/2005/07/06/1744.aspx"> The Exciting Conclusion </a><img src ="http://blogs.acceleration.net/russ/aggbug/1736.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>Changing the scope of "this" when using eval in javascript</title><link>http://blogs.acceleration.net/russ/archive/2005/05/16/1139.aspx</link><pubDate>Mon, 16 May 2005 17:55:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/05/16/1139.aspx</guid><description>I want every Item on the page to have an onload that gets called when the window.onload is fired.  What I ended up doing is calling documnet.getElementsByAttribute('onload').  This is a function I wrote, but I will assume everyone can do a simple preorder tree traversal, so I will not go into it here.  After getting a list of nodes with onload (in the correct order I want to execute them, I call the following code on each node:
&lt;div class="code"&gt;function(){
     eval( theStringIWishToEval );
  }.call( objectIWantToBeThis ); // the node
&lt;/div&gt;
This gives the correct scoping to the evaluated code (which is the current node whose "load event" I am reacting to).&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1139.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">I want every Item on the page to have an onload that gets called when the window.onload is fired.  What I ended up doing is calling documnet.getElementsByAttribute('onload').  This is a function I wrote, but I will assume everyone can do a simple preorder tree traversal, so I will not go into it here.  After getting a list of nodes with onload (in the correct order I want to execute them, I call the following code on each node:
<div class="code">function(){
     eval( theStringIWishToEval );
  }.call( objectIWantToBeThis ); // the node
</div>
This gives the correct scoping to the evaluated code (which is the current node whose "load event" I am reacting to).<img src ="http://blogs.acceleration.net/russ/aggbug/1139.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>XUL Repeater</title><link>http://blogs.acceleration.net/russ/archive/2005/05/04/1063.aspx</link><pubDate>Wed, 04 May 2005 16:24:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/05/04/1063.aspx</guid><description>I had talked about this repeater control a while back but then got distracted onto other things.&lt;br /&gt;
&lt;a href="http://blogs.acceleration.net/russ/articles/1062.aspx"&gt;Go Here to see  the Repeater Source&lt;/a&gt;
&lt;br /&gt;
It probably can easily be ported to work with just javascript and HTML but I havnt had the time or need to do so yet.  Who knows maybe soon.

UPDATE: Fixed Link&lt;img src ="http://blogs.acceleration.net/russ/aggbug/1063.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">I had talked about this repeater control a while back but then got distracted onto other things.<br />
<a href="http://blogs.acceleration.net/russ/articles/1062.aspx">Go Here to see  the Repeater Source</a>
<br />
It probably can easily be ported to work with just javascript and HTML but I havnt had the time or need to do so yet.  Who knows maybe soon.

UPDATE: Fixed Link<img src ="http://blogs.acceleration.net/russ/aggbug/1063.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>The XBL Template / Repeater control</title><link>http://blogs.acceleration.net/russ/archive/2005/04/10/819.aspx</link><pubDate>Sun, 10 Apr 2005 17:04:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/04/10/819.aspx</guid><description>So I finally found a palatable solution to the &lt;a href="http://blogs.acceleration.net/russ/archive/2005/04/06/804.aspx"&gt;Templates Problem&lt;/a&gt; I talked about earlier.  The technique I used was to create a XBL control called 'repeater'.  &lt;a title="Ryan" href="http://blogs.acceleration.net/ryan/"&gt;Ryan&lt;/a&gt; had some issues with the word template as I was using it so we switched over to repeater to be less ambiguous.  The goal of this is not to provide a general control system (which XBL and &lt;a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank"&gt;XBLinJS&lt;/a&gt; try to do), but only to provide the functionality to easily repeat nodes inside of a valid tag.  The best example I can give for this is for  binding a dropdownlist / select box / menupopup, where I just need to repeat the &amp;lt;menuitem /&amp;gt; over a flat set of data.  
&lt;br /&gt;&lt;br /&gt;
var testTable = [['id', 'name'],&lt;br /&gt;
 [ 1, 'Programmers' ],&lt;br /&gt;
 [ 2, 'WebAdmin' ],&lt;br /&gt;
 [ 3, 'Broadband']];&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hbox&amp;gt;&lt;br /&gt;
  &amp;lt;repeater&amp;gt;&lt;br /&gt;
    &amp;lt;label value="{name}" /&amp;gt;&lt;br /&gt;
  &amp;lt;/repeater&amp;gt;&lt;br /&gt;
&amp;lt;/hbox&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What the 'repeater' control does is remove the repeater node from its parent storing a reference to this 'template' on that control (so we have what was there but none of it is rendered).  Then it loops through the data set adding all of the nodes that were inside of the repeater tags, with their values filled in.  So what gets rendered to the page would be this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;hbox&amp;gt;&lt;br /&gt;
    &amp;lt;label value="Programmers" /&amp;gt;&lt;br /&gt;
    &amp;lt;label value="WebAdmin" /&amp;gt;&lt;br /&gt;
    &amp;lt;label value="Broadband" /&amp;gt;&lt;br /&gt;
&amp;lt;/hbox&amp;gt;&lt;br /&gt;
&lt;br /&gt;

The really nice part about this system is that by inserting a repeater node inside of the template, with the outer template filling in the datasource attribute for the inner repeater as it goes, allows you to chain these repeaters to make hierarchical data repeaters.   After I finish polishing everything and test it once more, I am going to port this to use &amp;lt;div repeater="true" &amp;gt; [enter repeated data here]&amp;lt;/div&amp;gt; so that I can achieve the same repeater functionality in standard HTML.   
&lt;br /&gt;&lt;br /&gt;
Overall this has been my best experience with XBL, most notable because it required only one function block and one line of xbl content binding  ( the &amp;lt;children /&amp;gt; node).  It did however force me to copy code in and out of the xbl document to a standard JS doc to get parse errors to show up (Mozilla was just silently failing when their was a parse error in the XBL Javascript). 
&lt;br /&gt;&lt;br /&gt;
&lt;a title="Ryan" href="http://blogs.acceleration.net/ryan/"&gt;Ryan&lt;/a&gt; will probably give us a little preview of his js control scheme based of his interpretations of &lt;a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank"&gt;XBLinJS&lt;/a&gt;.  What it seems we've got almost worked out is a simple way to repeat nodes and a simple way to create complex, repeatable, XUL/HTML controls.  Most of this work was inspired by excessive frustration (mostly caused by nonexistant error handling) at the way mozilla handles these two things  and by reading &lt;a href="http://www.jerf.org"&gt;Jeremy Bowers&lt;/a&gt; site which convinced us to do what we already wanted to do.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;
UPDATE:&lt;br /&gt;
&lt;a href="http://blogs.acceleration.net/russ/articles/1062.aspx"&gt;Go Here to see  the Repeater Source&lt;/a&gt;&lt;br /&gt;
&lt;a href="http://blogs.acceleration.net/russ/articles/1145.aspx"&gt;Usage Example&lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/819.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">So I finally found a palatable solution to the <a href="http://blogs.acceleration.net/russ/archive/2005/04/06/804.aspx">Templates Problem</a> I talked about earlier.  The technique I used was to create a XBL control called 'repeater'.  <a title="Ryan" href="http://blogs.acceleration.net/ryan/">Ryan</a> had some issues with the word template as I was using it so we switched over to repeater to be less ambiguous.  The goal of this is not to provide a general control system (which XBL and <a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank">XBLinJS</a> try to do), but only to provide the functionality to easily repeat nodes inside of a valid tag.  The best example I can give for this is for  binding a dropdownlist / select box / menupopup, where I just need to repeat the &lt;menuitem /&gt; over a flat set of data.  
<br /><br />
var testTable = [['id', 'name'],<br />
 [ 1, 'Programmers' ],<br />
 [ 2, 'WebAdmin' ],<br />
 [ 3, 'Broadband']];<br />
<br />
&lt;hbox&gt;<br />
  &lt;repeater&gt;<br />
    &lt;label value="{name}" /&gt;<br />
  &lt;/repeater&gt;<br />
&lt;/hbox&gt;<br />
<br />
What the 'repeater' control does is remove the repeater node from its parent storing a reference to this 'template' on that control (so we have what was there but none of it is rendered).  Then it loops through the data set adding all of the nodes that were inside of the repeater tags, with their values filled in.  So what gets rendered to the page would be this:<br />
<br />
&lt;hbox&gt;<br />
    &lt;label value="Programmers" /&gt;<br />
    &lt;label value="WebAdmin" /&gt;<br />
    &lt;label value="Broadband" /&gt;<br />
&lt;/hbox&gt;<br />
<br />

The really nice part about this system is that by inserting a repeater node inside of the template, with the outer template filling in the datasource attribute for the inner repeater as it goes, allows you to chain these repeaters to make hierarchical data repeaters.   After I finish polishing everything and test it once more, I am going to port this to use &lt;div repeater="true" &gt; [enter repeated data here]&lt;/div&gt; so that I can achieve the same repeater functionality in standard HTML.   
<br /><br />
Overall this has been my best experience with XBL, most notable because it required only one function block and one line of xbl content binding  ( the &lt;children /&gt; node).  It did however force me to copy code in and out of the xbl document to a standard JS doc to get parse errors to show up (Mozilla was just silently failing when their was a parse error in the XBL Javascript). 
<br /><br />
<a title="Ryan" href="http://blogs.acceleration.net/ryan/">Ryan</a> will probably give us a little preview of his js control scheme based of his interpretations of <a title="xbl alternative" href="http://www.jerf.org/resources/xblinjs/" target="_blank">XBLinJS</a>.  What it seems we've got almost worked out is a simple way to repeat nodes and a simple way to create complex, repeatable, XUL/HTML controls.  Most of this work was inspired by excessive frustration (mostly caused by nonexistant error handling) at the way mozilla handles these two things  and by reading <a href="http://www.jerf.org">Jeremy Bowers</a> site which convinced us to do what we already wanted to do.<br /><br /><br />
UPDATE:<br />
<a href="http://blogs.acceleration.net/russ/articles/1062.aspx">Go Here to see  the Repeater Source</a><br />
<a href="http://blogs.acceleration.net/russ/articles/1145.aspx">Usage Example</a><img src ="http://blogs.acceleration.net/russ/aggbug/819.aspx" width = "1" height = "1" /></body></item><item><dc:creator>Russ</dc:creator><title>JS Shell Update</title><link>http://blogs.acceleration.net/russ/archive/2005/04/08/812.aspx</link><pubDate>Fri, 08 Apr 2005 14:24:00 GMT</pubDate><guid>http://blogs.acceleration.net/russ/archive/2005/04/08/812.aspx</guid><description>I finally got around to sorting the outputs of both the tab complete and the props function.  That was a long time coming for .sort().
&lt;br /&gt;&lt;br /&gt;
 &lt;a href="http://birdman.acceleration.net/shell/extensiondev.xpi"&gt;The XPI&lt;/a&gt;&lt;img src ="http://blogs.acceleration.net/russ/aggbug/812.aspx" width = "1" height = "1" /&gt;</description><body xmlns="http://www.w3.org/1999/xhtml">I finally got around to sorting the outputs of both the tab complete and the props function.  That was a long time coming for .sort().
<br /><br />
 <a href="http://birdman.acceleration.net/shell/extensiondev.xpi">The XPI</a><img src ="http://blogs.acceleration.net/russ/aggbug/812.aspx" width = "1" height = "1" /></body></item></channel></rss>