<?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>This Life of Brian &#187; Javascript</title>
	<atom:link href="http://life-of-brian.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://life-of-brian.com</link>
	<description>My name is Brian.  Welcome to my life.</description>
	<lastBuildDate>Tue, 03 Jan 2012 03:09:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Using a jQuery Gallery in a Photography Website</title>
		<link>http://life-of-brian.com/2010/04/using-a-jquery-gallery-in-a-photography-website/</link>
		<comments>http://life-of-brian.com/2010/04/using-a-jquery-gallery-in-a-photography-website/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 00:17:32 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Nerds at Work]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Gallery]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Photography]]></category>

		<guid isPermaLink="false">http://life-of-brian.com/?p=1579</guid>
		<description><![CDATA[Recently, I&#8217;ve made a foray into the world of professional photography with one of my students. Olinda wants to pursue photography as a career, so she&#8217;s simultaneously pursuing a bachelor&#8217;s degree in photography and working on setting up a portfolio and client base. To get things started, I took a stab at developing a website [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve made a foray into the world of professional photography with one of my students. Olinda wants to pursue photography as a career, so she&#8217;s simultaneously pursuing a bachelor&#8217;s degree in photography and working on setting up a portfolio and client base.</p>
<p>To get things started, I took a stab at developing a website for her: <a href="http://olinda-gibbons.com">olinda-gibbons.com</a>.</p>
<p>I&#8217;m not 100% happy with the theme, but we kind of had to launch it under short notice so that we could post/sell images from a few events that she worked. I&#8217;ll probably re-vamp the theme over the summer when I have free time, but at the moment there are some really cool things in there that I want to show off.</p>
<h3>Auto Portfolio with a jQuery Gallery</h3>
<p>One feature I definitely wanted to have was a portfolio page with some kind of nifty jQuery functionality. I looked through some options on this list of <a href="http://vandelaydesign.com/blog/web-development/jquery-image-galleries/">jquery gallery plug-ins</a>, and I liked the <a href="http://devkick.com/lab/galleria/">galleria</a> plug-in. Although I think it might now be out of development, I was able to get it working to my satisfaction with a static html demo.</p>
<p>Of course, I wanted to be able to easily and automatically create and change portfolios with WordPress, and the <a href="http://nextgen-gallery.com/">NextGEN Gallery plug-in for WordPress</a> made that possible. I created a custom template file to display a gallery with the mark-up necessary for the Galleria plug-in to work. Now all I have to do is upload the pictures to a gallery, insert a piece of short code, and instant portfolio page. Nice.</p>
<p>There are two samples on the site now: Olinda&#8217;s <a href="http://olinda-gibbons.com/portfolios/portraits-portfolio/">portrait portfolio</a> and her <a href="http://olinda-gibbons.com/portfolios/events-portfolio/">events portfolio</a>.</p>
<h3>Integrating PayPal Web Payment</h3>
<p>The second thing I needed to do was integrate PayPal&#8217;s web payment system so that we could accept payments and then print/ship pictures after events. Portrait sessions can be handled through invoicing and other payment methods, but PayPal makes it really convenient to handle larger groups of people more efficiently.</p>
<p>Again, this was made possible by the NextGen gallery plug-in. I marked up a custom template to include the html mark-up for the PayPal payment buttons. Now, I just upload the proof images to a gallery and with one piece of short-code I have an instant ordering page.</p>
<p>This is a place where I definitely want to work on a better design, but I was working under short notice and just wanted something functional&#8230;</p>
<p>Example: <a href="http://olinda-gibbons.com/proofs/william-paterson-fashion-show-03-25-2010/">William Paterson Fashion Show proof album</a>.</p>
<h3>How Did I Do It?</h3>
<p>I plan to write up some detailed guides to how I designed those pages. I&#8217;m not sure if I&#8217;ll post them here or start up a blog section on <a href="http://olinda-gibbons.com">olinda-gibbons.com</a> and post it there. Either way, I&#8217;ll post about the guides here because I think they&#8217;ll be valuable for anyone looking to develop a site for a photographer. The more I work with it, I&#8217;m really impressed with the combination of WordPress and the NextGen gallery plugin.</p>
]]></content:encoded>
			<wfw:commentRss>http://life-of-brian.com/2010/04/using-a-jquery-gallery-in-a-photography-website/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Use Pre-Cached Javascript Libraries: Google&#8217;s AJAX API</title>
		<link>http://life-of-brian.com/2009/01/how-to-use-pre-cached-javascript-libraries-googles-ajax-api/</link>
		<comments>http://life-of-brian.com/2009/01/how-to-use-pre-cached-javascript-libraries-googles-ajax-api/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 02:15:02 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Nerds at Work]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://life-of-brian.com/?p=1296</guid>
		<description><![CDATA[Recently, I stumbled on Google&#8217;s AJAX API project. There are a number of things I like, but there is one thing that everyone can use: Google&#8217;s hosted Javascript libraries. Last year, Google launched a project to host a handful of popular Javascript libraries. Among the initial offerings is jQuery &#8211; the Javascript library that I [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, I stumbled on Google&#8217;s AJAX API project.</p>
<p>There are a number of things I like, but there is one thing that everyone can use: <a href="http://googleajaxsearchapi.blogspot.com/2008/05/speed-up-access-to-your-favorite.html">Google&#8217;s hosted Javascript libraries</a>.</p>
<p>Last year, Google launched a project to host a handful of popular Javascript libraries. Among the initial offerings is jQuery &#8211; the Javascript library that I use on this site. They also have some other widely used options &#8211; like prototype and MooTools.</p>
<p>Basically, Google hosts the most recent (and some legacy versions) of the library on its server. You can then link the remote copy of the JS library to your site instead of hosting it yourself.</p>
<h3>Why Should I Use Google Hosted Javascript Libraries?</h3>
<p>Because it could be faster.</p>
<p>If two sites use the same Javascript library but host it locally, the user has to reload and recache the library for each site. jQuery.js on life-of-brian.com is different from jQuery.js on css-tricks.com &#8211; even if the file is exactly the same.</p>
<p>By pointing the user&#8217;s browser to the Google server, it will recognize that .js file in the cache and not download it a second time. So if life-of-brian.com and css-tricks.com both used the jQuery library on Google&#8217;s servers, the user would have to cache it once &#8211; and it would be preloaded when he or she visited the second site.</p>
<p>A secondary benefit (of concern only to large sites) is that it doesn&#8217;t put a strain on your bandwidth. This shouldn&#8217;t be a big deal for most people, but some high volume sites may find this comforting.</p>
<h3>How Do I Load Google&#8217;s Hosted Javascript Libraries?</h3>
<p>You could use the fancy load() function of Google&#8217;s AJAX API, or you could simply add a &lt;script&gt; element using the remote address on Google&#8217;s server.</p>
<p>I chose to go the second route with this site. I wanted to load both the jquery library and the jquery ui library (mainly for the tabs in the sidebar), so I included the following two lines in my header:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.3/jquery-ui.min.js&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/javascript&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span></pre></div></div>

<p>You can find a list of all the URLs on the <a href="http://code.google.com/apis/ajaxlibs/documentation/#AjaxLibraries">AJAX API documentation page</a>.</p>
<h3>Why Not Do This?</h3>
<p>I don&#8217;t see a lot of potential for harm, but there could be some drawbacks.</p>
<p><strong>No version control.</strong> Presumably Google is going to keep hosting important legacy versions of each library, but this takes version control somewhat out of your hands. It also means you can&#8217;t use the development releases &#8211; only the stable releases are hosted on Google&#8217;s server.</p>
<p><strong>No hacking the library.</strong> You won&#8217;t be able to introduce custom hacks into the library if its hosted on Google&#8217;s server. I don&#8217;t know how many people do that anyway. I&#8217;ve never jumped into to hack a compressed library file &#8211; I just use it as is and add any custom code to another .js file.</p>
<p><strong>Google could sabotage your site.</strong> Unlikely, but I suppose it&#8217;s possible. If you&#8217;re paranoid, steer clear.</p>
<h3>Check It Out</h3>
<p>I&#8217;ve been using it for a week or so, and I haven&#8217;t noticed any problems. In theory, it&#8217;s a great idea, but it&#8217;ll only work if a large number of sites (especially highly trafficked sites in a variety of niches) opt to use it.</p>
<p>I&#8217;m going to do my part and point my users to Google&#8217;s servers. Why don&#8217;t you?</p>
]]></content:encoded>
			<wfw:commentRss>http://life-of-brian.com/2009/01/how-to-use-pre-cached-javascript-libraries-googles-ajax-api/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Re-working the Conditional Digg This Button</title>
		<link>http://life-of-brian.com/2008/11/re-working-the-conditional-digg-this-button/</link>
		<comments>http://life-of-brian.com/2008/11/re-working-the-conditional-digg-this-button/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 01:23:56 +0000</pubDate>
		<dc:creator>Brian</dc:creator>
				<category><![CDATA[Nerds at Work]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Plugin]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://life-of-brian.com/?p=338</guid>
		<description><![CDATA[A while ago, I took a stab at writing a WordPress Plugin &#8211; the Conditional Digg This Badge. The plugin allows you to insert a Digg This badge in  your posts, but only have it appear if your post has a certain number of Diggs.  The idea is that you don&#8217;t want to promote the [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago, I took a stab at writing a WordPress Plugin &#8211; the <a href="http://www.earn-web-cash.com/scripts-plugins-and-modules/wp-plugin-digg-badge/">Conditional Digg This Badge</a>.</p>
<p>The plugin allows you to insert a Digg This badge in  your posts, but only have it appear if your post has a certain number of Diggs.  The idea is that you don&#8217;t want to promote the fact that your article only has one Digg &#8211; you only want to brag when it has 10, 20, or 100s.</p>
<p>The plugin ran into some problems, and I ran out of time to fix them.  As a result it&#8217;s dead.  However, I&#8217;ve recently had a few ideas on how to revive it and make it much more efficient.</p>
<h3>The Old Plugin Method</h3>
<p>The old plugin worked, but it was plagued with problems.  Most notably, it had a delayed effect and the badge wouldn&#8217;t show up for 10 or 15 seconds.  If it was used on an index page, it would slow down the loading of the page terribly.  It also broke when WordPress moved to version 2.5.</p>
<p>Most of the problems, I think, come from the way I designed the plugin.  I had just begun tinkering with the Digg API to grab information from the Digg database, so I thought this plug-in would be a useful way to fetch information about an article and have it dynamically update the way the article is displayed.</p>
<p>The plug-in relied on a bit of Javascript to insert or remove the Digg Badge.  The JS used AJAX to contact the Digg API via a tiny php script.  If there was a sufficient number of diggs, the Digg Badge would be inserted.  Otherwise, the container div would just remain empty.</p>
<h3>A Better Method &#8211; No More AJAX</h3>
<p>Recently, I had an idea on how the plugin could be improved and re-implemented.  The loading problems seemed to derive from the Digg API &#8211; it sometimes lagging in response time, which prevented the Digg This Badge from appearing in a timely fashion.</p>
<p>A more streamlined method would be to use CSS to toggle the display of Badge on and off and use JS to find out how many Diggs the article has.</p>
<p>The Digg This Badge is contained in an iframe, which contains in its source the number of Diggs the post currently has.  If you look in the source of your page, you&#8217;ll see the src of the iframe.  Load that page and view its source.  You&#8217;ll see a line like&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">strong</span>&gt;</span>1767<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">strong</span>&gt;</span> diggs</pre></div></div>

<p>It should be possible to use Javascript (and possibly jQuery for convenience) to access the iframe&#8217;s source, dig up the number of diggs, and then toggle the <code>display</code> attribute of the iframe on and off.</p>
<p>I tried testing this out last night, but I ran into some browser compatibility issues.  In Firefox, I was able to access the contents of the iframe.  However, both Google Chrome (my browser of choice) and Internet Explorer balked at the code.  It generated an error somewhere inside the jquery file itself, and any time I tried to access the contents of the iframe the script aborted.</p>
<p>The concept seems sound.  I just need to find a way to make the javascript work in Explorer.  Regardless, I&#8217;ll work up some code examples later on how to use jQuery to access an iframe.</p>
<p>The advantage of this method is that there should be no lag time at all.  As soon as the Badge would normally load, it should be a fraction of a second before the Javascript function to evaluate its logic and turn on the display attribute of the iframe.</p>
]]></content:encoded>
			<wfw:commentRss>http://life-of-brian.com/2008/11/re-working-the-conditional-digg-this-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

