<?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>disjoint thoughts &#187; javascript</title>
	<atom:link href="http://disjointthoughts.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://disjointthoughts.com</link>
	<description></description>
	<lastBuildDate>Thu, 29 Dec 2011 04:23:36 +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>adding blackbird javascript logging to your rails project</title>
		<link>http://disjointthoughts.com/2008/10/21/adding-blackbird-javascript-logging-to-your-rails-project/</link>
		<comments>http://disjointthoughts.com/2008/10/21/adding-blackbird-javascript-logging-to-your-rails-project/#comments</comments>
		<pubDate>Tue, 21 Oct 2008 23:44:19 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://disjointthoughts.com/?p=295</guid>
		<description><![CDATA[Blackbird is a nifty JavaScript logger that can be added to any web app. Ever find yourself adding alerts into your JavaScript to get some [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.gscottolson.com/blackbirdjs/" target="_new">Blackbird</a> is a nifty JavaScript logger that can be added to any web app. Ever find yourself adding alerts into your JavaScript to get some (foggy) idea of what&#8217;s going on? Blackbird makes this kind of debugging much easier.</p>
<p>So how do you get Blackbird working in your Rails app? By following these easy steps:</p>
<p>1. Download the <a href="http://blackbirdjs.googlecode.com/files/blackbirdjs-1.0.zip">Blackbird zip file</a>.<br />
2. Extract contents of zip file.<br />
3. Copy blackbird.css into public/stylesheets<br />
4. Copy blackbird.js into public/javascripts<br />
5. Copy blackbird_panel.png and blackbird_icon.png to public/images<br />
6. Edit blackbird.css, modify urls to blackbird_panel.png and blackbird_icon.png to contain &#8220;/images/&#8221; in their path; &#8220;url(blackbird_panel.png)&#8221; should become &#8220;url(/images/blackbird_panel.png)&#8221;<br />
7. Include the blackbird Javascript and CSS files in your layout: <%= stylesheet_link_tag 'blackbird' %> and <%= javascript_include_tag 'blackbird' %><br />
8. Add a button to open the Blackbird console: &lt;input type=&#8221;button&#8221; onclick=&#8221;javascript:log.toggle();&#8221; value=&#8221;show log&#8221;/&gt;<br />
9. ???<br />
10. Profit!<br />
11. Check out the <a href="http://www.gscottolson.com/blackbirdjs/" target="_new">Blackbird website</a> to learn more about using Blackbird.</p>
]]></content:encoded>
			<wfw:commentRss>http://disjointthoughts.com/2008/10/21/adding-blackbird-javascript-logging-to-your-rails-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>email munging using javascript for wordpress</title>
		<link>http://disjointthoughts.com/2007/11/08/email-munging-using-javascript-for-wordpress/</link>
		<comments>http://disjointthoughts.com/2007/11/08/email-munging-using-javascript-for-wordpress/#comments</comments>
		<pubDate>Fri, 09 Nov 2007 00:13:01 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[blogging]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://disjointthoughts.com/2007/11/08/email-munging-using-javascript-for-wordpress/</guid>
		<description><![CDATA[Anyone who wants to post their email address on the Internet should be wary of spiders picking up their address and filling their inbox with [...]]]></description>
			<content:encoded><![CDATA[<p>Anyone who wants to post their email address on the Internet should be wary of spiders picking up their address and filling their inbox with spam. Here&#8217;s a little trick that hopefully keeps your email address hidden from spiders, but allows normal users view it easily. </p>
<p>This will actually work anywhere you can get JavaScript to run. In the case of WordPress, there&#8217;s issues getting JavaScript to run directly in a post. So what I did was created a <a href="http://disjointthoughts.com/contact/">contact page</a>. Within the contact page I put:</p>
<pre style="width:500px;height:220px;border:solid 1px #ccc;overflow:scroll;">
If you'd like to contact me about anything at all, feel free to email
me at &lt;span id="foo">test&lt;/span> or send me an IM on google talk.

&lt;script language="javascript">
    //&lt;code>

    a = ["mai", "lto", "benjamin", "lee", "smith", "gm", "ail", "com"];//
    b = a[0]+a[1]+":"+a[2]+"."+a[3]+"."+a[4]+"@"+a[5]+a[6]+"."+a[7];//
    c = a[2]+"."+a[3]+"."+a[4]+"@"+a[5]+a[6]+"."+a[7];//
    document.getElementById("foo").innerHTML = "&lt;a href=\""+b+"\">"+c+"</a>";//
    //&lt;/code>
&lt;/script>
</pre>
<p>When the page loads, the contents of the span will be replaced with my email address. My email address is pieced together from the contents of an array, which I think obfuscates my email enough such that spiders (unless they&#8217;ve started executing JavaScript) won&#8217;t be able to understand.</p>
<p>There are also a couple of other hacks going on here to get it to work in WordPress. The code tags only exist to keep wordpress from touching the JavaScript syntax and escaping things like the greater than and less than characters. The code tags themselves are commented out, so that the JavaScript won&#8217;t worry about them being inside of the script tags. And at the end of every line of JavaScript there is an empty line comment, to escape anything that WordPress puts at the end of a line. If you&#8217;re not dealing with WordPress, these things can be omitted.</p>
]]></content:encoded>
			<wfw:commentRss>http://disjointthoughts.com/2007/11/08/email-munging-using-javascript-for-wordpress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>want to use json.js with prototype.js?</title>
		<link>http://disjointthoughts.com/2007/08/21/want-to-use-jsonjs-with-prototypejs/</link>
		<comments>http://disjointthoughts.com/2007/08/21/want-to-use-jsonjs-with-prototypejs/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 00:18:17 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://disjointthoughts.com/2007/08/21/want-to-use-jsonjs-with-prototypejs/</guid>
		<description><![CDATA[If you&#8217;ve tried this, you&#8217;ve realized that trying to include both prototype.js and json.js in the same html will cause things to silently fail. The [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve tried this, you&#8217;ve realized that trying to include both <a href="http://www.prototypejs.org/download" target="_new">prototype.js</a> and <a href="http://www.json.org/json.js" target="_new">json.js</a> in the same html will cause things to silently fail. The quick solution to this is to not use json.js and upgrade to prototype 1.5.1 or better. In the latest version of prototype there is a method &#8220;string.evalJSON();&#8221; which I think handles the case that most people use json.js for. </p>
]]></content:encoded>
			<wfw:commentRss>http://disjointthoughts.com/2007/08/21/want-to-use-jsonjs-with-prototypejs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>getting thickbox, jquery, and prototype to play together nicely</title>
		<link>http://disjointthoughts.com/2007/08/17/getting-thickbox-jquery-and-prototype-to-play-together-nicely/</link>
		<comments>http://disjointthoughts.com/2007/08/17/getting-thickbox-jquery-and-prototype-to-play-together-nicely/#comments</comments>
		<pubDate>Fri, 17 Aug 2007 17:39:06 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jumpbox]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://disjointthoughts.com/2007/08/17/getting-thickbox-jquery-and-prototype-to-play-together-nicely/</guid>
		<description><![CDATA[The latest version of the JumpBox admin interface uses ThickBox for its cool visual effects, and prototype for handling AJAX requests. The problem is that [...]]]></description>
			<content:encoded><![CDATA[<p>The latest version of the <a href="http://www.jumpbox.com/" target="_new">JumpBox</a> admin interface uses <a href="http://jquery.com/demo/thickbox/" target="_new">ThickBox</a> for its cool visual effects, and <a href="http://www.prototypejs.org/" target="_new">prototype</a> for handling AJAX requests. The problem is that ThickBox depends on jQuery, and jQuery and prototype don&#8217;t like working together. </p>
<p>Both jQuery and prototype define &#8220;$&#8221; as an alias in the global namespace. When you try to use the &#8220;$&#8221; shortcut and both libraries are included, the browser complains. Lucky <a href="http://docs.jquery.com/Using_jQuery_with_Other_Libraries" target="_new">jQuery gives you a way to override &#8220;$&#8221;</a> and let prototype use it thus resolving the conflict:</p>
<pre style="width:500px;height:200px;border:solid 1px #ccc;overflow:scroll;">
 &lt;html>
 &lt;head>
   &lt;script src="prototype.js">&lt;/script>
   &lt;script src="jquery.js">&lt;/script>
   &lt;script>
     jQuery.noConflict();
   &lt;/script>
 &lt;/head>
 &lt;body></body>
 &lt;/html>
</pre>
<p>After calling jQuery.noConflict(), you can still use jQuery &#8220;$&#8221; functionality, but you have to call it using &#8220;jQuery(&#8216;foo&#8217;)&#8221; instead of &#8220;$(&#8216;foo&#8217;)&#8221;.</p>
<p>Now that jQuery and prototype can coexists peacefully, how does ThickBox work? Well&#8230; out of the box it doesn&#8217;t. ThickBox uses the &#8220;$&#8221; syntax, but expects to use jQuery&#8217;s implementation of it. So to get ThickBox to work, you need to replace all instances of &#8220;$&#8221; with &#8220;jQuery&#8221; in thickbox.js. Now ThickBox should be using jQuery exclusively, jQuery and prototype won&#8217;t conflict over &#8220;$&#8221;, and everything should work fine and dandy. Note: I&#8217;ve only tried this using ThickBox 2.1.1, jQuery 1.1.1, and prototype 1.5.0, but it should work on the latest and greatest versions.</p>
]]></content:encoded>
			<wfw:commentRss>http://disjointthoughts.com/2007/08/17/getting-thickbox-jquery-and-prototype-to-play-together-nicely/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>awesome javascript lecture videos</title>
		<link>http://disjointthoughts.com/2007/05/07/awesome-javascript-lecture-videos/</link>
		<comments>http://disjointthoughts.com/2007/05/07/awesome-javascript-lecture-videos/#comments</comments>
		<pubDate>Tue, 08 May 2007 05:11:38 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://disjointthoughts.com/?p=157</guid>
		<description><![CDATA[Douglas Crockford has a great set of JavaScript lectures on Yahoo! Video. I&#8217;m working my way through them now&#8230; The JavaScript Programming Language [part 1] [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.crockford.com/">Douglas Crockford</a> has a great set of JavaScript lectures on <a href="http://video.yahoo.com/">Yahoo! Video</a>. I&#8217;m working my way through them now&#8230;</p>
<p><a href="http://video.yahoo.com/video/play?vid=111593&#038;fr=">The JavaScript Programming Language [part 1]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111594&#038;fr=">The JavaScript Programming Language [part 2]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111595&#038;fr=">The JavaScript Programming Language [part 3]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111596&#038;fr=">The JavaScript Programming Language [part 4]</a></p>
<p><a href="http://video.yahoo.com/video/play?vid=111582&#038;fr=">An Inconvenient API: The Theory of the DOM [part 1]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111583&#038;fr=">An Inconvenient API: The Theory of the DOM [part 2]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111584&#038;fr=">An Inconvenient API: The Theory of the DOM [part 3]</a></p>
<p><a href="http://video.yahoo.com/video/play?vid=111585&#038;fr=">Advanced JavaScript [part 1]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111586&#038;fr=">Advanced JavaScript [part 2]</a><br />
<a href="http://video.yahoo.com/video/play?vid=111587&#038;fr=">Advanced JavaScript [part 3]</a></p>
]]></content:encoded>
			<wfw:commentRss>http://disjointthoughts.com/2007/05/07/awesome-javascript-lecture-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>thickbox, https, ie6 and os x firefox compatibility issues</title>
		<link>http://disjointthoughts.com/2007/04/25/thickbox-https-ie6-and-os-x-firefox-compatibility-issues/</link>
		<comments>http://disjointthoughts.com/2007/04/25/thickbox-https-ie6-and-os-x-firefox-compatibility-issues/#comments</comments>
		<pubDate>Wed, 25 Apr 2007 21:39:49 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://disjointthoughts.com/?p=154</guid>
		<description><![CDATA[This might be the most obscure problem ever, but it caused me such a headache that I thought I would blog about it on the [...]]]></description>
			<content:encoded><![CDATA[<p>This might be the most obscure problem ever, but it caused me such a headache that I thought I would blog about it on the off chance that one person might have this same issue.</p>
<p>First off I&#8217;m using <a href="http://jquery.com/demo/thickbox/">ThickBox</a> to handle some of the cool visual effects in the <a href="http://www.jumpbox.com/">JumpBox</a> admin interface. Such as:</p>
<p><a href="http://www.flickr.com/photos/benjaminsmith/472695729/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/214/472695729_4a515eb890_o.png" width="500" alt="jumpbox screenshot 1" /></a></p>
<p>Everything was fine and dandy until we decided to start serving the admin interface over https. This worked for all browsers EXCEPT IE6. In IE6 when ThickBox tries to display you get this security warning:</p>
<p><a href="http://www.flickr.com/photos/benjaminsmith/472739902/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/199/472739902_054d437e22_o.png" width="500" alt="jumpbox screenshot 2" /></a></p>
<p>&#8220;This page contains both secure and nonsecure items. Do you want to display the nonsecure items?&#8221;</p>
<p>After a small amount of searching on the <a href="http://codylindley.com/thickboxforum/">ThickBox forums</a> I found <a href="http://codylindley.com/thickboxforum/comments.php?DiscussionID=180&#038;page=1#Item_0">a post</a> that referenced a <a href="http://gemal.dk/blog/2005/01/27/iframe_without_src_attribute_on_https_in_internet_explorer/">blog post about iframes, https, and IE</a>. The conclusion is that ThickBox creates an iframe without a &#8220;src&#8221; attribute, and in IE6 over HTTPS this throws up the warning as seen above. So the solution is to add a src attribute to the iframe and point it at a blank html file on the server.</p>
<p>The fix is achieved by modifying the ThickBox javascript file. Near the beginning of the TB_show function the following line:</p>
<blockquote><p>
$(&#8220;body&#8221;).append(&#8220;&lt;iframe id=&#8217;TB_HideSelect&#8217;>&lt;/iframe>&lt;div id=&#8217;TB_overlay&#8217;>&lt;/div>&lt;div id=&#8217;TB_window&#8217;>&lt;/div>&#8221;);
</p></blockquote>
<p>&#8230; should be changed to:</p>
<blockquote><p>
$(&#8220;body&#8221;).append(&#8220;&lt;iframe src=&#8221;blank.html&#8221; id=&#8217;TB_HideSelect&#8217;>&lt;/iframe>&lt;div id=&#8217;TB_overlay&#8217;>&lt;/div>&lt;div id=&#8217;TB_window&#8217;>&lt;/div>&#8221;);
</p></blockquote>
<p>As advertised this fixes the warning from IE6. However this breaks&#8230; something&#8230; in Firefox 2 on OS X. I say &#8220;something&#8221; because I really don&#8217;t know what is going on. Everything works fine in Firefox on XP, Safari, IE6 and IE7. Here&#8217;s a screen grab:</p>
<p><a href="http://www.flickr.com/photos/benjaminsmith/472816657/" title="Photo Sharing"><img src="http://farm1.static.flickr.com/214/472816657_abd0976a3e_o.png" width="500" alt="jumpbox screenshot 3" /></a></p>
<p>Apparently this weirdness is caused by the src=&#8217;blank.html&#8217; on the iframe. How this is causing problems is beyond me. The solution is to do a little browser detection to determine if we&#8217;re dealing with IE, in that case add the src attribute to the iframe, and the rest of the time forget about it:</p>
<blockquote><p>
if(navigator.appName == &#8220;Microsoft Internet Explorer&#8221;) {<br />
  $(&#8220;body&#8221;).append(&#8220;&lt;iframe src=&#8217;blank.html&#8217; id=&#8217;TB_HideSelect&#8217;>&lt;/iframe>&lt;div id=&#8217;TB_overlay&#8217;>&lt;/div>&lt;div id=&#8217;TB_window&#8217;>&lt;/div>&#8221;);<br />
} else {<br />
   $(&#8220;body&#8221;).append(&#8220;&lt;iframe id=&#8217;TB_HideSelect&#8217;>&lt;/iframe>&lt;div id=&#8217;TB_overlay&#8217;>&lt;/div>&lt;div id=&#8217;TB_window&#8217;>&lt;/div>&#8221;);<br />
}
</p></blockquote>
<p>To anyone still reading, I hoped this helps. Otherwise sorry you had to listen to me rant about another JavaScript issue that is fueling my hatred of supporting multiple browsers.</p>
<p><strong>UPDATE:</strong> <a href="http://cse-mjmcl.cse.bris.ac.uk/blog/" target="new">Mark</a> was kind enough to <a href="http://disjointthoughts.com/?p=154#comment-427" target="new">point out</a> that instead of using a blank html file as the source of the iframe, you can use &#8220;javascript:false;&#8221; which is compatible with all browsers thus eliminating the need to do browser detection. So instead of that ugly chunk of code seen above, all you need is:</p>
<blockquote><p>
  $(&#8220;body&#8221;).append(&#8220;&lt;iframe src=&#8217;javascript:false;&#8217; id=&#8217;TB_HideSelect&#8217;>&lt;/iframe>&lt;div id=&#8217;TB_overlay&#8217;>&lt;/div>&lt;div id=&#8217;TB_window&#8217;>&lt;/div>&#8221;);
</p></blockquote>
<p>This is a much simpler and cleaner solution. </p>
]]></content:encoded>
			<wfw:commentRss>http://disjointthoughts.com/2007/04/25/thickbox-https-ie6-and-os-x-firefox-compatibility-issues/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>

