<?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>Greylurk &#187; Javascript</title>
	<atom:link href="http://greylurk.com/index.php/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://greylurk.com</link>
	<description>Ramblings of a distracted techie</description>
	<lastBuildDate>Tue, 06 Sep 2011 17:22:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Quick &#8220;Shuffle&#8221; algorithm in JavaScript</title>
		<link>http://greylurk.com/index.php/2011/05/quick-shuffle-algorithm-in-javascript/</link>
		<comments>http://greylurk.com/index.php/2011/05/quick-shuffle-algorithm-in-javascript/#comments</comments>
		<pubDate>Mon, 23 May 2011 17:23:38 +0000</pubDate>
		<dc:creator>Adam N.</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[javascript csod]]></category>

		<guid isPermaLink="false">http://greylurk.com/?p=121</guid>
		<description><![CDATA[I came up with a quick &#8220;shuffling&#8221; algorithm for JavaScript for a project I&#8217;m working on, and I&#8217;m just saving it here for future reference in case I need it again. Feel free to copy it if you need one too. shuffle = function&#40; list &#41; &#123; var result = &#91;&#93;; while&#40; list.length &#38;gt; 0 [...]]]></description>
			<content:encoded><![CDATA[<p>I came up with a quick &#8220;shuffling&#8221; algorithm for JavaScript for a project I&#8217;m working on, and I&#8217;m just saving it here for future reference in case I need it again.   Feel free to copy it if you need one too.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">shuffle <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> list <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> result <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span> list.<span style="color: #660066;">length</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> Math.<span style="color: #660066;">floor</span><span style="color: #009900;">&#40;</span> list.<span style="color: #660066;">length</span> <span style="color: #339933;">*</span> Math.<span style="color: #660066;">random</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    result.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span> list.<span style="color: #660066;">splice</span><span style="color: #009900;">&#40;</span> i<span style="color: #339933;">,</span> <span style="color: #CC0000;">1</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
  <span style="color: #000066; font-weight: bold;">return</span> result<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;counturl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;count=none&amp;text=Quick%20%26%238220%3BShuffle%26%238221%3B%20algorithm%20in%20JavaScript" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;counturl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;count=none&amp;text=Quick%20%26%238220%3BShuffle%26%238221%3B%20algorithm%20in%20JavaScript" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;linkname=Quick%20%26%238220%3BShuffle%26%238221%3B%20algorithm%20in%20JavaScript" title="Delicious" rel="nofollow" target="_blank"><img src="http://greylurk.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;linkname=Quick%20%26%238220%3BShuffle%26%238221%3B%20algorithm%20in%20JavaScript" title="Email" rel="nofollow" target="_blank"><img src="http://greylurk.com/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2011%2F05%2Fquick-shuffle-algorithm-in-javascript%2F&amp;title=Quick%20%26%238220%3BShuffle%26%238221%3B%20algorithm%20in%20JavaScript" id="wpa2a_2"><img src="http://greylurk.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://greylurk.com/index.php/2011/05/quick-shuffle-algorithm-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AJAX with XML, without proper response headers.</title>
		<link>http://greylurk.com/index.php/2006/10/ajax-with-xml-without-proper-response-headers/</link>
		<comments>http://greylurk.com/index.php/2006/10/ajax-with-xml-without-proper-response-headers/#comments</comments>
		<pubDate>Fri, 20 Oct 2006 16:50:04 +0000</pubDate>
		<dc:creator>Adam N.</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[lotus notes]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[XMLHttpRequest]]></category>

		<guid isPermaLink="false">http://www.greylurk.com/wordpress/?p=13</guid>
		<description><![CDATA[One of my clients is dealing with an antiquated Lotus Notes 5.1 database for storing files, and I was asked to build an AJAX interface that would pull a list of files filtered by Category onto an HTML page. The Lotus Notes wizards were able to build an XML &#8220;view&#8221; of the files, which listed [...]]]></description>
			<content:encoded><![CDATA[<p>One of my clients is dealing with an antiquated Lotus Notes 5.1 database for storing files, and I was asked to build an AJAX interface that would pull a list of files filtered by Category onto an HTML page.  The Lotus Notes wizards were able to build an XML &#8220;view&#8221; of the files, which listed all of the files associated with a Document, however they weren&#8217;t able to set the Content-Type of the response to &#8220;text/xml&#8221;.  This means that the standard XMLHttpRequest in both Internet Explorer and Gecko don&#8217;t populate the &#8220;responseXML&#8221; property with the parsed XML document.</p>
<p>I also noted that the <em>way</em> in which the responseXML failed to be populated differed from browser to browser.  In Internet Explorer 6.1, the responseXML.documentElement wasn&#8217;t populated, but in Gecko, the responseXML wasn&#8217;t populated.</p>
<p>So, I wrote a short snippet to handle responses which don&#8217;t have the proper Content-Type header set:</p>
<div style="background-color: #ffc; font: 10pt monospace; white-space: pre; border: 1px solid #ccc; margin: 2px 5px;overflow: auto;">function onXMLHttpLoad( objXMLHttp) {<br />
// First try to use the auto-parsed value<br />
var xml = objXMLHttp.responseXML;<br />
// The browser failed, but we think we&#8217;re smarter<br />
if( !xml || !xml.documentElement ) {<br />
// Internet Explorer, use the Msxml COM object<br />
if( window.ActiveXObject ) {<br />
xml = new ActiveXObject( &#8220;Msxml2.DOMDocument&#8221; );<br />
xml.loadXML( objXMLHttp.responseText );<br />
} else if ( DOMParser ) { // Use the gecko builtin if it&#8217;s available.<br />
xml = new DomParser().parseFromString(objXMLHttp.responseText, &#8220;text/xml&#8221; );<br />
}<br />
}<br />
}</div>
<p><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;counturl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;count=none&amp;text=AJAX%20with%20XML%2C%20without%20proper%20response%20headers." scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;counturl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;count=none&amp;text=AJAX%20with%20XML%2C%20without%20proper%20response%20headers." scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><a class="a2a_button_delicious" href="http://www.addtoany.com/add_to/delicious?linkurl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;linkname=AJAX%20with%20XML%2C%20without%20proper%20response%20headers." title="Delicious" rel="nofollow" target="_blank"><img src="http://greylurk.com/wp-content/plugins/add-to-any/icons/delicious.png" width="16" height="16" alt="Delicious"/></a><a class="a2a_button_email" href="http://www.addtoany.com/add_to/email?linkurl=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;linkname=AJAX%20with%20XML%2C%20without%20proper%20response%20headers." title="Email" rel="nofollow" target="_blank"><img src="http://greylurk.com/wp-content/plugins/add-to-any/icons/email.png" width="16" height="16" alt="Email"/></a><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fgreylurk.com%2Findex.php%2F2006%2F10%2Fajax-with-xml-without-proper-response-headers%2F&amp;title=AJAX%20with%20XML%2C%20without%20proper%20response%20headers." id="wpa2a_4"><img src="http://greylurk.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://greylurk.com/index.php/2006/10/ajax-with-xml-without-proper-response-headers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

