<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>BBQIguana &#187; Web</title>
	<atom:link href="http://www.bbqiguana.com/category/web/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bbqiguana.com</link>
	<description></description>
	<lastBuildDate>Fri, 28 Oct 2011 13:17:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Lightboxes are for assholes</title>
		<link>http://www.bbqiguana.com/2011/08/lightboxes-are-for-assholes/</link>
		<comments>http://www.bbqiguana.com/2011/08/lightboxes-are-for-assholes/#comments</comments>
		<pubDate>Sat, 20 Aug 2011 23:45:24 +0000</pubDate>
		<dc:creator>bbqiguana</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=1856</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2011/08/lightboxes-are-for-assholes/" data-text="Lightboxes are for assholes" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>There is a sickening, maddening, frustrating, irritating trend in the web for the last year or so. People are overusing &#8220;lightboxes&#8221;. </p>
<p>A lightbox is that effect when the screen goes kind of dark and you can only see one thing centered in the middle. It&#8217;s a modern (web 2.0?) form of modal input. </p>
<p>In other words, it stops you from doing what you want, in order to force you to do what the web site wants. And that, my friends, is a fundamentally evil behavior.</p>
<p>This particular behavior is especially overused in internet marketing: you&#8217;re trying to read a blog and then suddenly you can&#8217;t do anything until you sign up for their email list; you&#8217;re trying to read some song lyrics but suddenly your screen is hijacked by an ad for ringtones; you click a link to read an article on a news site, but before you can read it you have to sit through a commercial for Swiffer or some other bullshit.  </p>
<p>Well fuck that.  I made a browser plugin to shut off those lightboxes. Click for <a href="https://addons.mozilla.org/en-US/firefox/addon/stoppity-poppity/" title="Stoppity Poppity for Firefox">Firefox</a>. Click for <a href="https://chrome.google.com/webstore/detail/abckjldgppcaijlhpdjipckhehlpenbf" title="Stoppity Poppity for Chrome">Chrome</a>. </p>
<p>Unfortunately, because this is a non-standard behavior, there are limitless ways to create new lightbox popups and my plugin can never stop <em>all of them</em>, but I&#8217;m happy just to stop the most used ones, if that means an improved browsing experience for some people.</p>
<p>Meanwhile, if you use my plugin and you see a site with lightbox popus that aren&#8217;t blocked, please <a href="http://twitter.com/yearlyglot" title="@yearlyglot">tweet me</a> or <a href="mailto:letsgetrandy@gmail.com">email me</a> or comment here and I&#8217;ll happily add support to block it in the future.</p>
<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='https://addons.mozilla.org/en-US/firefox/addon/stoppity-poppity/' title="Stoppity Poppity for Firefox">Stoppity Poppity for Firefox</a></li><li><a href='https://chrome.google.com/webstore/detail/abckjldgppcaijlhpdjipckhehlpenbf' title="Stoppity Poppity for Chrome">Stoppity Poppity for Chrome</a></li><li><a href='http://twitter.com/yearlyglot' title="@yearlyglot">@yearlyglot</a></li><li><a href='mailto:letsgetrandy@gmail.com'>mailto:letsgetrandy@gmail.com</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2011/08/lightboxes-are-for-assholes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Long overdue feature added to Linked Image plugin</title>
		<link>http://www.bbqiguana.com/2010/12/long-overdue-feature-added-to-linked-image-plugin/</link>
		<comments>http://www.bbqiguana.com/2010/12/long-overdue-feature-added-to-linked-image-plugin/#comments</comments>
		<pubDate>Thu, 23 Dec 2010 19:06:28 +0000</pubDate>
		<dc:creator>bbqiguana</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=1782</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2010/12/long-overdue-feature-added-to-linked-image-plugin/" data-text="Long overdue feature added to Linked Image plugin" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>The most requested feature of my <a href="http://www.bbqiguana.com/wordpress-plugins/add-linked-images-to-gallery/" title="Add Linked Images To Gallery plugin for WordPress">Add Linked Images To Gallery</a> plugin has been a function to process all past posts.</p>
<p>I&#8217;ve finally found the time to add this feature, and published it as version 1.3.  I hope this will make everyone happy. Merry Christmas.</p>
<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='http://www.bbqiguana.com/wordpress-plugins/add-linked-images-to-gallery/' title="Add Linked Images To Gallery plugin for WordPress">Add Linked Images To ... plugin for WordPress</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2010/12/long-overdue-feature-added-to-linked-image-plugin/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Don&#8217;t publish an API that isn&#8217;t complete</title>
		<link>http://www.bbqiguana.com/2010/11/dont-publish-an-api-that-isnt-complete/</link>
		<comments>http://www.bbqiguana.com/2010/11/dont-publish-an-api-that-isnt-complete/#comments</comments>
		<pubDate>Mon, 29 Nov 2010 16:01:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=1766</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2010/11/dont-publish-an-api-that-isnt-complete/" data-text="Don't publish an API that isn't complete" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>I&#8217;ve been receiving comments lately from people asking me to update my Crossposterous plugin to use additional features from Posterous, particularly those added by version 2 of their API.</p>
<p>And I would love to do that. </p>
<p>Unfortunately, Posterous has published an incomplete API, and what they call documentation is what I call a joke.</p>
<p>And to add insult to injury, they&#8217;ve also removed (or hidden) all the documentation from the V1 API that I am currently using, and seems to work (most of the time).</p>
<p>I&#8217;ve worked in startups that were constantly rushing bad code out to production and then fixing it later, and I understand the mentality of deliver-and-iterate.  If you&#8217;re going to deliver a little now and add to it later, that&#8217;s fine. It makes sense. But don&#8217;t remove something that&#8217;s working just for the sake of adding something that&#8217;s not.</p>
<p>And moreover, we&#8217;re talking about an API here.  This isn&#8217;t a UI change that might take a moment for people to get used to later&#8230; it&#8217;s a change in functionality that requires developers to re-write and re-release software. It&#8217;s frustrating and irresponsible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2010/11/dont-publish-an-api-that-isnt-complete/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter client for Kindle!</title>
		<link>http://www.bbqiguana.com/2010/09/twitter-client-for-kindle/</link>
		<comments>http://www.bbqiguana.com/2010/09/twitter-client-for-kindle/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 04:36:04 +0000</pubDate>
		<dc:creator>bbqiguana</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Kindle]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=1641</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2010/09/twitter-client-for-kindle/" data-text="Twitter client for Kindle!" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>Impressed with the availability of free 3G wireless on Kindle, I decided to buy one. And within the first few minutes of playing with it, I found myself on the Twitter web site, cringing while I loaded their heavy UI from this device.</p>
<p>So I did the only logical thing I could think of.  I created a Kindle-friendly client for Twitter.  <a href="http://www.kindletwit.com/">KindleTwit</a>.</p>
<p>I wrote the whole thing in the last few hours, so I&#8217;m sure there are some designn details I should work out. And in time, I will.  But the important thing is that it works.</p>
<p>Go try it out!</p>
<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='http://www.kindletwit.com/'>http://www.kindletwit.com/</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2010/09/twitter-client-for-kindle/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Bug tracking via Twitter?</title>
		<link>http://www.bbqiguana.com/2009/11/bug-tracking-via-twitter/</link>
		<comments>http://www.bbqiguana.com/2009/11/bug-tracking-via-twitter/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 04:03:13 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=1219</guid>
		<description><![CDATA[An interesting thought just occurred to me...   It seems quite reasonable to implement the Twitter API as a bug-tracking tool.]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2009/11/bug-tracking-via-twitter/" data-text="Bug tracking via Twitter?" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>An interesting thought just occurred to me&#8230;   It seems quite reasonable to implement the Twitter API as a bug-tracking tool.</p>
<p>A software team could implement a Twitter account for bug tracking, and include the API into their projects within various try-catch blocks around potential points of failure.  Then, all the members of that team would just follow that twitter account.  For more critical applications, they could turn on device updates.  It seems like a more available version of the old developer&#8217;s standby of programmatically emailing bug reports.</p>
<p>For sensitive applications, the tweets could be &#8220;protected&#8221;&#8230; but for less critical uses, the visibility of the public timeline would seem to be an added incentive for developers to fix bugs quickly.</p>
<p>It&#8217;s an interesting thought.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2009/11/bug-tracking-via-twitter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>String formatting for Javascript</title>
		<link>http://www.bbqiguana.com/2009/11/string-formatting-for-javascript/</link>
		<comments>http://www.bbqiguana.com/2009/11/string-formatting-for-javascript/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 23:03:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=1149</guid>
		<description><![CDATA[Today, I was asked by a C# developer if Javascript has any string formatting functions comparable to the String.Format() method in C#.  I thought about it for a few minutes, going over the possibilities of regular expressions in my head, but finally settled on giving him a simple extension to Javascript's String object.]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2009/11/string-formatting-for-javascript/" data-text="String formatting for Javascript" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>Today, I was asked by a C# developer if Javascript has any string formatting functions comparable to the String.Format() method in C#.</p>
<p>I thought about it for a few minutes, going over the possibilities of regular expressions in my head, but finally settled on giving him a simple extension to Javascript&#8217;s String object.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">String.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">format</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> str <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>arguments.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> str<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">&lt;</span>arguments.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'{'</span><span style="color: #339933;">+</span>i<span style="color: #339933;">+</span><span style="color: #3366CC;">'}'</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> str<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This simple function gives your Javascript strings the exact same formatting ability they would have in C#.</p>
<p>Test it out for yourself:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> s <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Hello, {0}, I am {1}, and I am {2} to meet you.'</span><span style="color: #339933;">;</span>
<span style="color: #000066;">alert</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">format</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'foo'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'bar'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'baz'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2009/11/string-formatting-for-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Blinker</title>
		<link>http://www.bbqiguana.com/2009/10/css-blinker/</link>
		<comments>http://www.bbqiguana.com/2009/10/css-blinker/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 19:19:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=136</guid>
		<description><![CDATA[The secret to user-friendly forms in web apps is to draw attention to errors before submitting the form, and to do so without accosting the user with irritating Javscript popups.]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2009/10/css-blinker/" data-text="CSS Blinker" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>The secret to user-friendly forms in web apps is to draw attention to errors before submitting the form, and to do so without accosting the user with irritating Javscript popups.</p>
<p>After filling in half a dozen (or more) form fields and then pressing the submit button, the user has mentally moved on.  Suddenly hearing a &#8220;clunk&#8221; sound and getting a popup that says &#8220;invalid ssn&#8221; is jarring to say they least&#8230; but it also means the user must now read through all the form labels looking for something that sounds like &#8220;invalid ssn&#8221;.</p>
<p>My solution is to flash the form field drawing the user&#8217;s attention to exactly what information needs to be fixed.  And for that, I have created <a href="/js/Blinker.js">Blinker.js</a>.</p>
<p>Just include Blinker.js into your page. Then, during validation, when a field is not valid, just call Blinker:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Blinker.<span style="color: #660066;">blink</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'element-id'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'error-classname'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Blinker uses the supplied CSS classname to do the <em>blinking</em>, so you can use any effect you want:  change the text color, change the background, underline, add a border, whatever floats your boat.  Just declare the desired style in your CSS and then use that class name in your call, along with the DOM ID of the element to flash.</p>
<p>The <em>scrollTo</em> option allows Blinker to scroll a field into the viewport if it&#8217;s not visible.  The <em>onDelay</em> and <em>offDelay</em> allow you to customize the rate of blinking, and <em>cycle</em> determines the number of times to flash.</p>
<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='/js/Blinker.js'>/js/Blinker.js</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2009/10/css-blinker/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive script inclusion with REQUIRE (C#)</title>
		<link>http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require-c/</link>
		<comments>http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require-c/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 20:54:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=144</guid>
		<description><![CDATA[This is the C# version of the script I posted earlier.  It's also available as a VB.net version.]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require-c/" data-text="Recursive script inclusion with REQUIRE (C#)" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>This is the C# version of the script I posted earlier.  It&#8217;s also available as a <a href="/2009/10/recursive-script-inclusion-with-require/">VB.net version</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Collections</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.IO</span><span style="color: #008000;">;</span>
<span style="color: #0600FF; font-weight: bold;">using</span> <span style="color: #008080;">System.Web</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #0600FF; font-weight: bold;">public</span> <span style="color: #0600FF; font-weight: bold;">partial</span> <span style="color: #6666cc; font-weight: bold;">class</span> javascript <span style="color: #008000;">:</span> <span style="color: #000000;">System.<span style="color: #0000FF;">Web</span><span style="color: #008000;">.</span><span style="color: #0000FF;">UI</span></span><span style="color: #008000;">.</span><span style="color: #0000FF;">Page</span>
<span style="color: #008000;">&#123;</span>
	<span style="color: #0600FF; font-weight: bold;">private</span> Stack files<span style="color: #008000;">;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">protected</span> <span style="color: #6666cc; font-weight: bold;">void</span> Page_Load<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">object</span> sender, EventArgs e<span style="color: #008000;">&#41;</span>
    <span style="color: #008000;">&#123;</span>
		files <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> Stack<span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		Response<span style="color: #008000;">.</span><span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;application/x-javascript&quot;</span><span style="color: #008000;">;</span>
		Response<span style="color: #008000;">.</span><span style="color: #0000FF;">Write</span><span style="color: #008000;">&#40;</span>GetFile<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;js/Contacts.js&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
	<span style="color: #008000;">&#125;</span>
&nbsp;
	<span style="color: #0600FF; font-weight: bold;">private</span> <span style="color: #6666cc; font-weight: bold;">string</span> GetFile<span style="color: #008000;">&#40;</span><span style="color: #6666cc; font-weight: bold;">string</span> path<span style="color: #008000;">&#41;</span>
	<span style="color: #008000;">&#123;</span>
		<span style="color: #6666cc; font-weight: bold;">string</span> result <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span>
		<span style="color: #6666cc; font-weight: bold;">string</span> filespec <span style="color: #008000;">=</span> HttpContext<span style="color: #008000;">.</span><span style="color: #0000FF;">Current</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Request</span><span style="color: #008000;">.</span><span style="color: #0000FF;">PhysicalApplicationPath</span> <span style="color: #008000;">+</span>
						 path<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;/&quot;</span>, <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\\</span>&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		filespec <span style="color: #008000;">=</span> Path<span style="color: #008000;">.</span><span style="color: #0000FF;">GetFullPath</span><span style="color: #008000;">&#40;</span>filespec<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">//if the file is already loaded, then exit</span>
		<span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>files<span style="color: #008000;">.</span><span style="color: #0000FF;">Contains</span><span style="color: #008000;">&#40;</span>filespec<span style="color: #008000;">&#41;</span><span style="color: #008000;">&#41;</span>
			<span style="color: #0600FF; font-weight: bold;">return</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">//add this file to the loaded list</span>
		files<span style="color: #008000;">.</span><span style="color: #0000FF;">Push</span><span style="color: #008000;">&#40;</span>filespec<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">//load the file</span>
		<span style="color: #6666cc; font-weight: bold;">string</span> s <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span>
		<span style="color: #6666cc; font-weight: bold;">bool</span> b <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
		<span style="color: #0600FF; font-weight: bold;">try</span> <span style="color: #008000;">&#123;</span>
			StreamReader sr <span style="color: #008000;">=</span> File<span style="color: #008000;">.</span><span style="color: #0000FF;">OpenText</span><span style="color: #008000;">&#40;</span>filespec<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			<span style="color: #0600FF; font-weight: bold;">do</span> <span style="color: #008000;">&#123;</span>
				b <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">true</span><span style="color: #008000;">;</span>
				s <span style="color: #008000;">=</span> sr<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadLine</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span>
				<span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>s<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;//LIBRARY:&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span>
					b <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
&nbsp;
				<span style="color: #0600FF; font-weight: bold;">if</span><span style="color: #008000;">&#40;</span>s<span style="color: #008000;">.</span><span style="color: #0000FF;">IndexOf</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;//REQUIRES:&quot;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">==</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">&#123;</span>
					b <span style="color: #008000;">=</span> <span style="color: #0600FF; font-weight: bold;">false</span><span style="color: #008000;">;</span>
					s <span style="color: #008000;">=</span> s<span style="color: #008000;">.</span><span style="color: #0000FF;">Replace</span><span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;//REQUIRES:&quot;</span>, <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">.</span><span style="color: #0000FF;">Trim</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
					result <span style="color: #008000;">=</span> result <span style="color: #008000;">+</span> GetFile<span style="color: #008000;">&#40;</span><span style="color: #666666;">&quot;..&quot;</span> <span style="color: #008000;">+</span> s<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
					s <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;&quot;</span><span style="color: #008000;">;</span>
				<span style="color: #008000;">&#125;</span>
				result <span style="color: #008000;">=</span> result <span style="color: #008000;">+</span> s<span style="color: #008000;">;</span>
			<span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">while</span> <span style="color: #008000;">&#40;</span>sr<span style="color: #008000;">.</span><span style="color: #0000FF;">Peek</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">!=</span> <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span> <span style="color: #008000;">&amp;&amp;</span> <span style="color: #008000;">!</span>b<span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
			result <span style="color: #008000;">=</span> result <span style="color: #008000;">+</span> sr<span style="color: #008000;">.</span><span style="color: #0000FF;">ReadToEnd</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span><span style="color: #008000;">;</span>
			sr<span style="color: #008000;">.</span><span style="color: #0000FF;">Close</span><span style="color: #008000;">&#40;</span><span style="color: #008000;">&#41;</span><span style="color: #008000;">;</span>
		<span style="color: #008000;">&#125;</span> <span style="color: #0600FF; font-weight: bold;">catch</span> <span style="color: #008000;">&#123;</span>
			result <span style="color: #008000;">=</span> <span style="color: #666666;">&quot;<span style="color: #008080; font-weight: bold;">\n</span>/* Error loading file: &quot;</span> <span style="color: #008000;">+</span> filespec <span style="color: #008000;">+</span> <span style="color: #666666;">&quot; */<span style="color: #008080; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #008000;">&#125;</span>
		<span style="color: #0600FF; font-weight: bold;">return</span> result<span style="color: #008000;">;</span>
    <span style="color: #008000;">&#125;</span>
<span style="color: #008000;">&#125;</span></pre></td></tr></table></div>

<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='/2009/10/recursive-script-inclusion-with-require/'>/2009/10/recursive-sc...clusion-with-require/</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Recursive script inclusion with REQUIRE</title>
		<link>http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require/</link>
		<comments>http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require/#comments</comments>
		<pubDate>Thu, 01 Oct 2009 19:16:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[VB.net]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=132</guid>
		<description><![CDATA[One thing that tends to seriously limit the "best practices" when it comes to enterprise development and code reuse for Javascript is a lack of INCLUDE or REQUIRE functionality.]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require/" data-text="Recursive script inclusion with REQUIRE" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>One thing that tends to seriously limit the &#8220;best practices&#8221; when it comes to enterprise development and code reuse for Javascript is a lack of INCLUDE or REQUIRE functionality.</p>
<p>Code reuse and portability requires various functionality to be compartmentalized into individual .js files containing only related functionality, but on the web, including several files means making lots of unnecessary roundtrips, which can add up to a huge performance cost in the load time of your pages.</p>
<p>Good compartmentalized code also necessitates some sort of REQUIRE mechanism, which allows one unit of code (ie, script file) to specify when it won&#8217;t run properly without another unit of code.</p>
<p>Thus, while working on a VB.Net project, I created this simple Javascript loader, which looks at the name of the directory in which an app resides, and then looks for a javascript file by that name and loads it.  Directives can be placed in that Javascript file (and in any subsequent file) requiring the inclusion of additional script files.</p>
<p>Not only does this allow for easier inclusion of libraries as needed, but it also makes it easier to strip out unused code if/when it is no longer needed by an app.</p>
<p>This source code is also available in a <a href="/2009/10/recursive-script-inclusion-with-require-c/">C# version</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
</pre></td><td class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Imports</span> System.<span style="color: #0000FF;">IO</span>
&nbsp;
Partial <span style="color: #0600FF;">Class</span> javascript
	<span style="color: #0600FF;">Inherits</span> System.<span style="color: #0000FF;">Web</span>.<span style="color: #0000FF;">UI</span>.<span style="color: #0000FF;">Page</span>
&nbsp;
	<span style="color: #FF8000;">Private</span> <span style="color: #008000;">files</span> <span style="color: #FF8000;">As</span> Stack
&nbsp;
	Protected <span style="color: #0600FF;">Sub</span> Page_Load<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> sender <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Object</span>, <span style="color: #FF8000;">ByVal</span> e <span style="color: #FF8000;">As</span> System.<span style="color: #0000FF;">EventArgs</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Handles</span> <span style="color: #FF8000;">Me</span>.<span style="color: #0000FF;">Load</span>
		<span style="color: #008000;">files</span> <span style="color: #008000;">=</span> <span style="color: #FF8000;">New</span> Stack<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		Response.<span style="color: #0000FF;">ContentType</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;application/x-javascript&quot;</span>
		Response.<span style="color: #0600FF;">Write</span><span style="color: #000000;">&#40;</span>GetFile<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;js/Contacts.js&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Sub</span>
&nbsp;
	<span style="color: #FF8000;">Private</span> <span style="color: #0600FF;">Function</span> GetFile<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> path <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span>
		<span style="color: #0600FF;">Dim</span> result <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
		<span style="color: #0600FF;">Dim</span> filespec <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> HttpContext.<span style="color: #0000FF;">Current</span>.<span style="color: #0000FF;">Request</span>.<span style="color: #0000FF;">PhysicalApplicationPath</span> <span style="color: #008000;">&amp;</span> path.<span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;/&quot;</span>, <span style="color: #808080;">&quot;\&quot;</span><span style="color: #000000;">&#41;</span>
&nbsp;
		filespec <span style="color: #008000;">=</span> IO.<span style="color: #0000FF;">Path</span>.<span style="color: #0000FF;">GetFullPath</span><span style="color: #000000;">&#40;</span>filespec<span style="color: #000000;">&#41;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">'if the file is already loaded, then exit</span>
		<span style="color: #0600FF;">If</span> <span style="color: #008000;">files</span>.<span style="color: #0000FF;">Contains</span><span style="color: #000000;">&#40;</span>filespec<span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">Then</span> <span style="color: #FF8000;">Return</span> <span style="color: #808080;">&quot;&quot;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">'add this file to the loaded list</span>
		<span style="color: #008000;">files</span>.<span style="color: #0000FF;">Push</span><span style="color: #000000;">&#40;</span>filespec<span style="color: #000000;">&#41;</span>
&nbsp;
		<span style="color: #008080; font-style: italic;">'load the file</span>
		<span style="color: #0600FF;">Dim</span> s <span style="color: #FF8000;">As</span> <span style="color: #FF8000;">String</span> <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
		<span style="color: #0600FF;">Dim</span> b <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Boolean</span> <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
		<span style="color: #0600FF;">Try</span>
			<span style="color: #0600FF;">Dim</span> sr <span style="color: #FF8000;">As</span> StreamReader <span style="color: #008000;">=</span> <span style="color: #008000;">File</span>.<span style="color: #0000FF;">OpenText</span><span style="color: #000000;">&#40;</span>filespec<span style="color: #000000;">&#41;</span>
			<span style="color: #0600FF;">Do</span>
				b <span style="color: #008000;">=</span> <span style="color: #0600FF;">True</span>
				s <span style="color: #008000;">=</span> sr.<span style="color: #0000FF;">ReadLine</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> vbCrLf
				<span style="color: #0600FF;">If</span> s.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;//LIBRARY:&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
					b <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
				<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
				<span style="color: #0600FF;">If</span> s.<span style="color: #0000FF;">IndexOf</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;//REQUIRES:&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span> <span style="color: #FF8000;">Then</span>
					b <span style="color: #008000;">=</span> <span style="color: #0600FF;">False</span>
					s <span style="color: #008000;">=</span> s.<span style="color: #0600FF;">Replace</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;//REQUIRES:&quot;</span>, <span style="color: #808080;">&quot;&quot;</span><span style="color: #000000;">&#41;</span>.<span style="color: #0600FF;">Trim</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
					result <span style="color: #008000;">=</span> result <span style="color: #008000;">&amp;</span> GetFile<span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;..&quot;</span> <span style="color: #008000;">&amp;</span> s<span style="color: #000000;">&#41;</span>
					s <span style="color: #008000;">=</span> <span style="color: #808080;">&quot;&quot;</span>
				<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">If</span>
				result <span style="color: #008000;">=</span> result <span style="color: #008000;">&amp;</span> s
			<span style="color: #0600FF;">Loop</span> <span style="color: #0600FF;">While</span> sr.<span style="color: #0000FF;">Peek</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> &lt;&gt; <span style="color: #008000;">-</span><span style="color: #FF0000;">1</span> <span style="color: #804040;">And</span> <span style="color: #804040;">Not</span> b
			result <span style="color: #008000;">=</span> result <span style="color: #008000;">&amp;</span> sr.<span style="color: #0000FF;">ReadToEnd</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #008000;">&amp;</span> vbCrLf
			sr.<span style="color: #0600FF;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>
		<span style="color: #0600FF;">Catch</span> ex <span style="color: #FF8000;">As</span> Exception
			result <span style="color: #008000;">=</span> vbCrLf <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot;/* Error loading file: &quot;</span> <span style="color: #008000;">&amp;</span> filespec <span style="color: #008000;">&amp;</span> <span style="color: #808080;">&quot; */&quot;</span> <span style="color: #008000;">&amp;</span> vbCrLf
		<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Try</span>
&nbsp;
		<span style="color: #FF8000;">Return</span> result
	<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span>
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Class</span></pre></td></tr></table></div>

<p>This could be easily updated to work for CSS files as well.</p>
<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='/2009/10/recursive-script-inclusion-with-require-c/'>/2009/10/recursive-sc...usion-with-require-c/</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2009/10/recursive-script-inclusion-with-require/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript XML extensions</title>
		<link>http://www.bbqiguana.com/2009/09/javascript-xml-extensions/</link>
		<comments>http://www.bbqiguana.com/2009/09/javascript-xml-extensions/#comments</comments>
		<pubDate>Fri, 25 Sep 2009 19:13:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Web]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.bbqiguana.com/?p=126</guid>
		<description><![CDATA[While several features of Microsoft's DOMDocument object are not supported by standards, it's hard to deny that many of them are quite useful, and probably should be standardized.  When writing AJAX web apps, you need easy access to XML nodes.  And more than anything, you need it to be cross-browser capable.  To that end, I often include the following script in my AJAX apps.]]></description>
			<content:encoded><![CDATA[<div style="float:right;margin:5px;" class="tweet_button"><a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.bbqiguana.com/2009/09/javascript-xml-extensions/" data-text="Javascript XML extensions" data-count="vertical" data-via="bbqiguana"">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div><p>While several features of Microsoft&#8217;s DOMDocument object are not supported by standards, it&#8217;s hard to deny that many of them are quite useful, and probably <em>should</em> be standardized.</p>
<p>When writing AJAX web apps, you need easy access to XML nodes.  And more than anything, you need it to be cross-browser capable.  To that end, I often include the <a href="/js/xml.js">following script</a> in my AJAX apps.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * XML functions
 */</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* Functions for IE */</span>
	domLoadXml<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> doc<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'MSXML2.DOMDocument'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		doc.<span style="color: #660066;">async</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
		doc.<span style="color: #660066;">loadXML</span><span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> doc<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
	<span style="color: #009966; font-style: italic;">/* Functions for non-IE browsers */</span>
	domLoadXml<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xml<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> parser<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> DOMParser<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">return</span> parser.<span style="color: #660066;">parseFromString</span><span style="color: #009900;">&#40;</span>xml<span style="color: #339933;">,</span><span style="color: #3366CC;">'text/xml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #006600; font-style: italic;">//fill in the missing convenience methods for Firefox</span>
	Element.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">selectSingleNode</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xpath<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> xpe<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> XPathEvaluator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> n<span style="color: #339933;">=</span>xpe.<span style="color: #660066;">evaluate</span><span style="color: #009900;">&#40;</span>xpath<span style="color: #339933;">,</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>XPathResult.<span style="color: #660066;">FIRST_ORDERED_NODE_TYPE</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> n.<span style="color: #660066;">singleNodeValue</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	Element.<span style="color: #660066;">prototype</span>.<span style="color: #660066;">selectNodes</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>xpath<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> xpe<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> XPathEvaluator<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> xpr<span style="color: #339933;">=</span>xpe.<span style="color: #660066;">evaluate</span><span style="color: #009900;">&#40;</span>xpath<span style="color: #339933;">,</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">,</span>XPathResult.<span style="color: #660066;">ORDERED_NODE_ITERATOR_TYPE</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> nodes<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>xpr<span style="color: #339933;">!=</span><span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> el<span style="color: #339933;">=</span>xpr.<span style="color: #660066;">iterateNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				nodes.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				el<span style="color: #339933;">=</span>xpr.<span style="color: #660066;">iterateNext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000066; font-weight: bold;">return</span> nodes<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span> HTMLElement.<span style="color: #660066;">prototype</span>.__defineGetter__ <span style="color: #339933;">!=</span> <span style="color: #3366CC;">'undefined'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		Element.<span style="color: #660066;">prototype</span>.__defineGetter__<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'xml'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> XMLSerializer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">serializeToString</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Element.<span style="color: #660066;">prototype</span>.__defineGetter__<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">textContent</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Element.<span style="color: #660066;">prototype</span>.__defineSetter__<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">textContent</span><span style="color: #339933;">=</span>s<span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//Element.prototype.__defineSetter__('xml', function(s) {} );</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<div class="link-summarizer"><p><strong>Links in this post</strong><ul><li><a href='/js/xml.js'>/js/xml.js</a></li></ul></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.bbqiguana.com/2009/09/javascript-xml-extensions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

