<?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"
	>

<channel>
	<title>bigredswitch</title>
	<atom:link href="http://www.bigredswitch.com/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bigredswitch.com/blog</link>
	<description>Push it. You know you want to.</description>
	<pubDate>Thu, 20 Nov 2008 17:22:35 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.3</generator>
	<language>en</language>
			<item>
		<title>Sports Authority Coupon</title>
		<link>http://www.bigredswitch.com/blog/2008/11/sports-authority-coupon/</link>
		<comments>http://www.bigredswitch.com/blog/2008/11/sports-authority-coupon/#comments</comments>
		<pubDate>Thu, 20 Nov 2008 17:22:35 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=207</guid>
		<description><![CDATA[I love getting coupons in email.  I also love Sports Authority.

]]></description>
			<content:encoded><![CDATA[<p>I love getting coupons in email.  I also love Sports Authority.</p>
<p><img src="/blog/wp-content/uploads/2008/11/sportsauthority-081120.PNG"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/11/sports-authority-coupon/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Autocomplete Plugin 2</title>
		<link>http://www.bigredswitch.com/blog/2008/11/jquery-autocomplete-plugin-2/</link>
		<comments>http://www.bigredswitch.com/blog/2008/11/jquery-autocomplete-plugin-2/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 00:33:24 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=201</guid>
		<description><![CDATA[
.coding {
  background-color: #1b1d1e; color: #f8f8f2; font-family: georgia, serif; font-size: 15px;
  width: 400px; overflow-x: auto; padding: 3px;
  border: 3px solid #999;
}
li {
  font-size: 13px;
}

Continuing from my last post.
Some notes:

You can give a wrapped set as a second argument to a selector such as: $(&#8217;p', wrappedSet). This is the same as wrappedSet.find(&#8217;p').
The [...]]]></description>
			<content:encoded><![CDATA[<style>
.coding {
  background-color: #1b1d1e; color: #f8f8f2; font-family: georgia, serif; font-size: 15px;
  width: 400px; overflow-x: auto; padding: 3px;
  border: 3px solid #999;
}
li {
  font-size: 13px;
}
</style>
<p>Continuing from <a href="/blog/2008/11/jquery-autocomplete-plugin/">my last post</a>.</p>
<p>Some notes:
<ul>
<li>You can give a wrapped set as a second argument to a selector such as: <i>$(&#8217;p', wrappedSet)</i>. This is the same as <i>wrappedSet.find(&#8217;p')</i>.</li>
<li>The CSS selector <i>&#8216;> *&#8217;</i> returns direct descendants of an element. For example, <i>$(&#8217;> *&#8217;, $(&#8217;ul.fred&#8217;))</i> would bring back the list elements of any list with class &#8216;fred&#8217;.</li>
<li>The JS function <i>window.clearInterval()</i> will clear a timeout set with <i>window.setTimeout()</i>.</li>
<li>What&#8217;s fascinating for me about this plugin is the size of it, it&#8217;s very small. Now I realize that it doesn&#8217;t do that much but the kernel is there. See <a href="http://xidey.wordpress.com/2008/02/18/jquery-autocomplete-choices/">this post</a> for a discussion of different jQuery autocomplete plugins. The author of the bassistance autocomplete plugin (Jorn) has an interesting first comment.
  </ul>
</p>
<p>What&#8217;s nice about this plugin is that it&#8217;s event driven. Sometimes that makes it hard to follow, but if you keep in mind to &#8220;just follow the events&#8221;, it&#8217;s not that hard.  So, here are the events we need to follow:</p>
<p>These are the main input (autocomplete input text box) events:
<ul>
<li><i>keyup</i> Main input event that sets up the typing timeout (delay to autocomplete).</li>
<li><i>keypress</i> Main input event that </li>
<li><i>autocomplete</i> This is the event that triggers the autocomplete on an input control. See the autocomplete binding method for the behavior.  Sets up a &#8216;one&#8217; binding for the <i>updateList</i> event that does most the work.</li>
<li><i>updateList</i> This event updates the list and starts the autocomplete on the input after setting up the container (opt.wrapper element).  This calls <i>autocompleteMode</i> which does the work.</li>
</ul>
<p>These are the autocompleteMode events:
<ul>
<li><i>activate.autocomplete</i> This event is when the highlighted autocomplete list item is selected; either via the enter key or via a mouse click. Note line 51: <i>active &#038;&#038; input.trigger(&#8221;activate.autocomplete&#8221;, [$.data(active[0], &#8220;originalObject&#8221;)]);</i> the input element does not have an actiavate.autocomplete handler on it but one can be added an dwill be called.  This is the same for the <i>cancel.autocomplete</i> and <i>itemSelected.autocomplete</i> events.</li>
<li><i>cancel.autocomplete</i> This cancels the autocomplete, either from an escape key or from a click on the window object.</li>
<li><i>off.autocomplete</i> Does the work of actually turning off the autocomplete.</li>
<li><i>itemSelected.autocomplete</i> Triggered on input when autolist item is selected.</li>
<li><i>keydown.autocomplete</i> Straightforward; handles special keys (ESC, RETRUN, UP, DOWN, TAB).</li>
<li><i>click.autocomplete</i> Click handler.</li>
<li><i>mouseover</i> Mouseover handler.</li>
</ul>
<p><p>The key event handlers are on the input element and the mouse event handlers are on the container (wrapper) element and the body/window.</p>
<p>Another thing to have in mind are the data contents for the elements:
<ul>
<li><i>autocompleteMode (document.body)</i> holds the current state of autocomplete on the current control; true if the autocomplete list is showing, false otherwise.  Note that a global is all that&#8217;s needed since only one control is active at a time.</li>
<li><i>suppressKey (document.body)</i> if set, keypress on input element is cleared and returns ignoring key. This suppresses the up/down keypress when navigating the autocomplete list from clearing the autocomplete. This is not necessary since IE does not have a keydown/up keypress event; unfortunately, this suppresses valid keys in IE. See discussion <a href="http://ejohn.org/blog/keypress-in-safari-31/">here</a>.</li>
<li><i>originalObject (single element of autocomplete list, i.e. opt.template)</i> this is set on every list (or opt.template) element in the matching autocomplete list. This is not state but rather a way to get back to the original object when an autocomplete item is selected.</li>
<li><i>typingTimeout (input)</i> the return from the setTimeout function so we can clear the timeout later. Not state.</li>
</ul>
<p>Some other notes:
<ul>
<li>I like how container is created around the autocomplete list and to remove you just have to do container.remove().</li>
<li>I metioned the namespaced events in previous post, but this plugin makes nice use of them.</li>
<li>The filter and map on list (lines 164-170) is very perlish/lispy; I love it.</li>
</ul>
<p>I&#8217;m using a modified version with these changes:
<ul>
<li>Fixed console in autocomplete.html for IE7.</li>
<li>Fix suppressKey for IE (see above).</li>
<li>Fix pressing tab/down/up before typingTimeout. (Not setting/clearing typeTimeout data on same element.)</li>
<li>Bring down autocomplete list immediately on arrow up/down.</li>
<li>Update autocomplete list on backspace and delete.</li>
<li>Added a few comments prefixed with [B]</li>
</ul>
<p>  If you want it, I&#8217;ve zipped it up here:<br />
<a href='http://www.bigredswitch.com/blog/wp-content/uploads/2008/11/jquery.autocomplete-0.7.1.zip'>jquery.autocomplete-0.7.1</a>
  </p>
<p>Postscript: I know the detail is way too much on last few posts unless you are studying these in depth. But I needed to go though these and these are my notes. So &#8230; whatever :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/11/jquery-autocomplete-plugin-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Autocomplete Plugin</title>
		<link>http://www.bigredswitch.com/blog/2008/11/jquery-autocomplete-plugin/</link>
		<comments>http://www.bigredswitch.com/blog/2008/11/jquery-autocomplete-plugin/#comments</comments>
		<pubDate>Mon, 10 Nov 2008 00:02:11 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=197</guid>
		<description><![CDATA[
.coding {
  background-color: #1b1d1e; color: #f8f8f2; font-family: georgia, serif; font-size: 15px;
  width: 600px; overflow-x: auto; padding: 3px;
  border: 3px solid #999;
}
li {
  font-size: 13px;
}

Some notes from looking at Yehuda Katz and Rein Henrichs autocomplete plugin:

I don&#8217;t understand when authors of provide no documentation. Programmers don&#8217;t really like doing documentation but this [...]]]></description>
			<content:encoded><![CDATA[<style>
.coding {
  background-color: #1b1d1e; color: #f8f8f2; font-family: georgia, serif; font-size: 15px;
  width: 600px; overflow-x: auto; padding: 3px;
  border: 3px solid #999;
}
li {
  font-size: 13px;
}
</style>
<p>Some notes from looking at <a href="http://github.com/ReinH/jquery-autocomplete/tree/master">Yehuda Katz and Rein Henrichs autocomplete plugin</a>:</p>
<ul>
<li>I don&#8217;t understand when authors of provide no documentation. Programmers don&#8217;t really like doing documentation but this would get many more people to use the plugin.</li>
<li>It took me a while to figure out what events like &#8216;click.autocomplete&#8217; were. Turns out that jQuery has a mechanism where you can <a href="http://www.learningjquery.com/2007/09/namespace-your-events">namespace your events</a>.  <a href="http://www.learningjquery.com/2008/05/working-with-events-part-2">Here is another writeup</a> about it.  Nice idea.</li>
<li>Getting the key in a event callback in a cross browser manner can be done succinctly like: <i>var k = e.which || e.keyCode;</i> I already knew about this as I know that many others do but it&#8217;s nice to note.  You would think that jQuery would hide this detail.  Also, I always wondered why jQuery didn&#8217;t have a map for the common keycodes.  I guess you have to do it yourself: <i>var KEY = { ESC: 27, RETURN: 13,&#8230;};</i></li>
<li>Note that the version from the site above works on IE, the one in the svn jQuery source base doesn&#8217;t.</li>
</ul>
<p>The plugin is very succinct and I wanted to study it; these are my notes.</p>
<p>The plugin is split up into 2 files: jquery.ui.autocomplete.js and jquery.ui.autocomplete.ext.js.  The ext file is optional, but if you are going to use it, include it before the main plugin file.  I&#8217;m actually not sure why it&#8217;s optional and I would just include it in the main plugin.  It has 2 methods: <i>ajax</i> and <i>templateText</i> (in the $.ui.autocomplete.ext namespace). In the main plugin, the ext methods are used like this:</p>
<pre class="coding">
<span style="background-color: #232526"><font color="#bcbcbc">112 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>if</b></font>($.ui.autocomplete.ext) {
<span style="background-color: #232526"><font color="#bcbcbc">113 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>for</b></font>(<font color="#66d9ef">var</font>&nbsp;ext <font color="#f92672">in</font>&nbsp;$.ui.autocomplete.ext) {
<span style="background-color: #232526"><font color="#bcbcbc">114 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>if</b></font>(opt[ext]) {
<span style="background-color: #232526"><font color="#bcbcbc">115 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;opt = $.extend(opt, $.ui.autocomplete.ext[ext](opt));
<span style="background-color: #232526"><font color="#bcbcbc">116 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672">delete</font>&nbsp;opt[ext];
<span style="background-color: #232526"><font color="#bcbcbc">117 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}
<span style="background-color: #232526"><font color="#bcbcbc">118 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;} }
</pre>
<p>This goes through all items in <i>$.ui.autocomplete.ext</i> (the 2 methods) and merges them iff the options already include those methods (line 114). It merges them (line 115) by calling the method in ext with the opt hash as the parameter and merges in the return value which is a hash; this is why the ext methods take opt as the parameter and return a hash that replaces some methods in the original opt hash. Note that it deletes the opt hash element for the ext value (line 116). This is the first time I&#8217;ve seen this type of extension mechanism.  Hmm, a little obscure; I&#8217;ll reserve judgement for now.</p>
<p>Note how these are used in the HTML file (autocomplete.html):</p>
<pre class="coding">
<span style="background-color: #232526"><font color="#bcbcbc">29 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#e6db74">ajax</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;list&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>,</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">32 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#e6db74">templateText</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;&lt;li&gt;Hey: &lt;%= text %&gt;&lt;/li&gt;&quot;</font>
<span style="background-color: #232526"><font color="#bcbcbc">53 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#e6db74">templateText</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;&lt;li&gt;&lt;%= pre_match %&gt;&lt;span class='matching' &gt;&lt;%= match %&gt;&lt;/span&gt;&lt;%= post_match %&gt;&lt;/li&gt;&quot;</font>
<span style="background-color: #232526"><font color="#bcbcbc">57 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#e6db74">ajax</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;list&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>,</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">60 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#e6db74">templateText</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;&lt;li&gt;Hey: &lt;%= text %&gt;&lt;/li&gt;&quot;</font>
</pre>
<p>It should be pretty obvious what the ext methods do (jquery.ui.autocomplete.ext.js):</p>
<pre class="coding">
<span style="background-color: #232526"><font color="#bcbcbc">18 </font></span>&nbsp;&nbsp;$.ui.autocomplete.ext.ajax = <font color="#a6e22e">function</font>(opt)&nbsp;{
<span style="background-color: #232526"><font color="#bcbcbc">19 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#66d9ef">var</font>&nbsp;ajax = opt.ajax;
<span style="background-color: #232526"><font color="#bcbcbc">20 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>return</b></font>&nbsp;{&nbsp;<font color="#e6db74">getList</font>: <font color="#a6e22e">function</font>(input)&nbsp;{
<span style="background-color: #232526"><font color="#bcbcbc">21 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>if</b></font>&nbsp;(input.val().match(<font color="#e6db74">/^</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\s</i></font></span><font color="#e6db74">*$/</font>)) <font color="#f92672"><b>return</b></font>&nbsp;<font color="#ae81ff">false</font>;
<span style="background-color: #232526"><font color="#bcbcbc">22 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.getJSON(ajax, <font color="#e6db74">&quot;val=&quot;</font>&nbsp;+ input.val(), <font color="#a6e22e">function</font>(json)&nbsp;{ input.trigger(<font color="#e6db74">&quot;updateList&quot;</font>, [json]); });
<span style="background-color: #232526"><font color="#bcbcbc">23 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;} };
<span style="background-color: #232526"><font color="#bcbcbc">24 </font></span>&nbsp;&nbsp;};
<span style="background-color: #232526"><font color="#bcbcbc">25 </font></span>
<span style="background-color: #232526"><font color="#bcbcbc">26 </font></span>&nbsp;&nbsp;$.ui.autocomplete.ext.templateText = <font color="#a6e22e">function</font>(opt)&nbsp;{
<span style="background-color: #232526"><font color="#bcbcbc">27 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#66d9ef">var</font>&nbsp;template = $.makeTemplate(opt.templateText, <font color="#e6db74">&quot;&lt;%&quot;</font>, <font color="#e6db74">&quot;%&gt;&quot;</font>);
<span style="background-color: #232526"><font color="#bcbcbc">28 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>return</b></font>&nbsp;{&nbsp;<font color="#e6db74">template</font>: <font color="#a6e22e">function</font>(obj)&nbsp;{ <font color="#f92672"><b>return</b></font>&nbsp;template(obj); } };
<span style="background-color: #232526"><font color="#bcbcbc">29 </font></span>&nbsp;&nbsp;};
</pre>
<p>Oh, it would probably help if you knew what the options actually were:
<ul>
<li>timeout: <i>integer</i> The timeout in ms after user typing idle and autocomplete list appears. </li>
<li>getList: <i>function(input)</i> Function called on main input element to show the autocomplete list.</li>
<li>template: <i>function(str)</i> Returns a single autocomplete list line for a match.</li>
<li>insertText: <i>function(str)</i> Returns the autocomplete text for a single line.</li>
<li>match: <i>function(str)</i> Return true or false, whether the typed str matches an autocomplete item.</li>
<li>wrapper: <i>string</i> The wrapper (pair of HTML elements) to wrap the autocomplete list in.</li>
</ul>
<p>The default option values (jquery.ui.autocomplete.js):</p>
<pre class="coding">
<span style="background-color: #232526"><font color="#bcbcbc">103 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;opt = $.extend({}, {
<span style="background-color: #232526"><font color="#bcbcbc">104 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">timeout</font>: <font color="#ae81ff">1000</font>,
<span style="background-color: #232526"><font color="#bcbcbc">105 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">getList</font>: <font color="#a6e22e">function</font>(input)&nbsp;{ input.trigger(<font color="#e6db74">&quot;updateList&quot;</font>, [opt.list]); },
<span style="background-color: #232526"><font color="#bcbcbc">106 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">template</font>: <font color="#a6e22e">function</font>(str)&nbsp;{ <font color="#f92672"><b>return</b></font>&nbsp;<font color="#e6db74">&quot;&lt;li&gt;&quot;</font>&nbsp;+ opt.insertText(str) + <font color="#e6db74">&quot;&lt;/li&gt;&quot;</font>; },
<span style="background-color: #232526"><font color="#bcbcbc">107 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">insertText</font>: <font color="#a6e22e">function</font>(str)&nbsp;{ <font color="#f92672"><b>return</b></font>&nbsp;str; },
<span style="background-color: #232526"><font color="#bcbcbc">108 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">match</font>: <font color="#a6e22e">function</font>(typed)&nbsp;{ <font color="#f92672"><b>return</b></font>&nbsp;<font color="#66d9ef">this</font>.match(<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>RegExp</i></font></span>(typed)); },
<span style="background-color: #232526"><font color="#bcbcbc">109 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">wrapper</font>: <font color="#e6db74">&quot;&lt;ul class='jq-ui-autocomplete'&gt;&lt;/ul&gt;&quot;</font>
<span style="background-color: #232526"><font color="#bcbcbc">110 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;}, opt);
</pre>
<p>That should be enough to give you an idea of how to get the plugin working.  And now we are ready to roll up our sleeves and see how the plugin actually works.  That will have to wait for the next post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/11/jquery-autocomplete-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Templating Plugin</title>
		<link>http://www.bigredswitch.com/blog/2008/11/jquery-templating-plugin/</link>
		<comments>http://www.bigredswitch.com/blog/2008/11/jquery-templating-plugin/#comments</comments>
		<pubDate>Mon, 03 Nov 2008 15:13:26 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=183</guid>
		<description><![CDATA[
.coder {
  background-color: #1b1d1e; color: #f8f8f2; font-family: georgia, serif;
  overflow-x: auto; padding: 3px;
  border: 3px solid #999;
}

I wanted to take a look at the templating plugin included in the jQuery distribution (for some reason, there is no documentation of it on jquery.com, this is the same templating plugin included in ReinH/Katz autocomplete [...]]]></description>
			<content:encoded><![CDATA[<style>
.coder {
  background-color: #1b1d1e; color: #f8f8f2; font-family: georgia, serif;
  overflow-x: auto; padding: 3px;
  border: 3px solid #999;
}
</style>
<p>I wanted to take a look at the templating plugin included in the jQuery distribution (for some reason, there is no documentation of it on jquery.com, this is the same templating plugin included in ReinH/Katz autocomplete plugin <a href="http://github.com/ReinH/jquery-autocomplete/tree/master">here</a>).  It&#8217;s not the best documented plugin but it&#8217;s short so should be quick to figure out.</p>
<p>Basically, what this plugin does is take a block of text and interprets it as a template.  What is a template?  Well, for this plugin, think about JSP or ASP.  I.e., executable code between special characters interspersed with HTML.  So for example:</p>
<pre class="coder">
<span style="background-color: #232526"><font color="#bcbcbc">23 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% $</i></font></span>(<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>arr</i></font></span>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.each</i></font></span>(<font color="#a6e22e">function</font>()<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;</i></font></span><font color="#a6e22e">{</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;%&gt;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">24 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;a href=</i></font></span><font color="#e6db74">&quot;&lt;%= this.url %&gt;&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&gt;&lt;%= </i></font></span><font color="#66d9ef">this</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.text %&gt;&lt;/a&gt;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">25 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% </i></font></span><font color="#a6e22e">}</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>; %&gt;</i></font></span>
</pre>
<p>This code uses JSP like syntax where executable code is between &#8216;&lt;%&#8217; and &#8216;%&gt;&#8217; tags.  And variable expansion uses the &#8216;&lt;%=&#8217; and &#8216;%&gt;&#8217;; this means that the code inside the variable expansion gets expanded to the value in place (see <i>this.url</i> and <i>this.text</i> in example above.)  Where does the <i>arr</i> variable come from?  This is passed in as a context parameter to the completed template.  Whoa, last 2 sentences need to be explained a little more.  Look at the full HTML example distributed in the plugin itself:</p>
<pre class="coder">
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;1 </font></span><font color="#465457">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot; &quot;<a href="http://www.w3.org/TR/html4/loose.dtd">http://www.w3.org/TR/html4/loose.dtd</a>&quot;&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;2 </font></span><font color="#a6e22e">&lt;</font><font color="#f92672"><b>html</b></font><font color="#a6e22e">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;3 </font></span>&nbsp;&nbsp;<font color="#a6e22e">&lt;</font><font color="#f92672"><b>head</b></font><font color="#a6e22e">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;4 </font></span><font color="#a6e22e">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#a6e22e">&lt;</font><font color="#f92672"><b>meta</b></font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">http-equiv</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;Content-type&quot;</font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">content</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;text/html; charset=utf-8&quot;</font><font color="#a6e22e">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;5 </font></span><font color="#a6e22e">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#a6e22e">&lt;</font><font color="#f92672"><b>title</b></font><font color="#a6e22e">&gt;</font><font color="#ef5939"><b>Templating</b></font><font color="#fd971f">&lt;/</font><font color="#f92672"><b>title</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;6 </font></span><font color="#a6e22e">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#a6e22e">&lt;</font><font color="#a6e22e"><b>script</b></font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">src</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;../jqueryjs/jquery/dist/jquery.js&quot;</font><font color="#a6e22e">&gt;</font><font color="#fd971f">&lt;/</font><font color="#a6e22e"><b>script</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;7 </font></span><font color="#a6e22e">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#a6e22e">&lt;</font><font color="#a6e22e"><b>script</b></font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">src</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;../jqueryjs/plugins/templating/jquery.templating.js&quot;</font><font color="#a6e22e">&gt;</font><font color="#fd971f">&lt;/</font><font color="#a6e22e"><b>script</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;8 </font></span><font color="#a6e22e">&nbsp;&nbsp;&nbsp;&nbsp;</font><font color="#a6e22e">&lt;</font><font color="#a6e22e"><b>script</b></font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">type</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;text/javascript&quot;</font><font color="#a6e22e">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;9 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;jQuery</i></font></span>(<font color="#a6e22e">function</font>(<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>$</i></font></span>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;</i></font></span><font color="#a6e22e">{</font>
<span style="background-color: #232526"><font color="#bcbcbc">10 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.pageTemplates = </i></font></span><font color="#a6e22e">{}</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">11 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$</i></font></span>(<font color="#e6db74">&quot;script[type=text/x-jquery-template]&quot;</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.each</i></font></span>(<font color="#a6e22e">function</font>()<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;</i></font></span><font color="#a6e22e">{</font>
<span style="background-color: #232526"><font color="#bcbcbc">12 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$.pageTemplates</i></font></span><font color="#a6e22e">[</font><font color="#66d9ef">this</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.title</i></font></span><font color="#a6e22e">]</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;= $.makeTemplate</i></font></span>(<font color="#66d9ef">this</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.innerHTML, </i></font></span><font color="#e6db74">&quot;&lt;%&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>, </i></font></span><font color="#e6db74">&quot;%&gt;&quot;</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">13 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$</i></font></span>(<font color="#e6db74">&quot;body&quot;</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.append</i></font></span>(<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>$.pageTemplates</i></font></span><font color="#a6e22e">[</font><font color="#e6db74">&quot;template1&quot;</font><font color="#a6e22e">]</font>(<font color="#a6e22e">{</font><font color="#e6db74">arr</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">14 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#a6e22e">[{</font><font color="#e6db74">url</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;<a href="http://www.yehudakatz.com">http://www.yehudakatz.com</a>&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>, </i></font></span><font color="#e6db74">text</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;Yehuda's site&quot;</font><font color="#a6e22e">}</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>,</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">15 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </i></font></span><font color="#a6e22e">{</font><font color="#e6db74">url</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;<a href="http://www.gweezlebur.com">http://www.gweezlebur.com</a>&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>, </i></font></span><font color="#e6db74">text</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>: </i></font></span><font color="#e6db74">&quot;Ivey's site&quot;</font><font color="#a6e22e">}]</font>
<span style="background-color: #232526"><font color="#bcbcbc">16 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#a6e22e">}</font>))<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">17 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#a6e22e">}</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">18 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#a6e22e">}</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">19 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#fd971f">&lt;/</font><font color="#a6e22e"><b>script</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">20 </font></span><font color="#a6e22e">&nbsp;&nbsp;</font><font color="#fd971f">&lt;/</font><font color="#f92672"><b>head</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">21 </font></span>&nbsp;&nbsp;<font color="#a6e22e">&lt;</font><font color="#f92672"><b>body</b></font><font color="#a6e22e">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">22 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a6e22e">&lt;</font><font color="#a6e22e"><b>script</b></font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">type</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;text/x-jquery-template&quot;</font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">title</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;template1&quot;</font><font color="#a6e22e">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">23 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% $</i></font></span>(<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>arr</i></font></span>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.each</i></font></span>(<font color="#a6e22e">function</font>()<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;</i></font></span><font color="#a6e22e">{</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;%&gt;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">24 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;a href=</i></font></span><font color="#e6db74">&quot;&lt;%= this.url %&gt;&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&gt;&lt;%= </i></font></span><font color="#66d9ef">this</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>.text %&gt;&lt;/a&gt;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">25 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;% </i></font></span><font color="#a6e22e">}</font>)<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>; %&gt;</i></font></span>
<span style="background-color: #232526"><font color="#bcbcbc">26 </font></span><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>&nbsp;&nbsp;&nbsp;&nbsp;</i></font></span><font color="#fd971f">&lt;/</font><font color="#a6e22e"><b>script</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">27 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#a6e22e">&lt;</font><font color="#f92672"><b>a</b></font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">href</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;foo&quot;</font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">rel</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;#myTemplate&quot;</font><font color="#a6e22e">&nbsp;</font><font color="#66d9ef">class</font><font color="#a6e22e">=</font><font color="#e6db74">&quot;updateTemplate&quot;</font><font color="#a6e22e">&gt;</font><font color="#808080"><u>Click</u></font><font color="#fd971f">&lt;/</font><font color="#f92672"><b>a</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">28 </font></span>&nbsp;&nbsp;<font color="#fd971f">&lt;/</font><font color="#f92672"><b>body</b></font><font color="#fd971f">&gt;</font>
<span style="background-color: #232526"><font color="#bcbcbc">29 </font></span><font color="#fd971f">&lt;/</font><font color="#f92672"><b>html</b></font><font color="#fd971f">&gt;</font>
</font></pre>
<p>You can see the template itself in lines 22-26 cleverly embedded inside a script tag with a custom type attribute.  Now look at the lines 11-17.  Line 12 takes the template text itself and creates a template function.  Yes, <i>$.makeTemplate</i>, the public templating plugin method, returns a function.  That function is then called with a context parameter (a hash) and the template is evaluated.  Note that the <i>arr</i> variable is passed into the template function on line 13.</p>
<p>Aight!  What do you think of that?  At first, I was like what the heck? but looking at it a few times now and it&#8217;s rather natural.  Let&#8217;s look at the actual plugin next.  It&#8217;s only 25 lines of formatted code:</p>
<pre class="coder">
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;1 </font></span><font color="#465457">// Copyright Yehuda Katz</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;2 </font></span><font color="#465457">// with assistance by Jay Freeman</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;3 </font></span><font color="#465457">// You may distribute this code under the same license as jQuery (BSD or GPL)</font>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;4 </font></span>(<font color="#a6e22e">function</font>&nbsp;($)&nbsp;{
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;5 </font></span>&nbsp;&nbsp;$.makeTemplate = <font color="#a6e22e">function</font>&nbsp;(template, begin, end)&nbsp;{
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;6 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#66d9ef">var</font>&nbsp;rebegin = begin.replace(<font color="#e6db74">/([</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\]</i></font></span><font color="#e6db74">{}[</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\</i></font></span><font color="#e6db74">])/g</font>, <font color="#e6db74">'</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\</i></font></span><font color="#e6db74">$1'</font>);
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;7 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#66d9ef">var</font>&nbsp;reend = end.replace(<font color="#e6db74">/([</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\]</i></font></span><font color="#e6db74">{}[</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\</i></font></span><font color="#e6db74">])/g</font>, <font color="#e6db74">'</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\</i></font></span><font color="#e6db74">$1'</font>);
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;8 </font></span>
<span style="background-color: #232526"><font color="#bcbcbc">&nbsp;9 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#66d9ef">var</font>&nbsp;code = <font color="#e6db74">&quot;try { with (_context) {&quot;</font>&nbsp;+
<span style="background-color: #232526"><font color="#bcbcbc">10 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">&quot;var _result = '';&quot;</font>&nbsp;+
<span style="background-color: #232526"><font color="#bcbcbc">11 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;template
<span style="background-color: #232526"><font color="#bcbcbc">12 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#e6db74">/[</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\t\r\n</i></font></span><font color="#e6db74">]/g</font>, <font color="#e6db74">' '</font>)
<span style="background-color: #232526"><font color="#bcbcbc">13 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#e6db74">/^(.*)$/</font>, end + <font color="#e6db74">'$1'</font>&nbsp;+ begin)
<span style="background-color: #232526"><font color="#bcbcbc">14 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>RegExp</i></font></span>(reend + <font color="#e6db74">&quot;(.*?)&quot;</font>&nbsp;+ rebegin, <font color="#e6db74">&quot;g&quot;</font>), <font color="#a6e22e">function</font>&nbsp;(text)&nbsp;{
<span style="background-color: #232526"><font color="#bcbcbc">15 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>return</b></font>&nbsp;text
<span style="background-color: #232526"><font color="#bcbcbc">16 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>RegExp</i></font></span>(<font color="#e6db74">&quot;^&quot;</font>&nbsp;+ reend + <font color="#e6db74">&quot;(.*)&quot;</font>&nbsp;+ rebegin + <font color="#e6db74">&quot;$&quot;</font>), <font color="#e6db74">&quot;$1&quot;</font>)
<span style="background-color: #232526"><font color="#bcbcbc">17 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#e6db74">/</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\</i></font></span><font color="#e6db74">/g</font>, <font color="#e6db74">&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\\\</i></font></span><font color="#e6db74">&quot;</font>)
<span style="background-color: #232526"><font color="#bcbcbc">18 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#e6db74">/'/g</font>, <font color="#e6db74">&quot;</font><span style="background-color: #1b1d1e"><font color="#66d9ef"><i>\\</i></font></span><font color="#e6db74">'&quot;</font>)
<span style="background-color: #232526"><font color="#bcbcbc">19 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#e6db74">/^(.*)$/</font>, end + <font color="#e6db74">&quot;_result += '$1';&quot;</font>&nbsp;+ begin);
<span style="background-color: #232526"><font color="#bcbcbc">20 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})
<span style="background-color: #232526"><font color="#bcbcbc">21 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>RegExp</i></font></span>(rebegin + <font color="#e6db74">&quot;=(.*?)&quot;</font>&nbsp;+ reend, <font color="#e6db74">&quot;g&quot;</font>), <font color="#e6db74">&quot;_result += ($1);&quot;</font>)
<span style="background-color: #232526"><font color="#bcbcbc">22 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>RegExp</i></font></span>(rebegin + <font color="#e6db74">&quot;(.*?)&quot;</font>&nbsp;+ reend, <font color="#e6db74">&quot;g&quot;</font>), <font color="#e6db74">' $1 '</font>)
<span style="background-color: #232526"><font color="#bcbcbc">23 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.replace(<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>RegExp</i></font></span>(<font color="#e6db74">&quot;^&quot;</font>&nbsp;+ reend + <font color="#e6db74">&quot;(.*)&quot;</font>&nbsp;+ rebegin + <font color="#e6db74">&quot;$&quot;</font>), <font color="#e6db74">'$1'</font>) +
<span style="background-color: #232526"><font color="#bcbcbc">24 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">&quot;return _result;&quot;</font>&nbsp;+
<span style="background-color: #232526"><font color="#bcbcbc">25 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#e6db74">&quot;} } catch(e) { return '' } &quot;</font>;
<span style="background-color: #232526"><font color="#bcbcbc">26 </font></span>
<span style="background-color: #232526"><font color="#bcbcbc">27 </font></span>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#f92672"><b>return</b></font>&nbsp;<font color="#f92672">new</font>&nbsp;<span style="background-color: #1b1d1e"><font color="#66d9ef"><i>Function</i></font></span>(<font color="#e6db74">&quot;_context&quot;</font>, code);
<span style="background-color: #232526"><font color="#bcbcbc">28 </font></span>&nbsp;&nbsp;};
<span style="background-color: #232526"><font color="#bcbcbc">29 </font></span>})(jQuery);
</font></pre>
<p>Very nicely written I would have to say.</p>
<p>Lines 6-7 munges the <i>begin</i> and <i>end</i> tags to be regualar expression friendly.</p>
<p>The next statement (lines 9-25) creates the code block.  Note that the code block starts with a <i>with (_context) {</i> and returns the code block on line 27 with <i>return new Function(&#8221;_context&#8221;, code)</i>.  If you forgot what the <i>with</i> statement in JavaScript does, take a look <a href="http://javascript.about.com/library/blwith.htm">here</a>.  There&#8217;s a bunch of regular expressions that I&#8217;m sure you can figure out (nothing too difficult), but a quick way to see what this is doing is adding the line &#8216;<i>alert(code)</i>&#8216; at line 26.  Ahh, should be obvious now.</p>
<p>Doing this for the example, gives the text below and it becomes obvious:</p>
<pre class="coder" style="font-family: monospace">
try {
  with (_context) {
    var _result = '';
    _result += '       ';
    $(arr).each(function() {
      _result += '         &lt;a href="';
      _result += ( this.url );
      _result += '"&gt;';
      _result += ( this.text );
      _result += '&lt;/a&gt;       ';
    });
    _result += '     ';
    return _result;
  }
} catch(e) { return '' }
</pre>
<p>So to recap a few points:</p>
<ul>
<li>You can think of <i>$.makeTemplate</i> as a code generator returning a<br />
  function to run the template with the passed arguments.</li>
<li>The &#8220;code generator&#8221; works by creating the code as a string and passing it<br />
  back using the Function constructor.</li>
<li>The second part of the above, is that a context (hash) is passed to<br />
  actually fill out the template.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/11/jquery-templating-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Leningrad Cowboys &#038; Red Army Choir</title>
		<link>http://www.bigredswitch.com/blog/2008/10/leningrad-cowboys-red-army-choir/</link>
		<comments>http://www.bigredswitch.com/blog/2008/10/leningrad-cowboys-red-army-choir/#comments</comments>
		<pubDate>Wed, 29 Oct 2008 13:17:57 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=177</guid>
		<description><![CDATA[I love it, the Leningrad Cowboys and the Red Army Choir play Sweet Home Alabama.

]]></description>
			<content:encoded><![CDATA[<p>I love it, the Leningrad Cowboys and the Red Army Choir play Sweet Home Alabama.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="src" value="http://www.youtube.com/v/0lNFRLrP014&amp;hl=en&amp;fs=1" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/0lNFRLrP014&amp;hl=en&amp;fs=1" allowfullscreen="true"></embed></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/10/leningrad-cowboys-red-army-choir/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Coupons everywhere!</title>
		<link>http://www.bigredswitch.com/blog/2008/10/coupons-everywhere/</link>
		<comments>http://www.bigredswitch.com/blog/2008/10/coupons-everywhere/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 14:23:43 +0000</pubDate>
		<dc:creator>doug</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=175</guid>
		<description><![CDATA[Found this site, which is directly relevant to our coupons module:
Coupons.com
How did i find this little gem? I just typed in coupons.com into my url bar. Why not, i thought.
Few interesting points:

Enter your zip code and tada! coupons for your area. Sounds like someone else&#8217;s plan &#8230; :)
Clearly aimed at large retail; try the Business [...]]]></description>
			<content:encoded><![CDATA[<p>Found this site, which is directly relevant to our coupons module:<br />
<a href="http://www.coupons.com">Coupons.com</a></p>
<p>How did i find this little gem? I just typed in coupons.com into my url bar. Why not, i thought.<br />
Few interesting points:</p>
<ul>
<li>Enter your zip code and tada! coupons for your area. Sounds like someone else&#8217;s plan &#8230; :)</li>
<li>Clearly aimed at large retail; try the Business Solutions page for hours of fun!</li>
<li>Doesn&#8217;t work on Mac &#8230; at least in my experience.</li>
<li>Interesting that it&#8217;s paired with &#8220;Recipes&#8221;. Pretty clear what the target demographic is.</li>
</ul>
<p>Well, happy printing and saving!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/10/coupons-everywhere/feed/</wfw:commentRss>
		</item>
		<item>
		<title>jQuery Dynamic TextboxList with Autocomplete</title>
		<link>http://www.bigredswitch.com/blog/2008/10/jquery-dynamic-textboxlist/</link>
		<comments>http://www.bigredswitch.com/blog/2008/10/jquery-dynamic-textboxlist/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 01:57:50 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[javascript]]></category>

		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=138</guid>
		<description><![CDATA[Hmmm, had a hard time naming this since I couldn&#8217;t think of a title that was succinct and more descriptive than the generic one above.  Any suggestions?  Update: it&#8217;s official!  In honor of Transformers everywhere, it&#8217;s now called autobox. 
Anyway, let&#8217;s just show the plugin:




 TextboxList with Autocomplete


Type an email or list name

fred@foo.bar
barney@foo.bar






Now the [...]]]></description>
			<content:encoded><![CDATA[<p>Hmmm, had a hard time naming this since I couldn&#8217;t think of a title that was succinct and more descriptive than the generic one above.  Any suggestions?  <i>Update: it&#8217;s official!  In honor of Transformers everywhere, it&#8217;s now called autobox.</i> </p>
<p>Anyway, let&#8217;s just show the plugin:</p>
<p><script src="/blog/wp-content/uploads/2008/10/jquerytextboxlist.js" type="text/javascript"></script></p>
<link rel="stylesheet" href="/blog/wp-content/uploads/2008/10/jquerytextboxlist.css" type="text/css" media="screen" title="Test Stylesheet" charset="utf-8" />
<form action="test_submit" accept-charset="utf-8" method="get">
<ol>
<li> <label>TextboxList with Autocomplete</label><br />
<input id="test-1" type="text" />
<div id="test-1-auto">
<div class="default">Type an email or list name</div>
<ul class="feed">
<li>fred@foo.bar</li>
<li>barney@foo.bar</li>
</ul>
</div>
</li>
</ol>
</form>
<p><script src="/blog/wp-content/uploads/2008/10/jquery-test-frag.js" type="text/javascript"></script></p>
<p>Now the story:</p>
<p>Guillermo Rauch has a very nice mootools script that does a Facebook-like or AppleMail-like input control: the<a href="http://devthought.com/textboxlist-fancy-facebook-like-dynamic-inputs/">basic one here</a> and <a href="http://devthought.com/textboxlist-meets-autocompletion/">here with autocompletion</a>.  The first thing I noticed is that Guillermo is only 17 years old! If you look at his original code, it&#8217;s clean and well written even if he was an industry veteran - amazing!</p>
<p>This plugin is what we&#8217;re looking for in our email composer.  Also, I was looking to actually cutting my teeth a little bit in javascript and jQuery (I&#8217;m currently reading chapter 3 of the jQ in Action book).  This points at porting this thing so here it is:</p>
<p>Update (10/23): Connect input behavior to submit values; updated example<br />
<a href="http://www.bigredswitch.com/blog/wp-content/uploads/2008/10/jq-autobox-plugin-052.zip">jq-autobox-plugin-052.zip</a><br />
Update (10/21): Rename to autobox<br />
<strike><a href="http://www.bigredswitch.com/blog/wp-content/uploads/2008/10/jq-autobox-plugin-051.zip">jq-autobox-plugin-051.zip</a></strike><br />
<strike><a href="http://www.bigredswitch.com/blog/wp-content/uploads/2008/10/jq.textboxlist.plugin-050.zip">jq.textboxlist.plugin-050.zip</a></strike></p>
<p>Notes on the port:</p>
<ul>
<li>Unlike <a href="http://www.interiders.com/2008/02/18/protomultiselect-02/">this prototype port</a>, it&#8217;s not a line-by-line port.  I&#8217;ve simplified it in some ways and added a few features.</li>
<li>The biggest simplification is that the mini-input boxes are gone.  I originally ported them, but didn&#8217;t really see a use for them.  Since I mostly believe in cutting rather than hiding, that&#8217;s what I did.  It also made some of the focus/blur/movement easier.</li>
<li>The mootools and prototype version are object-oriented style.  My port is more functional program style.  That is, I think it&#8217;s more functional programming style since I do not have much experience with functional programming.  I will say though, that what I think is functional programming, is very natural and clear.  Reminds me a bit of my college Scheme programming.  That said, the code is not very extensible.</li>
<li>Javascript programming is a <i>ton</i> of fun.</li>
<li>I integrated the autocomplete directly into the plugin.  The original extended the textbox list class.  To me, the autocomplete is part of the control and also, to the last point, it wasn&#8217;t exactly clear to me the most natural or accepted way to extend the plugin.</li>
<li>The focus/blur/movements were simplified.</li>
<li>You can enter a value and press return, which will add that value as an item.</li>
<li>Actually formatted it and put a few comments.</li>
<li>There is some focus/blur funkiness that needs to be worked out.</li>
<li>Tested on IE7 and FF3.</li>
<li>Validation to be added.</li>
</ul>
<p>We would love to get feedback on the control!  The release is 0.5.0 (alpha); I&#8217;m sure there are problems with it and bug reports would be appreciated as well.  I will release at least a few more versions as they get cooked and I get more familiar with jQuery and Javascript.</p>
<p>Quick instructions to create the demo above:</p>
<ol>
<li>In your HTML, include jQuery, the plugin (jquery.textboxlist.js), and the CSS (jquery.textboxlist.css).</li>
<li>Put close.gif in the same directory or else change the css to point to where you put it.</li>
<li>The CSS assumes a form with ordered list and list element container.  I.e. the CSS assumes the form as in the example.</li>
<li>Below the main input element, in the same list element, add a div element with the ID from above appended by &#8216;-auto&#8217;, this is the autofeed.  See the example.</li>
<li>In a script tag, get the ID and call &#8216;.textboxlist()&#8217; on it to make it a textboxlist.</li>
<li>Optionally pre-populate any autofeed elements.</li>
</ol>
<pre style="overflow: scroll; background-color: #1b1d1e; color: #f8f8f2; height: 300px;"><span style="font-family: monospace;">
<span style="color: #465457;">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd</a>"&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>html</strong></span><span style="color: #a6e22e;"> xmlns=</span><span style="color: #e6db74;">"<a href="http://www.w3.org/1999/xhtml">http://www.w3.org/1999/xhtml</a>"</span><span style="color: #a6e22e;"> xml:</span><span style="color: #66d9ef;">lang</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"en"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">lang</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"en"</span><span style="color: #a6e22e;">&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>head</strong></span><span style="color: #a6e22e;">&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>meta</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">http-equiv</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"Content-type"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">content</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"text/html; charset=utf-8"</span><span style="color: #a6e22e;"> /&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>title</strong></span><span style="color: #a6e22e;">&gt;</span><span style="color: #ef5939;"><strong>jQuery TextboxList Demo</strong></span><span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>title</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>link</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">rel</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"stylesheet"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">href</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"jquery.textboxlist.css"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">type</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"text/css"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">media</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"screen"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">title</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"Test Stylesheet"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">charset</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"utf-8"</span><span style="color: #a6e22e;"> /&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #a6e22e;"><strong>script</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">src</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"../jqueryjs/jquery/dist/jquery.js"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">type</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"text/javascript"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">charset</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"utf-8"</span><span style="color: #a6e22e;">&gt;</span><span style="color: #fd971f;">&lt;/</span><span style="color: #a6e22e;"><strong>script</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #a6e22e;"><strong>script</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">src</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"jquery.textboxlist.js"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">type</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"text/javascript"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">charset</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"utf-8"</span><span style="color: #a6e22e;">&gt;</span><span style="color: #fd971f;">&lt;/</span><span style="color: #a6e22e;"><strong>script</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #a6e22e;"><strong>style</strong></span><span style="color: #a6e22e;">&gt;</span><span style="color: #f92672;"><strong>img</strong></span><span style="color: #a6e22e;">{</span> <span style="color: #fd971f;"><em>height</em></span>: <span style="color: #ae81ff;">100px</span>; <span style="color: #fd971f;"><em>float</em></span>: <span style="color: #fd971f;"><em>left</em></span>; <span style="color: #a6e22e;">}</span><span style="color: #fd971f;">&lt;/</span><span style="color: #a6e22e;"><strong>style</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>head</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>body</strong></span><span style="color: #a6e22e;">&gt;</span>
  <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>form</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">action</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"test_submit"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">method</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"get"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">accept</span><span style="color: #a6e22e;">-</span><span style="color: #66d9ef;">charset</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"utf-8"</span><span style="color: #a6e22e;">&gt;</span>
  <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>ol</strong></span><span style="color: #a6e22e;">&gt;&lt;</span><span style="color: #f92672;"><strong>li</strong></span><span style="color: #a6e22e;">&gt;</span>
      <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>label</strong></span><span style="color: #a6e22e;">&gt;</span>Test input<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>label</strong></span><span style="color: #fd971f;">&gt;</span>
      <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>input</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">type</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"text"</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">value</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">""</span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">id</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"test-1"</span><span style="color: #a6e22e;">/&gt;</span>
      <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>div</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">id</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"test-1-auto"</span><span style="color: #a6e22e;">&gt;</span>
        <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>div</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">class</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"default"</span><span style="color: #a6e22e;">&gt;</span>Type an email or list name<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>div</strong></span><span style="color: #fd971f;">&gt;</span>
        <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>ul</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">class</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"feed"</span><span style="color: #a6e22e;">&gt;</span>
          <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>li</strong></span><span style="color: #a6e22e;">&gt;</span>fred@foo.bar<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>li</strong></span><span style="color: #fd971f;">&gt;</span>
          <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>li</strong></span><span style="color: #a6e22e;">&gt;</span>barney@foo.bar<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>li</strong></span><span style="color: #fd971f;">&gt;</span>
        <span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>ul</strong></span><span style="color: #fd971f;">&gt;</span>
      <span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>div</strong></span><span style="color: #fd971f;">&gt;</span>
    <span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>li</strong></span><span style="color: #fd971f;">&gt;&lt;/</span><span style="color: #f92672;"><strong>ol</strong></span><span style="color: #fd971f;">&gt;</span>
  <span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>form</strong></span><span style="color: #fd971f;">&gt;</span>
  <span style="color: #a6e22e;">&lt;</span><span style="color: #a6e22e;"><strong>script</strong></span><span style="color: #a6e22e;">&gt;</span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>    $</em></span></span>(<span style="color: #a6e22e;">function</span>()<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em> </em></span></span><span style="color: #a6e22e;">{</span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>      </em></span></span><span style="color: #66d9ef;">var</span><span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em> tbl = $</em></span></span>(<span style="color: #e6db74;">'#test-1'</span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>.textboxlist</em></span></span>()<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>.get</em></span></span>(<span style="color: #ae81ff;">0</span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>;</em></span></span>
<span style="color: #465457;">      //tbl.add('added@here.com');</span>
<span style="color: #465457;">      //tbl.autoFeed('autofeed1@there.com');</span>
<span style="color: #465457;">      //tbl.autoFeed('autofeed2@there.com');</span>
<span style="color: #465457;">      //tbl.autoFeed('autofeed3@there.com');</span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>      $.getJSON</em></span></span>(<span style="color: #e6db74;">'json.html'</span><span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>, </em></span></span><span style="color: #a6e22e;">function</span>(<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>json</em></span></span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em> </em></span></span><span style="color: #a6e22e;">{</span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>        $.each</em></span></span>(<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>json, </em></span></span><span style="color: #a6e22e;">function</span>(<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>idx,str</em></span></span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em> </em></span></span><span style="color: #a6e22e;">{</span><span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em> tbl.autoFeed</em></span></span>(<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>str</em></span></span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>; </em></span></span><span style="color: #a6e22e;">}</span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>;</em></span></span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>      </em></span></span><span style="color: #a6e22e;">}</span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>;</em></span></span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>    </em></span></span><span style="color: #a6e22e;">}</span>)<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>;</em></span></span>
<span style="background-color: #1b1d1e"><span style="color: #66d9ef;"><em>  </em></span></span><span style="color: #fd971f;">&lt;/</span><span style="color: #a6e22e;"><strong>script</strong></span><span style="color: #fd971f;">&gt;</span>
  <span style="color: #a6e22e;">&lt;</span><span style="color: #f92672;"><strong>div</strong></span><span style="color: #a6e22e;"> </span><span style="color: #66d9ef;">id</span><span style="color: #a6e22e;">=</span><span style="color: #e6db74;">"console"</span><span style="color: #a6e22e;">&gt;</span>
  <span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>div</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>body</strong></span><span style="color: #fd971f;">&gt;</span>
<span style="color: #fd971f;">&lt;/</span><span style="color: #f92672;"><strong>html</strong></span><span style="color: #fd971f;">&gt;</span>
</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/10/jquery-dynamic-textboxlist/feed/</wfw:commentRss>
		</item>
		<item>
		<title>I am now a Mac?</title>
		<link>http://www.bigredswitch.com/blog/2008/10/i-am-now-a-mac/</link>
		<comments>http://www.bigredswitch.com/blog/2008/10/i-am-now-a-mac/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 01:39:05 +0000</pubDate>
		<dc:creator>doug</dc:creator>
		
		<category><![CDATA[Announcement]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=134</guid>
		<description><![CDATA[Ha! Writing this post from shiny new macbook pro 15&#8243;. Very fancy indeed, in fact, i could buy three basic Dells for this price. Or two pretty slammed Dells, plus a Dell mini.
Initial thoughts? LOVE the multitouch pad. Two fingers to scroll, brilliant. I&#8217;m a complete keyboard shortcut fiend, so that part is very important [...]]]></description>
			<content:encoded><![CDATA[<p>Ha! Writing this post from shiny new macbook pro 15&#8243;. Very fancy indeed, in fact, i could buy three basic Dells for this price. Or two pretty slammed Dells, plus a Dell mini.</p>
<p>Initial thoughts? LOVE the multitouch pad. Two fingers to scroll, brilliant. I&#8217;m a complete keyboard shortcut fiend, so that part is very important for me &#8230; if the robustness of OS shortcuts aren&#8217;t there, it&#8217;ll be hard for me to drink the entire glass (of kool-aid).</p>
<p>Other than that, I mean - it runs applications, right? You can save and manage files too. Also, when you press a key, the corresponding letter appears in the editor. I guess I don&#8217;t ask a lot from my OS.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/10/i-am-now-a-mac/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Form Validation</title>
		<link>http://www.bigredswitch.com/blog/2008/09/form-validation/</link>
		<comments>http://www.bigredswitch.com/blog/2008/09/form-validation/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 00:21:56 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[design]]></category>

		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=129</guid>
		<description><![CDATA[Looked for some resources to help with form validation design and found some good links:

jQuery Validation Basic stuff, our baseline (since we use jQuery validation)
Yahoo Signup Page I&#8217;ve always loved how this page does validation (hit submit without filling in any fields)
47+ Excellent Ajax Forms Self proclamation

Smashing Magazine Web Form Design Patterns Part 1 and [...]]]></description>
			<content:encoded><![CDATA[<p>Looked for some resources to help with form validation design and found some good links:</p>
<ul>
<li><a href="http://jquery.bassistance.de/validate/demo/">jQuery Validation</a> Basic stuff, our baseline (since we use jQuery validation)</li>
<li><a href="https://edit.yahoo.com/registration">Yahoo Signup Page</a> I&#8217;ve always loved how this page does validation (hit submit without filling in any fields)</li>
<li><a href="http://www.noupe.com/css/47-excellent-ajax-css-forms.html">47+ Excellent Ajax Forms</a> Self proclamation<a href="http://www.noupe.com/css/47-excellent-ajax-css-forms.html"><br />
</a></li>
<li>Smashing Magazine Web Form Design Patterns <a href="http://www.smashingmagazine.com/2008/07/04/web-form-design-patterns-sign-up-forms/">Part 1</a> and <a href="http://www.smashingmagazine.com/2008/07/08/web-form-design-patterns-sign-up-forms-part-2/">Part 2</a></li>
<li><a href="http://wufoo.com/">Wufoo</a> Online Form Builder<a href="http://wufoo.com/"><br />
</a></li>
<li><a href="http://www.lukew.com/resources/articles/WebForms_LukeW.pdf">Best Practices for Form Design</a> by Luke Wroblewski, Wow!</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/09/form-validation/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Java Enlightenment</title>
		<link>http://www.bigredswitch.com/blog/2008/09/java-enlightenment/</link>
		<comments>http://www.bigredswitch.com/blog/2008/09/java-enlightenment/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 16:38:19 +0000</pubDate>
		<dc:creator>brandon</dc:creator>
		
		<category><![CDATA[Development]]></category>

		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.bigredswitch.com/blog/?p=114</guid>
		<description><![CDATA[I don&#8217;t know why Java web companies do not communicate architecture and design more often.  It seems like the Ruby guys and the PHP guys or the Perl guys talk about how they do things.  For example, the classic LiveJournal backend scaling presentation.
One exception: LinkedIn does a fantastic job of bringing the Java web application [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t know why Java web companies do not communicate architecture and design more often.  It seems like the Ruby guys and the PHP guys or the Perl guys talk about how they do things.  For example, the classic <a href="http://www.scribd.com/doc/2684169/LiveJournal-scaling">LiveJournal backend scaling presentation</a>.</p>
<p>One exception: LinkedIn does a fantastic job of bringing the Java web application discourse forward with presentations (<a href="http://www.slideshare.net/linkedin/linkedins-communication-architecture">Tech and Practices</a> and <a href="http://www.slideshare.net/linkedin/linked-in-javaone-2008-tech-session-comm">Comm Arch</a> for example) and open discussion.  We need more!</p>
<p>By the way, anybody have a list of papers, presentations, and blogs from Java web efforts?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bigredswitch.com/blog/2008/09/java-enlightenment/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
