<?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>Jon Fox &#187; Javascript</title>
	<atom:link href="http://jonefox.com/blog/category/code/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://jonefox.com/blog</link>
	<description>My rants, ramblings, and random thoughts</description>
	<lastBuildDate>Mon, 24 May 2010 16:12:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/><cloud domain='jonefox.com' port='80' path='/blog/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Gravatar in Gmail (Update)</title>
		<link>http://jonefox.com/blog/2010/01/25/gravatar-in-gmail-update/</link>
		<comments>http://jonefox.com/blog/2010/01/25/gravatar-in-gmail-update/#comments</comments>
		<pubDate>Tue, 26 Jan 2010 03:03:21 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[gravatar]]></category>
		<category><![CDATA[greasemonkey]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=277</guid>
		<description><![CDATA[A while back I wrote a Greasemonkey script to add Gravatars to Gmail. Unfortunately it broke after an update from Gmail and had a few issues I didn&#8217;t like. I recently had a chance to go back through the script though and update it. It now uses jQuery, works with the current Gmail structure, and [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jonefox.com/blog/2009/03/14/gravatar-in-gmail/">A while back</a> I wrote a <a href="https://addons.mozilla.org/en-US/firefox/addon/748">Greasemonkey</a> script to add <a href="http://en.gravatar.com/">Gravatars</a> to <a href="http://gmail.com/">Gmail</a>.  Unfortunately it broke after an update from Gmail and had a few issues I didn&#8217;t like.</p>
<p>I recently had a chance to go back through the script though and update it.  It now uses <a href="http://jquery.com/">jQuery</a>, works with the current Gmail structure, and loads Gravatars for all open messages (the last one didn&#8217;t).  It&#8217;s not perfect though.  It will not yet load Gravatars if you click to open a collapsed message in a conversation (only the expanded messages upon first opening will have the Gravatar images loaded).  It works pretty well otherwise, though, and it&#8217;s nice to see faces with my emails again.</p>
<p>I&#8217;ve got a screen shot below if you want to see what it looks like.  If you&#8217;d like to get the script for yourself, I&#8217;ve posted it <a href="http://jonefox.com/blog/download_gravatar_in_gmail.user.js">here</a>.  Just install Greasemonkey, click the link, and choose &#8220;install&#8221; when the popup comes up.  Enjoy.</p>
<p><img style='display:none' src="http://jonefox.com/blog/wp-content/uploads/2009/03/grav_gmail_screen.jpg" alt="Screenshot of Gravatar in Gmail" /></p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2010/01/25/gravatar-in-gmail-update/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Internet Explorer and the innerHTML Property</title>
		<link>http://jonefox.com/blog/2009/05/21/internet-explorer-and-the-innerhtml-property/</link>
		<comments>http://jonefox.com/blog/2009/05/21/internet-explorer-and-the-innerhtml-property/#comments</comments>
		<pubDate>Thu, 21 May 2009 06:19:47 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[browser crash]]></category>
		<category><![CDATA[innerHTML]]></category>
		<category><![CDATA[Internet Explorer]]></category>
		<category><![CDATA[tables]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=181</guid>
		<description><![CDATA[Recently while helping a friend deal with the joys of cross-browser JavaScript when working with widgets, I was reminded of a painful quirk in how Intenert Explorer handles the innerHTML property of DOM elements in some cases.Â  In particular, DOM elements that are part of a table, or are a child to a table (no [...]]]></description>
			<content:encoded><![CDATA[<p>Recently while helping a friend deal with the joys of cross-browser JavaScript when working with widgets, I was reminded of a painful quirk in how Intenert Explorer handles the innerHTML property of DOM elements in some cases.Â  In particular, DOM elements that are part of a table, or are a child to a table (no matter how many levels deep), can&#8217;t have the innerHTML property set at run time.Â  Doing so produces a completely unhelpful error message and crashes the rendering engine.Â  This is not only true for tables, but unfortunately happens with several other HTML elements in regard to Internet Explorer.</p>
<p>So, how does one get around this unfortunate problem?Â  Well, the best method I&#8217;ve found is to set the innerHTML property when the element is not yet attached to the DOM or is attached in a &#8220;safe&#8221; place (usually at the BODY tag).Â  To make this process simpler, I generalized this into a function that creates a new DOM node of the same type, preserves any attributes I care about, sets the innerHTML property, and replaces the original node in the DOM with this new node having the desired innerHTML.Â  Here&#8217;s the function for reference:</p>
<pre>
function replace_html(el, html) {
	if( el ) {
                var oldEl = (typeof el === "string" ? document.getElementById(el) : el);
                var newEl = document.createElement(oldEl.nodeName);

                // Preserve any properties we care about (id and class in this example)
                newEl.id = oldEl.id;
                newEl.className = oldEl.className;

                //set the new HTML and insert back into the DOM
                newEl.innerHTML = html;
                if(oldEl.parentNode)
        	        oldEl.parentNode.replaceChild(newEl, oldEl);
                else
		        oldEl.innerHTML = html;

                //return a reference to the new element in case we need it
                return newEl;
	}
};
</pre>
<p>Hopefully this function will help someone out there work around this problem a little faster than I originally did.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2009/05/21/internet-explorer-and-the-innerhtml-property/feed/</wfw:commentRss>
		<slash:comments>42</slash:comments>
		</item>
		<item>
		<title>Gravatar in Gmail</title>
		<link>http://jonefox.com/blog/2009/03/14/gravatar-in-gmail/</link>
		<comments>http://jonefox.com/blog/2009/03/14/gravatar-in-gmail/#comments</comments>
		<pubDate>Sat, 14 Mar 2009 17:22:55 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[gravatar]]></category>
		<category><![CDATA[greasemonkey]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=180</guid>
		<description><![CDATA[UPDATE: I&#8217;ve posted a new version of this script here. The version on this page no longer works. Earlier today I hacked together another GreaseMonkey script. This one adds a Gravatar of the person the email was from to Gmail when reading an individual message. It&#8217;s inspired by the Thunderbird integration I read about here [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> I&#8217;ve posted a new version of this script <a href="http://jonefox.com/blog/2010/01/25/gravatar-in-gmail-update/">here</a>.  The version on this page no longer works.</p>
<p>Earlier today I hacked together another <a href="https://addons.mozilla.org/en-US/firefox/addon/748">GreaseMonkey</a> script.  This one adds a <a href="http://en.gravatar.com/">Gravatar</a> of the person the email was from to <a href="http://gmail.com">Gmail</a> when reading an individual message.  It&#8217;s inspired by the <a href="http://www.mozillamessaging.com/en-US/thunderbird/">Thunderbird</a> integration I read about <a href="http://blog.gravatar.com/2008/01/02/email-gets-personal-with-gravatar-and-messagefaces/">here</a> a while back.  Here&#8217;s a screenshot of it for a better understanding of what it does:<br />
<img src="http://jonefox.com/blog/wp-content/uploads/2009/03/grav_gmail_screen.jpg" alt="Gravatar in Gmail" /></p>
<p>It&#8217;s really just a prototype honestly, but it was far enough along to make me happy for now.  A couple of limitations I&#8217;d like to correct some day (if I ever get around to it) would be to modify it to work with multiple open messages and to only display the image if the email address <em>actually</em> has a gravatar (currently it just displays the default gravatar image in this case).  It would also be nice to clean up how the image is added to the email &#8211; currently it&#8217;s a long dom navigation.  I&#8217;ve posted the script <a href="http://jonefox.com/grav_gmail.user.js">here</a> if anyone is interested in giving it a try (or updating it).  Also, if you didn&#8217;t already know about it (because I didn&#8217;t) the Gmail team has built a nice little <a href="http://code.google.com/p/gmail-greasemonkey/wiki/GmailGreasemonkey10API">API</a> for people developing GreaseMonkey scripts.</p>
<p>As always, feedback welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2009/03/14/gravatar-in-gmail/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Twitter Throttle</title>
		<link>http://jonefox.com/blog/2009/03/07/twitter-throttle/</link>
		<comments>http://jonefox.com/blog/2009/03/07/twitter-throttle/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 05:47:15 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[greasemonkey]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[twitter throttle]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=171</guid>
		<description><![CDATA[One of my biggest pet peeves on Twitter is when people I follow slam Twitter with a bunch of tweets in a short time. Maybe I&#8217;m the only one, but it&#8217;s definitely the #1 reason I stop following people. I don&#8217;t want a single user completely taking over my Twitter page&#8230; With this in mind, [...]]]></description>
			<content:encoded><![CDATA[<p>One of my biggest pet peeves on <a href="http://twitter.com">Twitter</a> is when people I follow slam Twitter with a bunch of tweets in a short time.  Maybe I&#8217;m the only one, but it&#8217;s definitely the #1 reason I stop following people.  I don&#8217;t want a single user completely taking over my Twitter page&#8230;</p>
<p>With this in mind, I decided to write a <a href="https://addons.mozilla.org/en-US/firefox/addon/748">GreaseMonkey</a> script today to address the problem.  I call it Twitter Throttle, and what it does is hides (and groups if they&#8217;re in a row) tweets when a user has more than one tweet on my screen at the same time.  It will then also add however many older tweets are needed to have the correct total viewable on the page.  So, for example, if there are 5 tweets that are hidden (because the user that made the tweet has already made a tweet that is currently being displayed) then it will pull in the 5 previous tweets that are by users not yet represented on your page.  This effectively ensures that if there are 20 items on the page there will be at least 20 different users on the page as well.  Here&#8217;s a screenshot of what it looks like in use:</p>
<p><img src="http://jonefox.com/blog/wp-content/uploads/2009/03/twitter-throttle-screen1.jpg" alt="twitter-throttle-screen1" title="twitter-throttle-screen1" width="612" height="407" class="aligncenter size-full wp-image-174" /></p>
<p>Clicking on the links will display the tweets in case you still want to read them.  I&#8217;ve posted the script <a href="http://jonefox.com/twitter-throttle.user.js">here</a> if anyone is interested.  Be sure to set your twitter username and password in the script (used in the API call to add in older tweets to fill in for the hidden ones).  Let me know if you have any feedback.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2009/03/07/twitter-throttle/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Ubiquity: Compete Stats</title>
		<link>http://jonefox.com/blog/2009/01/26/ubiquity-compete-stats/</link>
		<comments>http://jonefox.com/blog/2009/01/26/ubiquity-compete-stats/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 21:55:56 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[compete.com]]></category>
		<category><![CDATA[Ubiquity]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=165</guid>
		<description><![CDATA[I wrote yet another command for Ubiquity. This one allows you to do a search on Compete for the site you&#8217;re currently on. Simply subscribe to the command here to add it to your command list. Once youâ€™ve got the command installed you can check a sites stats by opening Ubiquity (CTRL+SPACE) and typing &#8220;compete&#8221;. [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote yet another command for <a href="https://wiki.mozilla.org/Labs/Ubiquity/">Ubiquity</a>.  This one allows you to do a search on <a href="http://compete.com">Compete</a> for the site you&#8217;re currently on. Simply subscribe to the command <a href="http://jonefox.com/ubiquity-compete.php">here</a> to add it to your command list.</p>
<p>Once youâ€™ve got the command installed you can check a sites stats by opening Ubiquity (CTRL+SPACE) and typing &#8220;compete&#8221;. You can also add &#8220;mv&#8221; for monthly page views or &#8220;uv&#8221; for unique visitors.  If neither is specified it will default to Compete&#8217;s default (uniques). Hopefully someone else will find it useful.</p>
<p>Feedback welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2009/01/26/ubiquity-compete-stats/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		</item>
		<item>
		<title>Ubiquity: Twitter Search</title>
		<link>http://jonefox.com/blog/2009/01/18/ubiquity-twitter-search/</link>
		<comments>http://jonefox.com/blog/2009/01/18/ubiquity-twitter-search/#comments</comments>
		<pubDate>Sun, 18 Jan 2009 22:48:15 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[search]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[Ubiquity]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=161</guid>
		<description><![CDATA[I recently wrote another command for Ubiquity. This one allows you to do a Twitter search. Simply subscribe to the command here to add it to your command list. Once youâ€™ve got the command installed you can perform a Twitter search by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;twitter-search [search term(s)]&#8220;. Another simple one, but [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wrote another command for <a href="https://wiki.mozilla.org/Labs/Ubiquity/">Ubiquity</a>.  This one allows you to do a Twitter search. Simply subscribe to the command <a href="http://jonefox.com/ubiquity-twitter-search.php">here</a> to add it to your command list.</p>
<p>Once youâ€™ve got the command installed you can perform a Twitter search by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;twitter-search [search term(s)]&#8220;. Another simple one, but it saves me a little time and maybe someone else will find it useful.</p>
<p>Let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2009/01/18/ubiquity-twitter-search/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Ubiquity: PHP function lookup</title>
		<link>http://jonefox.com/blog/2008/09/22/ubiquity-php-function-lookup/</link>
		<comments>http://jonefox.com/blog/2008/09/22/ubiquity-php-function-lookup/#comments</comments>
		<pubDate>Tue, 23 Sep 2008 03:17:15 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Ubiquity]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=72</guid>
		<description><![CDATA[So I guess I&#8217;m getting into this Ubiquity thing a bit. I&#8217;ve created another one to lookup php functions on php.net. Simply subscribe to the command here to add it to your command list. Once you&#8217;ve got the command installed you can lookup PHP functions by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;php [function]&#8220;. This [...]]]></description>
			<content:encoded><![CDATA[<p>So I guess I&#8217;m getting into this Ubiquity thing a bit.  I&#8217;ve created another one to lookup php functions on <a href="http://www.php.net">php.net</a>.  Simply subscribe to the command <a href="http://jonefox.com/ubiquity-php.htm">here</a> to add it to your command list.</p>
<p>Once you&#8217;ve got the command installed you can lookup PHP functions by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;php [function]&#8220;.  This one was pretty simple to do, but very useful already.  I look up syntax for PHP functions several times a day and saving my &#8220;Google step&#8221; is really nice.</p>
<p>Let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/22/ubiquity-php-function-lookup/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ubiquity: Password Generator</title>
		<link>http://jonefox.com/blog/2008/09/11/ubiquity-password-generator/</link>
		<comments>http://jonefox.com/blog/2008/09/11/ubiquity-password-generator/#comments</comments>
		<pubDate>Fri, 12 Sep 2008 05:45:10 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Password Generator]]></category>
		<category><![CDATA[Ubiquity]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=65</guid>
		<description><![CDATA[I recently made a stab at another Ubiquity command. This one is a password generator to generate site-specific passwords. Simply subscribe to the command here to get started. I&#8217;d suggest manually changing the &#8220;mypass&#8221; value to some unique string rather than use the default, but this is not technically required. Once you&#8217;ve got the initial [...]]]></description>
			<content:encoded><![CDATA[<p>I recently made a stab at another <a href="http://labs.mozilla.com/2008/08/introducing-ubiquity/">Ubiquity</a> command.  This one is a password generator to generate site-specific passwords.  Simply subscribe to the command <a href="http://jonefox.com/ubiquity-password.htm">here</a> to get started.  I&#8217;d suggest manually changing the &#8220;mypass&#8221; value to some unique string rather than use the default, but this is not technically required.</p>
<p>Once you&#8217;ve got the initial command setup you can generate a password by simply opening Ubiquity (CTRL+SPACE) and typing &#8220;password&#8221;.  You can specify the site by adding it as a parameter after &#8220;password&#8221; or the command will use the current window&#8217;s location href as the default.  Passwords are an 8 character hash based on the site and the &#8220;mypass&#8221; key set at install.  The password will then be pasted at the current cursor location for your convenience.</p>
<p>Let me know what you think.</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/11/ubiquity-password-generator/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ubiquity</title>
		<link>http://jonefox.com/blog/2008/09/09/ubiquity/</link>
		<comments>http://jonefox.com/blog/2008/09/09/ubiquity/#comments</comments>
		<pubDate>Tue, 09 Sep 2008 19:23:55 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Ubiquity]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://jonefox.com/blog/?p=63</guid>
		<description><![CDATA[For those of you that don&#8217;t already know, Mozilla Labs recently released an early version of Ubiquity. Ubiquity is a command line interface that opens up new options to interface with your browser and integrate your web apps. Check out the video for more info. Overall I think this project is very interesting. For the [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you that don&#8217;t already know, <a href="http://labs.mozilla.com/">Mozilla Labs</a> recently released an early version of <a href="http://labs.mozilla.com/2008/08/introducing-ubiquity/">Ubiquity</a>.  Ubiquity is a command line interface that opens up new options to interface with your browser and integrate your web apps.  Check out the <a href="http://www.vimeo.com/1561578?sec=1561578">video</a> for more info.</p>
<p>Overall I think this project is very interesting.  For the techies/power users out there it provides a much more efficient way to do complex tasks.  This type of UI lends itself well to the repetitive tasks that you face on a daily basis (in particular the email commands in Ubiquity are a great example of this).  The real power of Ubiquity comes from its expandability though.  New commands can be added by adding simple javascript functions to the addon.  These additional commands can then be shared with a special link tag in a document and can even be automatically updated (if the user has given permissions for this).</p>
<p>I&#8217;ve taken a stab at my first Ubiquity command.  You can get it <a href="http://jonefox.com/ubiquity-newsgator.htm">here</a>.  It adds a command to add RSS feeds to <a href="http://newsgator.com">Newsgator</a> (my RSS reader of choice).  Just hit CTRL+SPACE (to open Ubiquity) then execute the command &#8220;add-to-newsgator&#8221; and it&#8217;ll search the current page for an RSS feed and add it to your Newsgator account.</p>
<p>What do you think of Ubiquity?</p>
]]></content:encoded>
			<wfw:commentRss>http://jonefox.com/blog/2008/09/09/ubiquity/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
