<?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>Social Vitamin &#187; JavaScript</title>
	<atom:link href="http://www.socialvitamin.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.socialvitamin.com</link>
	<description>Give your social space a vitamin boost.</description>
	<lastBuildDate>Tue, 20 Sep 2011 17:02:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Yahoo! Query Language (YQL)</title>
		<link>http://www.socialvitamin.com/2009/07/10/yahoo-query-language-yql/</link>
		<comments>http://www.socialvitamin.com/2009/07/10/yahoo-query-language-yql/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 15:09:18 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web 2.0]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[xml]]></category>
		<category><![CDATA[yahoo]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=224</guid>
		<description><![CDATA[The Yahoo! Query Language is an expressive SQL-like language that lets you query, filter, and join data across Web services. With YQL, apps run faster with fewer lines of code [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://developer.yahoo.com/yql/">Yahoo! Query Language</a> is an expressive SQL-like language that lets you query, filter, and join data across Web services. With YQL, apps run faster with fewer lines of code and a smaller network footprint.</p>
<p>Yahoo! and other websites across the Internet make much of their structured data available to developers, primarily through Web services. To access and query these services, developers traditionally endure the pain of locating the right URLs and documentation to access and query each Web service.</p>
<p>With YQL, developers can access and shape data across the Internet through one simple language, eliminating the need to learn how to call different APIs.</p>
<h3>How Do I Get Started?</h3>
<ol>
<li>Check out the YQL <a href="http://developer.yahoo.com/yql/console/" target="_blank">Console</a>.</li>
<li>Read how to access YQL from <a href="http://developer.yahoo.com/yql/guide/running-chapt.html" target="_blank">your application</a>.</li>
<li>Get your <a href="http://developer.yahoo.com/dashboard/createKey.html" target="_blank">API Keys</a> to sign your requests if you <a href="http://developer.yahoo.com/yql/guide/authorization-access.html" target="_blank">need them</a>.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/07/10/yahoo-query-language-yql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 jQuery 1.3 Tips and Tricks for everyday use</title>
		<link>http://www.socialvitamin.com/2009/05/18/10-jquery-13-techniques-you-cant-live-without/</link>
		<comments>http://www.socialvitamin.com/2009/05/18/10-jquery-13-techniques-you-cant-live-without/#comments</comments>
		<pubDate>Mon, 18 May 2009 17:22:18 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web 2.0]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=145</guid>
		<description><![CDATA[Some useful jQuery Tips and Tricks for your everyday use. Removing and Hiding Dom Elements, Browser Detection, Toggling, Handling Select Lists and more. 1. Removing, Showing or Hiding DOM elements [...]]]></description>
			<content:encoded><![CDATA[<p>Some useful jQuery Tips and Tricks for your everyday use. Removing and Hiding Dom Elements, Browser Detection, Toggling, Handling Select Lists and more.<br />
<span id="more-145"></span></p>
<h3>1. Removing, Showing or Hiding DOM elements</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Remove Element</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">remove</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// Hide</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;fast&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// Show</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;fast&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">show</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1000</span><span style="color: #339933;">,</span> callback<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
&nbsp;
<span style="color: #006600; font-style: italic;">// Toggle Hide/ Show</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slow&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>2. Select All Check Boxes</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Check</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#selectList&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// Uncheck</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#selectList&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>3. Creating Images on the Fly</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;img/&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;images/loadingAnimation.gif&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#div&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>4. jQuery noConflict used when using other libraries</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> $j <span style="color: #339933;">=</span> jQuery.<span style="color: #660066;">noConflict</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$j<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#div'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>5. Getting Selected Radio Button value</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input[name='id'][checked]&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>6.  Getting Select List values</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Value</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#selectList'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">val</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// Text value</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#selectList :selected'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> 
&nbsp;
<span style="color: #006600; font-style: italic;">// Multiple Selection</span>
<span style="color: #003366; font-weight: bold;">var</span> selections <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#multipleList :selected'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span> selected<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
     selections<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span>selected<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>7. Check if checkbox is Checked</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#checkBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'checked'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#checkBoxID'</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">':checked'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;[:checkbox]:checked&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span>
    <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">&#125;</span> 
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>8. Browser Detection</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">safari</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Do something }</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span> <span style="color: #339933;">&amp;&amp;</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">version</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">6</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Do something }</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span> <span style="color: #339933;">&amp;&amp;</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">version</span> <span style="color: #339933;">&lt;=</span> <span style="color: #CC0000;">6</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Do something }</span>
&nbsp;
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">mozilla</span> <span style="color: #339933;">&amp;&amp;</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">version</span> <span style="color: #339933;">&gt;=</span> <span style="color: #3366CC;">&quot;1.8&quot;</span> <span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// Do something }</span></pre></div></div>

<h3>9. Highlight a Row onClick</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;tr&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;rowActive&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* CSS highlights clicked row */</span>
<span style="color: #6666ff;">.rowActive</span> <span style="color: #00AA00;">&#123;</span>  
    <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">solid</span> <span style="color: #cc00cc;">#333333</span><span style="color: #00AA00;">;</span> 
    <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;">;</span> 
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h3>10. Building the DOM Dynamically</h3>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;div/&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>id<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;header&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;class&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;header&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;Welcome to my Site!&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">body</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;img/&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;images/logo.gif&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#header&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/05/18/10-jquery-13-techniques-you-cant-live-without/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Paging with LINQ in ASP.NET MVC</title>
		<link>http://www.socialvitamin.com/2009/04/25/paging-with-linq-in-aspnet-mvc/</link>
		<comments>http://www.socialvitamin.com/2009/04/25/paging-with-linq-in-aspnet-mvc/#comments</comments>
		<pubDate>Sat, 25 Apr 2009 13:19:19 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=115</guid>
		<description><![CDATA[Here&#8217;s a really neat and simple way to add pagination to your LINQ results in ASP.NET MVC. The simple class can be also implemented in non ASP.NET MVC projects. Note: [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s a really neat and simple way to add pagination to your LINQ results in ASP.NET MVC. The simple class can be also implemented in non ASP.NET MVC projects.<br />
Note: You can change the source parameter to be List or just add a method overload.</p>
<p>PaginatedList Class</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">using <span style="color: #990000;">System</span><span style="color: #339933;">;</span>
using <span style="color: #990000;">System</span><span style="color: #339933;">.</span>Linq<span style="color: #339933;">;</span>
using <span style="color: #990000;">System</span><span style="color: #339933;">.</span>Collections<span style="color: #339933;">.</span>Generic<span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">namespace</span> MyApp<span style="color: #339933;">.</span>Helpers
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PaginatedList<span style="color: #339933;">&lt;</span>T<span style="color: #339933;">&gt;</span> <span style="color: #339933;">:</span> List<span style="color: #339933;">&lt;</span>T<span style="color: #339933;">&gt;</span>
    <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> int PageIndex <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">private</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">public</span> int PageSize <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">private</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">public</span> int TotalCount <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">private</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">public</span> int TotalPages <span style="color: #009900;">&#123;</span> get<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">private</span> set<span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> PaginatedList<span style="color: #009900;">&#40;</span>IQueryable<span style="color: #339933;">&lt;</span>T<span style="color: #339933;">&gt;</span> source<span style="color: #339933;">,</span> int pageIndex<span style="color: #339933;">,</span> int pageSize<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            PageIndex <span style="color: #339933;">=</span> pageIndex<span style="color: #339933;">;</span>
            PageSize <span style="color: #339933;">=</span> pageSize<span style="color: #339933;">;</span>
            TotalCount <span style="color: #339933;">=</span> source<span style="color: #339933;">.</span><span style="color: #990000;">Count</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            TotalPages <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span> Math<span style="color: #339933;">.</span>Ceiling<span style="color: #009900;">&#40;</span>TotalCount <span style="color: #339933;">/</span> <span style="color: #009900;">&#40;</span>double<span style="color: #009900;">&#41;</span>PageSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            this<span style="color: #339933;">.</span>AddRange<span style="color: #009900;">&#40;</span>source<span style="color: #339933;">.</span>Skip<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>PageIndex<span style="color: #009900;">&#41;</span> <span style="color: #339933;">*</span> PageSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>Take<span style="color: #009900;">&#40;</span>PageSize<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> bool HasPreviousPage
        <span style="color: #009900;">&#123;</span>
            get <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>PageIndex <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> bool HasNextPage <span style="color: #009900;">&#123;</span>
            get <span style="color: #009900;">&#123;</span><span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span>PageIndex<span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">&lt;</span> TotalPages<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Controller</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">        <span style="color: #000000; font-weight: bold;">public</span> ActionResult Index<span style="color: #009900;">&#40;</span>int? page<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            int pageSize <span style="color: #339933;">=</span> <span style="color: #cc66cc;">15</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">var</span> content <span style="color: #339933;">=</span> MyAppRepository<span style="color: #339933;">.</span>FindContentByDate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span>ToList<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">var</span> pagedContent <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PaginatedList<span style="color: #339933;">&lt;</span>Content<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span>content<span style="color: #339933;">,</span> page ?? <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> pageSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #b1b100;">return</span> View<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Index&quot;</span><span style="color: #339933;">,</span> pagedContent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span></pre></div></div>

<p>View</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">        &lt;div id=&quot;nav_paging&quot;&gt;
        &lt;% if (Model.HasPreviousPage) { %&gt;
        &lt;div class=&quot;nav_prev&quot;&gt;
            &lt;%= Html.RouteLink(&quot;Previous&quot;, &quot;Index&quot;, new { page = (Model.PageIndex - 1) })%&gt;
        &lt;/div&gt;
        &lt;% } %&gt;
&nbsp;
        &lt;% if (Model.HasNextPage) { %&gt;
        &lt;div class=&quot;nav_next&quot;&gt;
            &lt;%= Html.RouteLink(&quot;Next&quot;, &quot;Index&quot;, new { page = (Model.PageIndex + 1) })%&gt;
        &lt;/div&gt;
        &lt;% } %&gt;
        &lt;/div&gt;</pre></div></div>

<p>Routes in Global.asax</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">routes.MapRoute(
                &quot;Index&quot;,
                &quot;Index/Page/{page}&quot;,
                new { controller = &quot;Home&quot;, action = &quot;Index&quot;, page = 0 }
            );</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/04/25/paging-with-linq-in-aspnet-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random CSS themes give your Social Space a Design Twist</title>
		<link>http://www.socialvitamin.com/2009/04/11/random-css-themes-give-your-social-space-a-design-twist/</link>
		<comments>http://www.socialvitamin.com/2009/04/11/random-css-themes-give-your-social-space-a-design-twist/#comments</comments>
		<pubDate>Sat, 11 Apr 2009 05:18:31 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=105</guid>
		<description><![CDATA[Many sites are using this technique to give a fresh interface on every page the user visits, giving the illusion of a fast passed user experience. Sites like MTV, Hulu, [...]]]></description>
			<content:encoded><![CDATA[<p>Many sites are using this technique to give a fresh interface on every page the user visits, giving the illusion of a fast passed user experience. Sites like MTV, Hulu, MP3.com and many others use different techniques to change the sites layout either by changing the colors, backgrounds or just converting the site to a huge ad campaign. </p>
<p>I came up with a simple PHP script to Random your Themes. It checks for CSS files on a specified folder and randomizes it. You can also set the parameter (theme.php?file=theme.css) if you want to have a static version. Note: Security has been stripped for clarity, setup up the script with your own security.</p>
<p>PHP</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Themes Folder</span>
<span style="color: #000088;">$folder</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'./'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// File Type Default CSS</span>
<span style="color: #000088;">$fileTypes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$fileTypes</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'css'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'text/css'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// File</span>
<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Sanity Check</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'/'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$folder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$folder</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Request Param</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$meta</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pathinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_GET</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'file'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>
	    <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fileTypes</span><span style="color: #009900;">&#91;</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extension'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span>
        <span style="color: #990000;">file_exists</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'basename'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'basename'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$fileList</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span> <span style="color: #339933;">=</span> <span style="color: #990000;">opendir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$folder</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	        <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #990000;">readdir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!==</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$file_info</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pathinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fileTypes</span><span style="color: #009900;">&#91;</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$file_info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extension'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$fileList</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$file</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
	        <span style="color: #009900;">&#125;</span>
	        <span style="color: #990000;">closedir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$handle</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	    <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileList</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$rnd</span> <span style="color: #339933;">=</span> <span style="color: #990000;">rand</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$fileList</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$folder</span><span style="color: #339933;">.</span><span style="color: #000088;">$fileList</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$rnd</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Header and Content</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$meta</span> <span style="color: #339933;">=</span> <span style="color: #990000;">pathinfo</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$contentType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Content-type: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$fileTypes</span><span style="color: #009900;">&#91;</span> <span style="color: #000088;">$meta</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'extension'</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">header</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$contentType</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #990000;">readfile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> 
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>USE</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;link rel=&quot;stylesheet&quot; href=&quot;theme.php&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/04/11/random-css-themes-give-your-social-space-a-design-twist/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JS detecting event support in browsers</title>
		<link>http://www.socialvitamin.com/2009/04/03/js-detecting-event-support-in-browsers/</link>
		<comments>http://www.socialvitamin.com/2009/04/03/js-detecting-event-support-in-browsers/#comments</comments>
		<pubDate>Fri, 03 Apr 2009 04:08:16 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[detection]]></category>
		<category><![CDATA[events]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=86</guid>
		<description><![CDATA[As you may know there is no easy way of detecting which elements supports which events across browsers. Kangax from Perfection Kills has come up with a very clever way [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know there is no easy way of detecting which elements supports which events across browsers. Kangax from <a href="http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/">Perfection Kills</a> has come up with a very clever way of detecting them.</p>
<p>JavaScript</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
  <span style="color: #003366; font-weight: bold;">var</span> isEventSupported <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> TAGNAMES <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">'select'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'input'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'change'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'input'</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">'submit'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'form'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'reset'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'form'</span><span style="color: #339933;">,</span>
      <span style="color: #3366CC;">'error'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'load'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'img'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'abort'</span><span style="color: #339933;">:</span><span style="color: #3366CC;">'img'</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #003366; font-weight: bold;">function</span> isEventSupported<span style="color: #009900;">&#40;</span>eventName<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #003366; font-weight: bold;">var</span> el <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span>TAGNAMES<span style="color: #009900;">&#91;</span>eventName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">||</span> <span style="color: #3366CC;">'div'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      eventName <span style="color: #339933;">=</span> <span style="color: #3366CC;">'on'</span> <span style="color: #339933;">+</span> eventName<span style="color: #339933;">;</span>
      <span style="color: #003366; font-weight: bold;">var</span> isSupported <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>eventName <span style="color: #000066; font-weight: bold;">in</span> el<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isSupported<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        el.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span>eventName<span style="color: #339933;">,</span> <span style="color: #3366CC;">'return;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        isSupported <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">typeof</span> el<span style="color: #009900;">&#91;</span>eventName<span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">'function'</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
      el <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">return</span> isSupported<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">return</span> isEventSupported<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Use</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">isEventSupported<span style="color: #009900;">&#40;</span><span style="color: #339933;">&lt;</span><span style="color: #3366CC;">&quot;Type of Event&gt;&quot;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>For a more detailed description visit <a href="http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/">Kangax blog</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/04/03/js-detecting-event-support-in-browsers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debouncing Javascript Methods</title>
		<link>http://www.socialvitamin.com/2009/03/31/debouncing-javascript-methods/</link>
		<comments>http://www.socialvitamin.com/2009/03/31/debouncing-javascript-methods/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 03:23:58 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[Ajax]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[debouncing]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=58</guid>
		<description><![CDATA[What is debouncing anyways? Debouncing is any kind of hardware device or software that ensures that only a single signal will be acted upon for a single opening or closing [...]]]></description>
			<content:encoded><![CDATA[<p>What is debouncing anyways? Debouncing is any kind of hardware device or software that ensures that only a single signal will be acted upon for a single opening or closing of a contact. Imagine you have a form with a few elements that a user may access thru the tab key, on each element you have an onfocus event that will trigger an Ajax call to the server to acquire some data. You could just imagine how you could kill the server with all those Ajax calls! So that&#8217;s where debouncing comes into play. With debouncing your assuring that the method will be triggered in the element that the user intended to, although is not perfect it does work better than Throttling. <span id="more-58"></span></p>
<p>With this little method writen by John Hann from <a href="http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/">Unscriptable.com</a> you can add debouncing functionality to your JS methods.</p>
<p>Javascript</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> debounce <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>func<span style="color: #339933;">,</span> threshold<span style="color: #339933;">,</span> execAsap<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> timeout<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">function</span> debounced <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> obj <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> args <span style="color: #339933;">=</span> arguments<span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">function</span> delayed <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>execAsap<span style="color: #009900;">&#41;</span>
                func.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            timeout <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span>
            clearTimeout<span style="color: #009900;">&#40;</span>timeout<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>execAsap<span style="color: #009900;">&#41;</span>
            func.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span>obj<span style="color: #339933;">,</span> args<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        timeout <span style="color: #339933;">=</span> setTimeout<span style="color: #009900;">&#40;</span>delayed<span style="color: #339933;">,</span> threshold <span style="color: #339933;">||</span> <span style="color: #CC0000;">100</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Usage</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">    <span style="color: #006600; font-style: italic;">// using debounce in a constructor or initialization function to debounce</span>
    <span style="color: #006600; font-style: italic;">// focus events for a widget (onFocus is the original handler):</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">debouncedOnFocus</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">onFocus</span>.<span style="color: #660066;">debounce</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">500</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">inputNode</span>.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'focus'</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">debouncedOnFocus</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/03/31/debouncing-javascript-methods/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TaskSpeed &#8211; JS Framework Benchmarking</title>
		<link>http://www.socialvitamin.com/2009/03/31/taskspeed-js-framework-benchmarking/</link>
		<comments>http://www.socialvitamin.com/2009/03/31/taskspeed-js-framework-benchmarking/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 19:02:21 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[frameworks]]></category>
		<category><![CDATA[taskspeed]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=53</guid>
		<description><![CDATA[TaskSpeed is a benchmarking tool for JS Frameworks. It includes tests for jQuery, Mootools, Prototype and  Dojo. Dojo 1.3 has proven to be the fastest JS framework on common DOM [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://dante.dojotoolkit.org/taskspeed/">TaskSpeed</a> is a benchmarking tool for JS Frameworks. It includes tests for jQuery, Mootools, Prototype and  Dojo. Dojo 1.3 has proven to be the fastest JS framework on common DOM operations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/03/31/taskspeed-js-framework-benchmarking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make Facebook new home look like Twitters using Greasemonkey</title>
		<link>http://www.socialvitamin.com/2009/03/30/makes-facebook-new-home-look-like-twitters-using-greasemonkey/</link>
		<comments>http://www.socialvitamin.com/2009/03/30/makes-facebook-new-home-look-like-twitters-using-greasemonkey/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 20:38:22 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[greasemoneky]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=19</guid>
		<description><![CDATA[Facebook Twitter Style is a small CSS injection to hide some parts of the new Facebook home page to make it cleaner and mimic Twitter, also hides the infamous highlights [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://userscripts.org/scripts/show/44252"><strong>Facebook Twitter Style</strong></a> is a small CSS injection to hide some parts of the new Facebook home page to make it cleaner and mimic Twitter, also hides the infamous highlights column. You can also update your twitter status from Facebook using <a href="http://userscripts.org/scripts/show/44252"><strong>Facebook Twitter Updates</strong></a> script for Greasemonkey.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/03/30/makes-facebook-new-home-look-like-twitters-using-greasemonkey/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Post Facebook Updates to Twitter using Greasemonkey</title>
		<link>http://www.socialvitamin.com/2009/03/18/facebook-twitter-updates/</link>
		<comments>http://www.socialvitamin.com/2009/03/18/facebook-twitter-updates/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 19:55:01 +0000</pubDate>
		<dc:creator>Michael D. Irizarry</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[facebook]]></category>
		<category><![CDATA[greasemoneky]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://www.socialvitamin.com/?p=1</guid>
		<description><![CDATA[I just finished a Greasemonkey script that I call &#8220;Facebook Twitter Updates&#8221; that lets you post Tweets from Facebooks new &#8220;Share&#8221; feature in 140 characters or less. You will be [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished a Greasemonkey script that I call &#8220;<a href="http://userscripts.org/scripts/show/44470">Facebook Twitter Updates</a>&#8221; that lets you post <a href="http://www.twitter.com">Tweets</a> from Facebooks new &#8220;Share&#8221; feature in 140 characters or less. You will be able to Tweet from Facebook using Facebooks &#8220;Share&#8221; feature.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.socialvitamin.com/2009/03/18/facebook-twitter-updates/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

