<?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>Patrick Jarrett &#187; Programming</title>
	<atom:link href="http://www.trickjarrett.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.trickjarrett.com</link>
	<description>Live Brave; Blaze your Trail; Do it.</description>
	<lastBuildDate>Tue, 31 Aug 2010 22:10:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>PHP to Assign Secret Santa</title>
		<link>http://www.trickjarrett.com/php-to-assign-secret-santa/</link>
		<comments>http://www.trickjarrett.com/php-to-assign-secret-santa/#comments</comments>
		<pubDate>Sat, 12 Dec 2009 17:35:21 +0000</pubDate>
		<dc:creator>Trick</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.trickjarrett.com/?p=909</guid>
		<description><![CDATA[Because I&#8217;m nerdy I decided to write a quick PHP script to handle the assigning of people for my family&#8217;s Secret Santa. It&#8217;s short, simple, and not-error checked or bug proof in the least. &#60;?php echo &#34;Christmas Secret Santa&#60;br&#62;\n&#34;; &#160; //Build the two arrays. I could in theory use a single array and double it [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Because I&#8217;m nerdy I decided to write a quick PHP script to handle the assigning of people for my family&#8217;s Secret Santa. It&#8217;s short, simple, and not-error checked or bug proof in the least.</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">&lt;?php</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">echo</span> <span class="st0">&quot;Christmas Secret Santa&lt;br&gt;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Build the two arrays. I could in theory use a single array and double it but I was lazy and just defined it twice.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$giver</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;Rudolph&#39;</span><span class="sy0">,</span><span class="st0">&#39;Donner&#39;</span><span class="sy0">,</span><span class="st0">&#39;Blitzen&#39;</span><span class="sy0">,</span><span class="st0">&#39;Santa&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="re1">$receiver</span> <span class="sy0">=</span> <span class="kw3">array</span><span class="br0">&#40;</span><span class="st0">&#39;Rudolph&#39;</span><span class="sy0">,</span><span class="st0">&#39;Donner&#39;</span><span class="sy0">,</span><span class="st0">&#39;Blitzen&#39;</span><span class="sy0">,</span><span class="st0">&#39;Santa&#39;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//Randomize the two arrays</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">shuffle</span><span class="br0">&#40;</span><span class="re1">$giver</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw3">shuffle</span><span class="br0">&#40;</span><span class="re1">$receiver</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;</div>
</li>
<li class="li1">
<div class="de1"><span class="co1">//We&#39;re going to iterate through the giver array for the individuals.</span></div>
</li>
<li class="li1">
<div class="de1"><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re1">$giver</span> <span class="kw1">as</span> <span class="re1">$g</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="co1">//Make sure that the giver and the receiver are not the same person</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">while</span> <span class="br0">&#40;</span><span class="re1">$receiver</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span> <span class="sy0">==</span> <span class="re1">$g</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="co1">//Shuffle the array to randomize it.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; <span class="kw3">shuffle</span><span class="br0">&#40;</span><span class="re1">$receiver</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="co1">//Grab the first person off the receiver array</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="re1">$r</span> <span class="sy0">=</span> <span class="re1">$receiver</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="co1">//Echo out the result</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw3">echo</span> <span class="re1">$g</span><span class="sy0">.</span><span class="st0">&quot; &#8211; &quot;</span><span class="sy0">.</span><span class="re1">$r</span><span class="sy0">.</span><span class="st0">&quot;&lt;br&gt;<span class="es0">\n</span>&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="co1">//Remove that first person from the array, so we only have ungifted people remaining.</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="re1">$receiver</span> <span class="sy0">=</span> <span class="kw3">array_slice</span><span class="br0">&#40;</span><span class="re1">$receiver</span><span class="sy0">,</span><span class="nu0">1</span><span class="br0">&#41;</span><span class="sy0">;</span> </div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span><span class="kw2">?&gt;</span></div>
</li>
</ol>
</div>
<p>So nerdy. Maybe later I&#8217;ll do it as a javascript snippet.</p>
<img src="http://www.trickjarrett.com/?ak_action=api_record_view&id=909&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trickjarrett.com/php-to-assign-secret-santa/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Web Design Primer</title>
		<link>http://www.trickjarrett.com/web-design-primer/</link>
		<comments>http://www.trickjarrett.com/web-design-primer/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 01:15:22 +0000</pubDate>
		<dc:creator>Trick</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.trickjarrett.com/?p=730</guid>
		<description><![CDATA[This post originated with a comment I made in a discussion about web design on Hacker News concerning what skills someone should have to be a good web developer. At the time I wrote a quick five minute response listing a few things that I felt were important skills for new web developers to have [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>This post originated with a comment I made in a <a href="http://news.ycombinator.com/item?id=684686">discussion about web design</a> on <a href="http://news.ycombinator.com/">Hacker News</a> concerning what skills someone should have to be a <em>good</em> web developer. At the time I wrote a quick five minute response listing a few things that I felt were important skills for new web developers to have for website design. These are things that I wish I had had a better grasp on when I entered the world of professional web development.</p>
<p>First I need to clarify the difference between <strong>web design</strong> and <strong>web development</strong>. Web <em>design</em> tends to lean towards the user interface and the actual website. Web <em>development</em> refers to the underlying code, and the inner workings of a site. There&#8217;s a good amount of overlap but they often get used as synonyms when they&#8217;re not; I wanted to clarify their meanings to those who may be fuzzy on the differences.<br />
<span id="more-730"></span></p>
<div class="post-image"><a title="Sidewalk Chalk Macro -- IMG_7662" href="http://www.flickr.com/photos/10506540@N07/3673826642/" target="_blank"><img src="http://farm4.static.flickr.com/3550/3673826642_4535afe927_m.jpg" border="0" alt="Sidewalk Chalk Macro -- IMG_7662" /></a><br />
<small><a title="Attribution License" href="http://creativecommons.org/licenses/by/2.0/" target="_blank"><img src="http://www.trickjarrett.com/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a title="stevendepolo" href="http://www.flickr.com/photos/10506540@N07/3673826642/" target="_blank">stevendepolo</a></small></div>
<p>Of the two I&#8217;m a web developer, my design skills resemble that of a four year old with crayons. Well maybe a little better, but I definitely trend towards the underlying code when it comes to what I work on.</p>
<p>For web development you need to start at the front-end. You don&#8217;t need to be a whiz in Photoshop, the fact is that most web developers form a sort of symbiotic relationship with designers they know. So when a project comes in they are able to outsource the design to the designer and then take it to build the site. The inverse holds true also; designers usually will call upon developers to write the backend code for them. In doing so everybody wins!</p>
<p>However, you can&#8217;t do this job without a good understanding of the the front-end. While designers may do the graphics, and even the html creation, it will eventually fall on you to make the site look right in the browser. And to do so, you need to understand HTML, CSS and Javascript.</p>
<ul>
<li><strong>HTML</strong> &#8211; This entails knowledge of the main tags. HTML is, in truth, a very simple language and anyone can learn it at its basic levels. To be a developer though you need to understand more than that. You&#8217;re the engineer to the designer&#8217;s architect. If they want something, you <strong>must</strong> know how to make it happen. Clients and designers both hate hearing the word &#8216;no.&#8217; There are, in truth, very few limitations to what websites can do these days. It&#8217;s up to the developers to know how to make something happen.</li>
<li><strong>CSS</strong> -This is knowing how to style pages, this is really a core skill these days. You&#8217;ll get the designs from the designer and sometimes they may have done all of this for you, sometimes you just get the graphic of how it should look and it&#8217;s up to you to cut the image and reassemble it on the page. Before the days of CSS, people used Tables to accomplish a lot of the stuff CSS is used for today, but CSS is so much more powerful (and in turn, more confusing) that it is a core skill for web developers.</li>
<li><strong>Javascript</strong> &#8211; Javascript is also a mandatory skill, though these days the Javascript libraries really overshadow Javascript itself. These days I write almost no javascript and only <a href="http://www.jquery.com">jQuery</a>. Now <a href="http://www.jquery.com">jQuery</a> may not be for you, you may be more of a <a href="http://www.prototypejs.org/">Prototype</a> or <a href="http://mootools.net/">moo</a> or <a href="http://developer.yahoo.com/yui/">YUI</a> person and that&#8217;s fine. The library only matters to those who work with it. If you&#8217;re working for a web development firm they most likely have a standard library they want you to use so that other developers are able to work on the project as well.</li>
</ul>
<div class="post-image-left"><a title="DSCN0077" href="http://www.flickr.com/photos/11513255@N00/3591836787/" target="_blank"><img src="http://farm4.static.flickr.com/3563/3591836787_198ddacb22_m.jpg" border="0" alt="DSCN0077" /></a><br />
<small><a title="Attribution-NonCommercial-ShareAlike License" href="http://creativecommons.org/licenses/by-nc-sa/2.0/" target="_blank"><img src="http://www.trickjarrett.com/wp-content/plugins/photo-dropper/images/cc.png" border="0" alt="Creative Commons License" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a title="library_chic" href="http://www.flickr.com/photos/11513255@N00/3591836787/" target="_blank">library_chic</a></small></div>
<p>These front-end skills are akin to learning some of the basics of home improvement. Knowing how to spackle, paint walls, properly hang paintings and mirrors, do tiling in the bathroom. They are all &#8220;superficial&#8221; as they take place on the surface of the house.</p>
<p>Then shifting to the server-side (backend), you&#8217;ll be best served by picking a language and focusing on it: PHP is probably the easiest in terms of entry. Lots of documentation (albeit spotty) and lots of people asking questions you&#8217;re likely to ask. PHP gets a bad rap because programmers so often turn to Google for answers, but the fact is that if you don&#8217;t know how to do something you can probably find it elsewhere online. But I urge you not to just copy, edit and paste. Be sure you read the code and understand it. Once you understand it you can then learn from it.</p>
<p>The reason I recommend PHP is that it doesn&#8217;t cost anything to work with. ASP.net is a bit more difficult to get working for free. Also Ruby on Rails is up and coming as a solid backend coding language, quite hot among web 2.0 companies but it isn&#8217;t near as popular as PHP and ASP.net. The fact of the matter is any programming language can be used as a server side backend, people write in Lisp, Perl, Scheme, C, C++, Ada, probably Fortran. It&#8217;s just finding the system that allows you to do it in a way which makes sense to you.</p>
<p>In most any language you&#8217;ll find frameworks which provide a good basis for web applications. <a href="http://codeigniter.com/">CodeIgniter</a>, <a href="http://www.cakephp.org">CakePHP</a> and a whole host of others currently exist for the PHP language and are used in corporate level projects. Again there is no &#8220;right&#8221; choice, you&#8217;re just going to have to begin playing around and dive into them to decide which ones to pursue.</p>
<div class="post-image"><a href="http://www.flickr.com/photos/31157339@N00/3200730532/" title="erect" target="_blank"><img src="http://farm4.static.flickr.com/3088/3200730532_a025ea78dc_m.jpg" alt="erect" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-sa/2.0/" title="Attribution-ShareAlike License" target="_blank"><img src="http://www.trickjarrett.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/31157339@N00/3200730532/" title="Looking Glass" target="_blank">Looking Glass</a></small></div>
<p>The strength in a framework is that it can smooth the rough edges in a language as well as present you with added functionality. While the language is like working on building the house from the ground up, from laying the ground supports and a sturdy base, up to building the roof and walls, frameworks are like buying a pre-built house exterior. You have an exterior which takes care of a lot of things, keeping the rain off your head, holding out intruders, it&#8217;s not a home really. You&#8217;ve got a lot of work to put in walls, doors, hallways, and other conveniences. It just gets you closer.</p>
<p>At a lower level, when writing the sites, you need to understand <a href="http://en.wikipedia.org/wiki/Object-oriented_programming">Object Oriented Programming</a> as well as other core Computer Science elements. Web developers are still computer programmers and so the programmers who came before us have explored and analyzed a very good amount of knowledge which is pertinent to us. When I was in college I mistakenly thought that I could do web development and not need to know OOP and algorithms but I&#8217;ve since learned just how wrong I was.</p>
<p>For websites, Content Management Systems are a main component in projects these days. <a href="http://www.wordpress.org">WordPress</a>, <a href="http://www.drupal.org">Drupal</a>, <a href="http://www.movabletype.com">MovableType</a> and <a href="http://www.expressionengine.com">ExpressionEngine</a> are just a few of the <a href="http://en.wikipedia.org/wiki/List_of_content_management_systems">many CMSs</a> out there. Again these are things where depending on what project you do, and who you do it with, and what your preferences end up being. There is no single solitary CMS though there are definitely some that have a deal more respect than others. The power of a CMS is that it handles a great deal of the backend of a website. Managing users, all the different content, the different types of content, and the many ways to present the content, these are all tasks which would take you a while to get a grasp on, even in the most simple of contexts. So for a CMS to handle this in a tested and solid way can allow you, the developer, to dive into the &#8220;fun&#8221; stuff in building the site.</p>
<p>CMSs and Frameworks have a lot of overlap, the real difference is the amount of completeness. If a framework is an empty shell of a house, a CMS is a pre-fabricated house that lacks furnishings and the other things which make a house a home.</p>
<div class="post-image"><a href="http://www.flickr.com/photos/89306448@N00/3677021452/" title="omg where did Facebook go?" target="_blank"><img src="http://farm4.static.flickr.com/3572/3677021452_90fa632370_m.jpg" alt="omg where did Facebook go?" border="0" /></a><br /><small><a href="http://creativecommons.org/licenses/by-nd/2.0/" title="Attribution-NoDerivs License" target="_blank"><img src="http://www.trickjarrett.com/wp-content/plugins/photo-dropper/images/cc.png" alt="Creative Commons License" border="0" width="16" height="16" align="absmiddle" /></a> <a href="http://www.photodropper.com/photos/" target="_blank">photo</a> credit: <a href="http://www.flickr.com/photos/89306448@N00/3677021452/" title="{Guerrilla Futures | Jason Tester}" target="_blank">{Guerrilla Futures | Jason Tester}</a></small></div>
<p>After exploring CMSs, next step is to begin learning to use other sites and their APIs. Like writing a <a href="http://www.facebook.com">Facebook</a> application, or a <a href="http://www.twitter.com">Twitter</a> application. To learn these, a good plan is to reinvent the wheel. Want to learn the Twitter API? Build a web twitter client. What to learn Facebook? Make a simple game. A web developer&#8217;s knowledge is his coin, and in a realm where the technology changes so quickly you owe it to yourself to explore as much as you can.</p>
<img src="http://www.trickjarrett.com/?ak_action=api_record_view&id=730&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trickjarrett.com/web-design-primer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>StumbleUpon&#8217;s Exciting Progress</title>
		<link>http://www.trickjarrett.com/stumbleupons-exciting-progress/</link>
		<comments>http://www.trickjarrett.com/stumbleupons-exciting-progress/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 01:59:57 +0000</pubDate>
		<dc:creator>Trick</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.trickjarrett.com/?p=716</guid>
		<description><![CDATA[Link shorteners seem to be the whipping boy of the Internet right now, everywhere I turn someone is griping about their evils, and their faults, and how they are going to be the downfall of the Internet. And yet, Digg, StumbleUpon, Bit.ly, Facebook and others are all working on this in various ways. Digg and [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Link shorteners seem to be the whipping boy of the Internet right now, everywhere I turn someone is griping about their evils, and their faults, and how they are going to be the downfall of the Internet. And yet, Digg, StumbleUpon, Bit.ly, Facebook and others are all working on this in various ways.</p>
<p>Digg and Facebook both use iframe wrappers to put a toolbar at the top of the window, offering the user enhanced functionality but in turn cloaking the content owner&#8217;s site and generally being uncool. Site owners, ones who are serious about blogging and building their following, usually dislike this as they feel that they lose credit or value from the links and traffic.<br />
<a href="http://www.trickjarrett.com/wp-content/uploads/stumbleuponashx1.jpg"><img src="http://www.trickjarrett.com/wp-content/uploads/stumbleuponashx1-300x252.jpg" alt="Stumble Upon" title="Stumble Upon" width="300" height="252" class="aligncenter size-medium wp-image-718" /></a><span id="more-716"></span><br />
StumbleUpon has a private beta going on for their <a href="http://www.su.pr">http://su.pr</a> link shortener and today they released info about something I am VERY keen on. It&#8217;s called <a href="http://www.stumbleupon.com/s/#1aj6Bd/www.stumbleupon.com/developers/Supr:Short_URLs_on_your_own_domain//">Supr:Short</a> according to this page, and it solves a major problem I have with Digg and Facebook&#8217;s linking.</p>
<p>Digg and Facebook use iframes to display a javascript toolbar that provides extra functionality and control back on the home site. This is done using a less than desirable iframe because it is the only way to maintain the javascript bar at the top of the window. But StumbleUpon is providing site owners with the ability to host the necessary scripts on their own site by some PHP code and a <del datetime="2009-06-30T10:49:06+00:00">locally</del> remotely hosted javascript file thus negating the need for the nasty iframe.</p>
<p>The fact that they put the scripts in the control of the user means that everyone wins. The site owner does because they regain the value and the address bar reads their own url. StumbleUpon does because the script sends them the necessary information and analytics and maintain their control bar.</p>
<p>The downside is that it possibly means issues as site owners will need to keep their script up to date. But the gained value more than makes up for the needed maintenance.</p>
<p>I can&#8217;t stress enough how exciting this possibility is and that it is a very good direction for link shorteners to go. <del datetime="2009-06-30T10:49:06+00:00">I unfortunately do not have a beta invite for StumbleUpon, but would love to get one to play with this new development!</del></p>
<p><strong>Update:</strong> &#8211; Minutes after I posted this, StumbleUpon released 250 more beta codes into the public. I successfully snatched one and have implemented the SuprShort code on the site. I&#8217;ll test it over the next few weeks and write a follow-up detailing my experience. Just a heads up, if you came to this page from <a href="http://trickjarrett.com/3gFN">http://trickjarrett.com/3gFN</a> then you just used the Su.pr code I talk about above.</p>
<img src="http://www.trickjarrett.com/?ak_action=api_record_view&id=716&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trickjarrett.com/stumbleupons-exciting-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Expand All</title>
		<link>http://www.trickjarrett.com/jquery-expand-all/</link>
		<comments>http://www.trickjarrett.com/jquery-expand-all/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 17:00:10 +0000</pubDate>
		<dc:creator>Trick</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.trickjarrett.com/?p=481</guid>
		<description><![CDATA[Here&#8217;s another lunchtime jQuery snippet as the last one proved semi-popular. This one came about today as I needed to expand on an existing expand/collapse functionality to allow users to expand or collapse all of the objects with this functionality. What had already been done was set a jQuery function to react on the presence [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#8217;s another lunchtime jQuery snippet as the last one proved semi-popular. This one came about today as I needed to expand on an existing expand/collapse functionality to allow users to expand or collapse all of the objects with this functionality.<br />
<span id="more-481"></span><br />
What had already been done was set a jQuery function to react on the presence of the .expanded class. The way it works is very simple, jQuery grabs all the elements with the .expandable class and then using the :first selector it tests the first one to see whether it is expanded or not. Then depending on the outcome it applies or removes the .expanded class.</p>
<div class="geshi no javascript">
<ol>
<li class="li1">
<div class="de1"><span class="kw2">function</span> toggle_expand_all<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> </div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span>$<span class="br0">&#40;</span><span class="st0">&#39;.expandable:first&#39;</span><span class="br0">&#41;</span>.<span class="kw1">is</span><span class="br0">&#40;</span><span class="st0">&#39;.expanded&#39;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="st0">&#39;.expandable&#39;</span><span class="br0">&#41;</span>.<span class="me1">removeClass</span><span class="br0">&#40;</span><span class="st0">&#39;expanded&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span> <span class="kw1">else</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; $<span class="br0">&#40;</span><span class="st0">&#39;.expandable&#39;</span><span class="br0">&#41;</span>.<span class="me1">addClass</span><span class="br0">&#40;</span><span class="st0">&#39;expanded&#39;</span><span class="br0">&#41;</span>;</div>
</li>
<li class="li1">
<div class="de1">&nbsp;<span class="br0">&#125;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>The headache with this snippet was my misunderstanding the jQuery.addClass and jQuery.removeClass pieces, originally I had &#8220;.addClass(&#8216;.expanded&#8217;)&#8221; and that add the class &#8216;..expanded&#8217; &#8211; Oops.</p>
<p>I opted to use .is as opposed to the .hasClass simply for it&#8217;s short length, no real reason here as both work by my understanding.</p>
<img src="http://www.trickjarrett.com/?ak_action=api_record_view&id=481&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trickjarrett.com/jquery-expand-all/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery snippet: How to make links break frames</title>
		<link>http://www.trickjarrett.com/jquery-snippet-how-to-make-links-break-frames/</link>
		<comments>http://www.trickjarrett.com/jquery-snippet-how-to-make-links-break-frames/#comments</comments>
		<pubDate>Fri, 03 Oct 2008 17:15:28 +0000</pubDate>
		<dc:creator>Trick</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.trickjarrett.com/?p=471</guid>
		<description><![CDATA[Here&#8217;s a quick lunch time post to share a simple snippet. It&#8217;s no new technology to have a page break out of frames when they&#8217;re not supposed to be in frames. But what if you do want the page to appear in a frame and only break the frame if a link is clicked? Well [...]]]></description>
			<content:encoded><![CDATA[<p></p><p>Here&#8217;s a quick lunch time post to share a simple snippet. </p>
<p>It&#8217;s no new technology to have a page break out of frames when they&#8217;re not supposed to be in frames. But what if you do want the page to appear in a frame and only break the frame if a link is clicked? Well then we turn to our trusty jQuery and use this little code snippet:</p>
<div class="geshi no php">
<ol>
<li class="li1">
<div class="de1"><span class="kw1">if</span> <span class="br0">&#40;</span>top<span class="sy0">.</span>frames<span class="sy0">.</span>length <span class="sy0">!=</span> <span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;$<span class="br0">&#40;</span><span class="st0">&quot;a&quot;</span><span class="br0">&#41;</span><span class="sy0">.</span>click<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp; &nbsp; this<span class="sy0">.</span>target <span class="sy0">=</span> <span class="st0">&quot;_parent&quot;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1">&nbsp; &nbsp;<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</li>
<li class="li1">
<div class="de1"><span class="br0">&#125;</span></div>
</li>
</ol>
</div>
<p>Why would you want to do this? That&#8217;s a fair question. For one of our clients at work they embed the header from their site onto the page for a site which sells merchandise for them. Now, we could have created a separate header but then when the header gets updated it needs to be changed in two places. This way it&#8217;s just one header file to maintain.</p>
<p>Hopefully this saves other developers ten minutes of their lives.</p>
<img src="http://www.trickjarrett.com/?ak_action=api_record_view&id=471&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://www.trickjarrett.com/jquery-snippet-how-to-make-links-break-frames/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
