<?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, 17 Aug 2010 20:34:48 +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>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>
<pre lang="Javascript">
// Remove Element
$("#div").remove();

// Hide
$("#div").hide();
$("#div").hide("slow");
$("#div").hide("fast");
$("#div").hide(1000);
$("#div").hide(1000, callback); 

// Show
$("#div").show();
$("#div").show("slow");
$("#div").show("fast");
$("#div").show(1000);
$("#div").show(1000, callback);  

// Toggle Hide/ Show
$("#div").toggle();
$("#div").toggle("slow");
</pre>
<h3>2. Select All Check Boxes</h3>
<pre lang="Javascript">
// Check
$("#selectList").attr('checked', true); 

// Uncheck
$("#selectList").attr('checked', false);
</pre>
<h3>3. Creating Images on the Fly</h3>
<pre lang="Javascript">
$("<img/>").attr({ "src": "images/loadingAnimation.gif" }).appendTo("#div");
</pre>
<h3>4. jQuery noConflict used when using other libraries</h3>
<pre lang="Javascript">
var $j = jQuery.noConflict();
$j('#div').hide();
</pre>
<h3>5. Getting Selected Radio Button value</h3>
<pre lang="Javascript">
$("input[name='id'][checked]").val();
</pre>
<h3>6.  Getting Select List values</h3>
<pre lang="Javascript">
// Value
$('#selectList').val(); 

// Text value
$('#selectList :selected').text() 

// Multiple Selection
var selections = [];
$('#multipleList :selected').each(function(i, selected){
     selections[i] = $(selected).text();
});
</pre>
<h3>7. Check if checkbox is Checked</h3>
<pre lang="Javascript">
$('#checkBox').attr('checked'); 

$('#checkBoxID').is(':checked'); 

$("[:checkbox]:checked").each(
    function() {
    }
);
</pre>
<h3>8. Browser Detection</h3>
<pre lang="Javascript">
if( $.browser.safari ) { // Do something }

if ($.browser.msie &#038;&#038; $.browser.version > 6 ) { // Do something }

if ($.browser.msie &#038;&#038; $.browser.version <= 6 ) { // Do something }

if ($.browser.mozilla &#038;&#038; $.browser.version >= "1.8" )  { // Do something }
</pre>
<h3>9. Highlight a Row onClick</h3>
<pre lang="Javascript">
$("tr").click(function() {
    $(this).toggleClass("rowActive");
});
</pre>
<pre lang="css">
/* CSS highlights clicked row */
.rowActive {
    border: 1px solid #333333;
    background-color: #999999;
}
</pre>
<h3>10. Building the DOM Dynamically</h3>
<pre lang="Javascript">
$("
<div/>").attr({id:"header", "class":"header"}).html("Welcome to my Site!").appendTo(document.body);
$("<img/>").attr("src", "images/logo.gif").appendTo("#header");
</pre>
]]></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>
<pre lang="PHP">
using System;
using System.Linq;
using System.Collections.Generic;

namespace MyApp.Helpers
{
    public class PaginatedList<T> : List<T>
    {

        public int PageIndex { get; private set; }
        public int PageSize { get; private set; }
        public int TotalCount { get; private set; }
        public int TotalPages { get; private set; }

        public PaginatedList(IQueryable<T> source, int pageIndex, int pageSize)
        {
            PageIndex = pageIndex;
            PageSize = pageSize;
            TotalCount = source.Count();

            TotalPages = (int) Math.Ceiling(TotalCount / (double)PageSize);

            this.AddRange(source.Skip((PageIndex) * PageSize).Take(PageSize));
        }

        public bool HasPreviousPage
        {
            get {return (PageIndex > 0);}
        }

        public bool HasNextPage {
            get {return (PageIndex+1 < TotalPages);}
        }

    }
}
</pre>
<p>Controller</p>
<pre lang="PHP">
        public ActionResult Index(int? page)
        {
            int pageSize = 15;
            var content = MyAppRepository.FindContentByDate().ToList();
            var pagedContent = new PaginatedList<Content>(content, page ?? 0, pageSize);

            return View("Index", pagedContent);
        }
</pre>
<p>View</p>
<pre lang="HTML">
<div id="nav_paging">
        <% if (Model.HasPreviousPage) { %>
<div class="nav_prev">
            <%= Html.RouteLink("Previous", "Index", new { page = (Model.PageIndex - 1) })%>
        </div>

        <% } %>

        <% if (Model.HasNextPage) { %>
<div class="nav_next">
            <%= Html.RouteLink("Next", "Index", new { page = (Model.PageIndex + 1) })%>
        </div>

        <% } %>
        </div>
</pre>
<p>Routes in Global.asax</p>
<pre lang="HTML">
routes.MapRoute(
                "Index",
                "Index/Page/{page}",
                new { controller = "Home", action = "Index", page = 0 }
            );
</pre>
]]></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>
<pre lang="PHP">
<?php

// Themes Folder
$folder = './';

// File Type Default CSS
$fileTypes = array();
$fileTypes['css'] = 'text/css';

// File
$file = null;

// Sanity Check
if (substr($folder,-1) != '/') {
	$folder = $folder.'/';
}

// Request Param
if (isset($_GET['file'])) {
	$meta = pathinfo($_GET['file']);
	if (
	    isset( $fileTypes[ strtolower( $meta['extension'] ) ] ) &#038;&#038;
        file_exists( $folder.$meta['basename'] )
    ) {
		$file = $folder.$meta['basename'];
	}
} else {
	$fileList = array();

	if (is_dir($folder)) {
	    if ($handle = opendir($folder)) {
	        while (($file = readdir($handle)) !== false) {
				$file_info = pathinfo($file);
				if ( isset( $fileTypes[ strtolower( $file_info['extension'] ) ] ) ) {
					$fileList[] = $file;
				}
	        }
	        closedir($handle);
	    }
	}

	if (count($fileList) > 0) {
		$rnd = rand(0, count($fileList)-1);
		$file = $folder.$fileList[$rnd];
	}
}

// Header and Content
if ($file != null) {
	$meta = pathinfo($file);
	$contentType = 'Content-type: '.$fileTypes[ $meta['extension'] ];
	header ($contentType);
	readfile($file);
}
?>
</pre>
<p>USE</p>
<pre lang="html">
<link rel="stylesheet" href="theme.php" type="text/css" media="screen" />
</pre>
]]></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>
<pre lang="Javascript">

  var isEventSupported = (function(){
    var TAGNAMES = {
      'select':'input','change':'input',
      'submit':'form','reset':'form',
      'error':'img','load':'img','abort':'img'
    }
    function isEventSupported(eventName) {
      var el = document.createElement(TAGNAMES[eventName] || 'div');
      eventName = 'on' + eventName;
      var isSupported = (eventName in el);
      if (!isSupported) {
        el.setAttribute(eventName, 'return;');
        isSupported = typeof el[eventName] == 'function';
      }
      el = null;
      return isSupported;
    }
    return isEventSupported;
  })();
</pre>
<p>Use</p>
<pre lang="Javascript">
isEventSupported(<"Type of Event>")
</pre>
<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>
<pre lang="Javascript">var debounce = function (func, threshold, execAsap) {

    var timeout;

    return function debounced () {
        var obj = this, args = arguments;
        function delayed () {
            if (!execAsap)
                func.apply(obj, args);
            timeout = null;
        };

        if (timeout)
            clearTimeout(timeout);
        else if (execAsap)
            func.apply(obj, args);

        timeout = setTimeout(delayed, threshold || 100);
    };

}</pre>
<p>Usage</p>
<pre lang="Javascript">    // using debounce in a constructor or initialization function to debounce
    // focus events for a widget (onFocus is the original handler):
    this.debouncedOnFocus = this.onFocus.debounce(500, false);
    this.inputNode.addEventListener('focus', this.debouncedOnFocus, false);</pre>
]]></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>
