<?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>Amped about Web Standards &#187; Examples</title>
	<atom:link href="http://www.ampedwebstandards.com/category/examples/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ampedwebstandards.com</link>
	<description>Discussion, code examples, and tutorials on web standards and web programming.</description>
	<lastBuildDate>Tue, 23 Feb 2010 10:05:24 +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>Tutorial: Dynamic slideshow with PHP &amp; JQuery</title>
		<link>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/</link>
		<comments>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 08:39:25 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=95</guid>
		<description><![CDATA[When I set out to add database driven player info at NuggetsHoops.com, I knew that I wanted to include code that would display some of the many images that I had set aside for each NBA player. I also knew that I would continue to add new pictures. Application code that could easily display old [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2009%2F03%2F16%2Ftutorial-dynamic-image-slideshow-with-php-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2009%2F03%2F16%2Ftutorial-dynamic-image-slideshow-with-php-jquery%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>When I set out to add database driven player info at <a title="NuggetsHoops" href="http://nuggetshoops.com">NuggetsHoops.com</a>, I knew that I wanted to include code that would display some of the many images that I had set aside for each NBA player. I also knew that I would continue to add new pictures. Application code that could easily display old and new images, without additional effort for each added image would work best.</p>
<p>I had already written PHP code that could look at a folder and create a list of images to be displayed. When I ran across the powerful<a title="jQuery Cycle Plugin" href="http://jquery.malsup.com/cycle/"> jQuery Cycle Plugin</a>, I had found a great way to display them.</p>
<p>Let&#8217;s get coding. This tutorial depends on PHP 5, jQuery 1.2.3 or later, jQuery Cycle Plugin version 2.51 or later.
<ul>
<li>I&#8217;ll assume you already have <a href="http://apache.org/">Apache</a> and <a href="http://www.php.net/downloads.php">PHP</a> setup and running. Make sure you have a recent version of PHP 5.</li>
<li><a title="jQuery Homepage" href="http://jquery.com/">Download jQuery</a></li>
<li><a title="Download jQuery Cycle Plugin" href="http://jquery.malsup.com/cycle/download.html">Download jQuery Cycle Plugin</a></li>
</ul>
<p>Add the following Javascript to your PHP/HTML to enable and call the Cycle Plugin:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="javascript"><div class="devcodeoverflow"><ol><li>&lt;script src=&quot;/scripts/jquery-1.3.2.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</li><li>&lt;script src=&quot;/scripts/jquery.cycle.all.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</li><li>&lt;script type=&quot;text/javascript&quot;&gt;</li><li>$(document).ready(function(){</li><li>	$('#myslides').cycle({</li><li>		fit: 1</li><li>	});</li><li>});</li><li>&lt;/script&gt;</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Note that there are <a href="http://www.malsup.com/jquery/cycle/options.html">many options</a> and <a href="http://www.malsup.com/jquery/cycle/browser.html">styles of animation</a> provided by the powerful Cycle plugin.</p>
<p>Add the following PHP to iterate over any folder and dynamically generate img tags using any images found in the folder:<br />
<!--DEVFMTCODE--><pre class="devcodeblock" title="php"><div class="devcodeoverflow"><ol><li>$directory = 'images/players/' . $row['imageName']; </li><li>try {&nbsp;&nbsp;&nbsp;&nbsp;</li><li>	// Styling for images</li><li>	echo &quot;&lt;div id=\&quot;myslides\&quot;&gt;&quot;;</li><li>	foreach ( new DirectoryIterator(&quot;../&quot; . $directory) as $item ) {			</li><li>		if ($item-&gt;isFile()) {</li><li>			$path = &quot;/&quot; . $directory . &quot;/&quot; . $item;</li><li>			echo &quot;&lt;img src=\&quot;&quot; . $path . &quot;\&quot; /&gt;&quot;;</li><li>		}</li><li>	}</li><li>	echo &quot;&lt;/div&gt;&quot;;</li><li>}</li><li>catch(Exception $e) {</li><li>	echo 'No images found for this player.&lt;br /&gt;';</li><li>}</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>Any img tags within an HTML element of class &#8216;myslides&#8217; (or whatever you initialized the Cycle plugin with in the Javascript) will have the slideshow behavior added to it. The $row array on line 1 is referencing a database query result, but could be set in a number of ways for your specific needs. The DirectoryIterator reference on line 5 is a builtin class in PHP5.</p>
<p>Here&#8217;s the CSS to style the images being displayed in the slideshow:</p>
<p><!--DEVFMTCODE--><pre class="devcodeblock" title="css"><div class="devcodeoverflow"><ol><li>#myslides {</li><li>width: 340px;</li><li>float: right;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;padding: 0;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;margin:&nbsp;&nbsp;0 auto;</li><li>margin-top: 20px;</li><li>} </li><li>&nbsp;</li><li>#myslides img {</li><li>&nbsp;&nbsp;&nbsp;&nbsp;padding: 10px;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;border:&nbsp;&nbsp;1px solid rgb(100,100,100);</li><li>&nbsp;&nbsp;&nbsp;&nbsp;background-color: rgb(230,230,230);</li><li>&nbsp;&nbsp;&nbsp;&nbsp;width: 320px;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;top:&nbsp;&nbsp;0;</li><li>&nbsp;&nbsp;&nbsp;&nbsp;left: 0</li><li>}</li></ol></div></pre><!--END_DEVFMTCODE--></p>
<p>So, there&#8217;s a very quick walk thru a working example to generate a dynamic slideshow from any folder of images. If you&#8217;d like a full download of the code, or any further explanation, please leave a comment!</p>
<p>You can see this code in action by just clicking on any player&#8217;s name at the  <a href="http://www.nuggetshoops.com/roster.php">NuggetsHoops.com Roster page</a>.</p>
<h2>New &#8211; download the code for this Tutorial</h2>
<p><a class="downloadlink" href="http://www.ampedwebstandards.com/download/1" title="Version1.0 downloaded 888 times" >Code for Dynamic Image Slideshow with PHP and JQuery (888)</a></p>
<p><a href="http://www.ampedwebstandards.com/demos/dynamic-image-slideshow-php-jquery/">Demo</a><br />
<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2009/03/16/tutorial-dynamic-image-slideshow-with-php-jquery/feed/</wfw:commentRss>
		<slash:comments>37</slash:comments>
		</item>
		<item>
		<title>Progressive Enhancement with jQuery</title>
		<link>http://www.ampedwebstandards.com/2008/08/29/progressive-enhancement-with-jquery/</link>
		<comments>http://www.ampedwebstandards.com/2008/08/29/progressive-enhancement-with-jquery/#comments</comments>
		<pubDate>Fri, 29 Aug 2008 08:28:18 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Examples]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[progressive enhancement]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=30</guid>
		<description><![CDATA[While I work on finishing up an overdue post on the amazing An Event Apart San Francisco conference I attended last week, I thought I would at least write about one of the many new concepts that was discussed. Progressive Enhancement (PE) is the concept of adding functionality or enhancements to the presentation and behavior [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F08%2F29%2Fprogressive-enhancement-with-jquery%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F08%2F29%2Fprogressive-enhancement-with-jquery%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><span id="extlinks">While I work on finishing up an overdue post on the amazing An Event Apart San Francisco conference I attended last week, I thought I would at least write about one of the many new concepts that was discussed.</span><br />
<code><script src="/scripts/jquery.js" type="text/javascript"></script></code></p>
<p>Progressive Enhancement (PE) is the concept of adding functionality or enhancements to the presentation and behavior of a webpage, using modern technologies such as CSS and Javascript. The PE approach adds the additional features thru externally linked files in order to avoid forcing older/less capable browsers to process data they don&#8217;t understand or can&#8217;t handle. In other words, the strategy demands that the basic content always be available, then add the fancier layout and features for browsers that can show it.</p>
<p>I&#8217;m going to show a quick but usable example of PE using jQuery. In this example, I am going to show how you can dynamically add an &#8220;external link&#8221; icon &#8211; <img src="/images/external.png" border="0" alt="" /> to links inside a specific area of your webpage.</p>
<p>1. <a href="http://docs.jquery.com/Downloading_jQuery">download the current release of jQuery</a> (at this writing &#8211; 1.2.6) and add it to your webpage in the tag.</p>
<p>2. Next, we will utilize the jQuery approach of executing Javascript code when the Document is loaded and the DOM is ready to be manipulated.</p>
<p><code>$(document).ready(function() { <code>});</code></code></p>
<p>3. Now, if we want to add an image after each external link, we can use the jQuery filter function which will addall elements that match a specified expression.</p>
<p>In the <code>section above, we'll add:</code></p>
<p><code>$("a").filter(".selected")</code></p>
<p>4. The expression will be another function that tests the hostname property of the link to see if it is different that the current page&#8217;s hostname.</p>
<p>Try this:</p>
<p><code>function() { return this.hostname &amp;&amp; this.hostname !== location.hostname; })</code></p>
<p>5. Lastly, we&#8217;ll use jQuery to insert the image after the link that matches the test expression &#8211; namely an external link!</p>
<p><code>.after(' &lt;img src="/images/ext.png" alt="External Link"&gt;');</code></p>
<p>6. Let&#8217;s put it all together!</p>
<p>Here&#8217;s the sum of the Javascript that we&#8217;ve written:</p>
<p><code>$(document).ready(function() {<br />
$('#extlinks a').filter(function() {<br />
return this.hostname &amp;&amp; this.hostname !== location.hostname;<br />
}).after(' &lt;img src="/images/ext.png" alt="External Link"&gt;');<br />
});</code></p>
<p>put that code in a Javascript file and include it after your jQuery code in your page&#8217;s :</p>
<p><code><script src="/scripts/ext-links.js" type="text/javascript"></script></code></p>
<p>That&#8217;s it! Now go give it a try for yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2008/08/29/progressive-enhancement-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Microformats to simplify registration forms</title>
		<link>http://www.ampedwebstandards.com/2008/06/19/using-microformats-to-simplify-registration-forms/</link>
		<comments>http://www.ampedwebstandards.com/2008/06/19/using-microformats-to-simplify-registration-forms/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 05:47:48 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[flickr]]></category>
		<category><![CDATA[hcard]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/?p=17</guid>
		<description><![CDATA[GetSatisfaction.com is a community website that encourages conversation between consumers and companies. Their registration form is a clever, real-world example of how microformats can make life easier on the web. If you&#8217;ve already registered with flickr.com, technorati.com, twitter.com, or any of several other sites, you can enter your id for that website off to the [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F06%2F19%2Fusing-microformats-to-simplify-registration-forms%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2008%2F06%2F19%2Fusing-microformats-to-simplify-registration-forms%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://getsatisfaction.com/">GetSatisfaction.com</a> is a community website that encourages conversation between consumers and companies.</p>
<p>Their <a href="http://getsatisfaction.com/people/new">registration form</a> is a clever, real-world example of how microformats can make life easier on the web.</p>
<p>If you&#8217;ve already registered with flickr.com, technorati.com, twitter.com, or any of several other sites, you can enter your id for that website off to the right of the form and it will pre-populate the GetSatisfaction form with publically available information. Specifically, it uses the <a href="http://microformats.org/wiki/hcard">hCard microformat</a> to extract the public portions of your profile on those other websites. The hCard microformat allows for individual elements of your contact information to be parsed and used.</p>
<p>If you haven&#8217;t already, go try out the form at GetSatisfaction and see it in action.</p>
<p>I&#8217;ll build a live example of this approach here in the coming weeks and post the code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2008/06/19/using-microformats-to-simplify-registration-forms/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial: Using hCalendar Microformats</title>
		<link>http://www.ampedwebstandards.com/2007/04/11/tutorial-using-hcalendar-microformats/</link>
		<comments>http://www.ampedwebstandards.com/2007/04/11/tutorial-using-hcalendar-microformats/#comments</comments>
		<pubDate>Wed, 11 Apr 2007 07:00:44 +0000</pubDate>
		<dc:creator>alan</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Microformats]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[hCalendar]]></category>
		<category><![CDATA[operator]]></category>

		<guid isPermaLink="false">http://www.ampedwebstandards.com/2007/04/11/tutorial-using-hcalendar-microformats/</guid>
		<description><![CDATA[Okay, hopefully you now have a general understanding of what Microformats are. (Hint: If you don&#8217;t follow that last link) Now, what can you do with them? I&#8217;m going to walk thru a real-world example, and we&#8217;ll discuss the tools you&#8217;ll need to do so. In this tutorial/example, you are a Denver Nuggets NBA fan, [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2007%2F04%2F11%2Ftutorial-using-hcalendar-microformats%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.ampedwebstandards.com%2F2007%2F04%2F11%2Ftutorial-using-hcalendar-microformats%2F&amp;source=aswitzer&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Okay, hopefully you now have a general understanding of <a href="http://www.ampedwebstandards.com/2007/04/26/what-are-microformats/" title="What are Microformats?" target="_blank">what Microformats are</a>. (Hint: If you don&#8217;t follow that last link)</p>
<p>Now, what can you do with them?</p>
<p>I&#8217;m going to walk thru a real-world example, and we&#8217;ll discuss the tools you&#8217;ll need to do so.</p>
<p>In this tutorial/example, you are a <a href="http://www.nuggetshoops.com" title="NuggetsHoops.com - A Denver Nuggets NBA Fansite">Denver Nuggets NBA fan</a>, and you would like to add a few of their remaining games to your online calendar. Even if you aren&#8217;t an NBA fan, hopefully by the time we are done, you will understand how to seek out and use microformats that you <em>are </em>interested in.</p>
<p>Tools you will need:</p>
<ul>
<li>Recent version of Mozilla Firefox (preferably 2.0+)</li>
<li>Google account (we&#8217;ll use Google&#8217;s online Calendar)</li>
<li>Firefox Operator Plugin (Add-on)</li>
</ul>
<p>Okay, let&#8217;s get started: (all links will open in a new window)</p>
<ol>
<li><a href="http://www.ampedwebstandards.com/2007/04/11/tutorial-using-hcalendar-microformats/firefox-3/" target="_blank" rel="attachment wp-att-9" title="Download Firefox"><img src="http://www.ampedwebstandards.com/wp-content/180px-firefox-logo.png" alt="Firefox" class="right" border="0" height="90" width="90" /></a> &#8211; <a href="http://www.mozilla.com/en-US/" title="Download Firefox 2" target="_blank">Download and install Firefox </a><br/><br/>Follow the basic install instructions. The current version as of this article is 2.0.0.3
<p>Mac or Linux user? <a href="http://www.mozilla.com/en-US/firefox/all.html" target="_blank" title="Download Firefox 2 for Mac or Linux">Download Firefox from here</a>.</li>
<li><a href="https://www.google.com/accounts/NewAccount?service=ig&#038;passive=true&#038;continue=http://www.google.com/ig%3Fhl%3Den&#038;followup=http://www.google.com/ig%3Fhl%3Den&#038;cd=US&#038;hl=en&#038;nui=1&#038;ltmpl=default" target="_blank" title="Create a free Google account">Create a free Google account</a><a href="http://www.ampedwebstandards.com/2007/04/11/tutorial-using-hcalendar-microformats/google/" rel="attachment wp-att-10" title="Google"><img src="http://www.ampedwebstandards.com/wp-content/200px-google_logo_transparent.png" alt="Google" class="right" border="0" /></a><br />
<strong><br />
Note:</strong> If you already use Gmail or another Google service, you already have an account and can skip this step.</p>
<p>Once you have your account, you can check out the <a href="http://www.google.com/calendar" title="Google Calendar" target="_blank">Google Calendar app</a>, but you don&#8217;t need to do anything with it yet.</li>
<li>Add the Operator Add-on to Firefox<br/>
<p>The current version of Firefox needs a little assistance to make it easy to work with Microformats. There are several add-ons that help you view and interact with Microformats, but the <a href="https://addons.mozilla.org/en-US/firefox/addon/4106" title="Operator Firefox Add-on" target="_blank">Operator Add-On by Michael Kaply</a> is the one I recommend. As of this writing, the latest version is  0.7.</p>
<p>Click on the link, scroll down and click on the green Install Now button. Firefox will have it installed in a matter of seconds for you &#8211; restart Firefox and you are ready for the next step.</li>
<li>Okay, you now have all the tools you need to make use of a Microformat &#8211; specifically, we are going to add the information for an upcoming event to your Google Calendar. Visit the <a href="http://www.nuggetshoops.com/schedule.php" title="NuggetsHoops.com - Season Results and Remaining Schedule" target="_blank">NuggetsHoops.com Season Schedule</a> with your Firefox browser. You&#8217;ll see the results of all games from the current NBA season. Scroll down to the bottom of the page to see the remaining games. As of this writing, there are only 5 games left, but all playoff games will also be added to this page when they are announced.<br />
<img src="http://www.ampedwebstandards.com/wp-content/microformat-screenshot2.gif" alt="Screenshot of Microformats at NuggetsHoops.com" /><br />
<em> </em><em><br />
Note:</em> If you run across the post in the offseason, there will be new events on this same page when the next NBA season restarts in October/November.</p>
<p>In the screenshot above, you will notice that I highlighted a button on the Operator toolbar that shows you that the Add-on has detected 3 Calendar events that you can add to Google Calendar, among other apps in the near future. The events are ordered from  next to later, top to bottom in the pulldown that appears when you click on the button.  This is the Operator Add-on at work, letting you know that it has detected Microformats on the current page and it is prepared to help you use them. Pick one of the games and left-click with your mouse. If you are currently logged into your Google Account, you will see the detail page for a new Event entry, with all of the required details already filled in. Just click &#8220;Save Changes&#8221;, and you&#8217;ve successfully used an hCalendar Microformat to create an event in your Google Calendar. Click on the Google Calendar link in the top left corner to see how it looks.</p>
<p>You can now go back to the <a href="http://www.nuggetshoops.com/schedule.php" title="NuggetsHoops Season Schedule" target="_blank">NuggetsHoops.com Season Schedule</a> and add more events in the same way, or better yet &#8211; go explore other websites and see what other Microformat enabled websites you can find and now easily take advantage of! (Hint: The social calendar website &#8211; <a href="http://www.upcoming.org/" title="Upcoming.org Homepage" target="_blank">Upcoming.org</a> is a great place to start!)</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.ampedwebstandards.com/2007/04/11/tutorial-using-hcalendar-microformats/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>
