<?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>Tony Bebber &#124; UI Developer</title>
	<atom:link href="http://www.tonybebber.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.tonybebber.com</link>
	<description>UI Developer Blog</description>
	<lastBuildDate>Sun, 06 May 2012 14:13:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Populate an Array with Random and Unique Values Using JavaScript</title>
		<link>http://www.tonybebber.com/populate-an-array-with-random-and-unique-values-using-javascript</link>
		<comments>http://www.tonybebber.com/populate-an-array-with-random-and-unique-values-using-javascript#comments</comments>
		<pubDate>Sun, 06 May 2012 03:05:07 +0000</pubDate>
		<dc:creator>Tony Bebber</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tonybebber.com/?p=153</guid>
		<description><![CDATA[I recently had the need to take a JavaScript array that contained 4 items, and create a new array of 3 random and unique items which would be populated from the values in the original 4 item array. I figured I would post an example of my solution for anyone who might need to do something similar. Though I'm not going detail to explain everything in this post, my example is heavily commented for anyone interested in how this snippet of code works...]]></description>
			<content:encoded><![CDATA[<p>I recently had the need to take a JavaScript array that contained 4 items, and create a new array of 3 random and unique items which would be populated from the values in the original 4 item array. I figured I would post an example of my solution for anyone who might need to do something similar. Though I&#8217;m not going into much detail to explain everything in this post, my example is heavily commented for anyone interested in how this snippet of code works.</p>
<p>One thing to note is that this solution is framework agnostic. However, I am using <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf" title="JavaScript array.indexOf">array.indexOf</a>, which was recently introduced in the 5th Edition of ECMAScript, I believe browser support of this new method is decent, however many JavaScript frameworks have similar methods that might be safer to use in terms of cross-browser compatibility for the time being (ie. jQuery&#8217;s $.inArray() method)&#8230;</p>
<p><pre><code>// Array of hockey players
var hockeyPlayers = [&#039;Wayne Gretzky&#039;, &#039;Wendel Clark&#039;, &#039;Joe Sakic&#039;, &#039;Ian Laperriere&#039;];

// Empty array to store random &amp; unique hockey players in
var randomize = [];

// Cache hockeyPlayers length for optimal performance in for loop
var numPlayers = hockeyPlayers.length;

// Create for loop to iterate 3 times
for(var i = 0; i &lt; 3; i++) {
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// Generate a random number for use in the randomize array
&nbsp;&nbsp;&nbsp;&nbsp;var randomIndex = Math.floor(Math.random() * numPlayers);
&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;// Use array.indexOf property (available as of ECMAScript 5th Edition)...
&nbsp;&nbsp;&nbsp;&nbsp;// to check if a hockey player has already been placed in the randomize array
&nbsp;&nbsp;&nbsp;&nbsp;if(randomize.indexOf(hockeyPlayers[randomIndex]) !== -1) {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// If hockey player already exists in randomize array decrement i...
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// this will allow loop to continue until we find a unique hockey player
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;i--;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;} else {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Else insert unique hockey player into randomize array
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;randomize.push(hockeyPlayers[randomIndex]);

&nbsp;&nbsp;&nbsp;&nbsp;}
}

alert(randomize);</code></pre></p>
<p>Also, here is a jsfiddle of the above example &#8211; <a href="http://jsfiddle.net/xTKPu/" title="jsfiddle">http://jsfiddle.net/xTKPu/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybebber.com/populate-an-array-with-random-and-unique-values-using-javascript/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>costEstimatr jQuery Plugin</title>
		<link>http://www.tonybebber.com/costestimatr-jquery-plugin</link>
		<comments>http://www.tonybebber.com/costestimatr-jquery-plugin#comments</comments>
		<pubDate>Sun, 08 Jan 2012 20:37:28 +0000</pubDate>
		<dc:creator>Tony Bebber</dc:creator>
				<category><![CDATA[Projects]]></category>

		<guid isPermaLink="false">http://www.tonybebber.com/?p=62</guid>
		<description><![CDATA[<a href="http://tonybebber.com/projects/costEstimatr/demo/index.html">costEstimatr</a> is a very simple jQuery plugin that I created to easily allow anyone who offers a service to provide a real-time cost estimate to their users. In a nutshell, this plugin allows you to add the value attribute of all checkboxes, radio buttons and select form elements (as long as you have set it to a number...]]></description>
			<content:encoded><![CDATA[<p><a href="http://tonybebber.com/projects/costEstimatr/demo/index.html">costEstimatr</a> is a very simple jQuery plugin that I created to easily allow anyone who offers a service to provide a real-time cost estimate to their users. In a nutshell, this plugin allows you to add the value attribute of all checkboxes, radio buttons and select form elements (as long as you have set it to a number which represents the price) and outputs a cost estimate as well as an optional estimate on the number of days it will take to complete the project.</p>
<p><a href="http://tonybebber.com/projects/costEstimatr/demo/index.html">Demo</a></p>
<h5>Installation/Usage</h5>
<p>Step 1<br />
<a href="http://tonybebber.com/projects/costEstimatr/download/costEstimatr.zip">Download</a> and call the jquery.costEstimatr.js script which is dependent on the jQuery core. Example&#8230;<br />
<code>&lt;script type=&quot;text/javascript&quot; src=&quot;js/jquery.costEstimatr.js&quot;&gt;&lt;/script&gt;</code></p>
<p>Step 2<br />
Select the form element that you want to have cost estimation functionality on and then apply the costEstimatr method. Example&#8230;<br />
<code>$(&#039;#priceQuote&#039;).costEstimatr();</code></p>
<p>Step 3<br />
Update the value attribute of any checkbox, radio button or select form element to use a number which will represent the cost of that particular service. Example&#8230;<br />
<code>&lt;input id=&quot;hosting&quot; type=&quot;checkbox&quot; name=&quot;hosting&quot; value=&quot;99&quot; /&gt;&lt;label for=&quot;hosting&quot;&gt;Web Hosting &lt;span&gt;$99&lt;/span&gt;&lt;/label&gt;</code></p>
<p>Step 4<br />
Define your estimation summary container. Example&#8230;<br />
<code>Estimated Total Price: $&lt;span id=&quot;price&quot;&gt;0.00&lt;/span&gt;</code></p>
<p>By default the plugin looks for a span with an id of price (span#price) to update the cost, and a span with an id of days (span#days) to update the ETA (ETA is optional). However, there are a few options that you can set to overwrite these and a few other defaults.</p>
<h5>Plugin Options</h5>
<p>This plugin has 4 options that can be overwritten. Below is a description of these options and their default value&#8230;</p>
<p><span class="yellow">price:</span> This defines the selector that you would like to use to display cost estimate summary.<br />
Default Value:<br />
<code>price: $(&#039;span#price&#039;)</code></p>
<p><span class="yellow">showDaysEstimate:</span> Boolean value to determine whether or not to display an ETA.<br />
Default Value:<br />
<code>showDaysEstimate: true</code></p>
<p><span class="yellow">days:</span> This defines the selector that you would like to use to display estimated days it will take to complete the project.<br />
Default Value:<br />
<code>days: $(&#039;span#days&#039;)</code></p>
<p><span class="yellow">dollarsPerDay:</span> In order for the days estimate to update accordingly, a number of dollars per day needs to be set. For example, by default the dollarsPerDay option is set to 200, so for every $200 that gets added to the price summary, 1 day gets added to the days summary.<br />
Default Value:<br />
<code>dollarsPerDay: 200</code></p>
<p>Below is an example of how to pass new options to the costEstimatr method to overwrite the defaults&#8230;<br />
<code>$(&#039;#priceQuote&#039;).costEstimatr({price: $(&#039;#yourNewPriceContainer&#039;), showDaysEstimate: false});</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybebber.com/costestimatr-jquery-plugin/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Welcome</title>
		<link>http://www.tonybebber.com/welcome</link>
		<comments>http://www.tonybebber.com/welcome#comments</comments>
		<pubDate>Sun, 08 Jan 2012 10:46:05 +0000</pubDate>
		<dc:creator>Tony Bebber</dc:creator>
				<category><![CDATA[Blog]]></category>

		<guid isPermaLink="false">http://www.tonybebber.com/?p=81</guid>
		<description><![CDATA[Today marks the official launch of a site that I have had plans to create for a while now. I have always wanted to have a blog that I could update regularly with the latest <a title="Projects" href="http://tonybebber.com/category/projects/">projects</a> that I have been working on, as well as the latest UI development techniques that I learn. Most of my projects and <a title="Blog" href="http://tonybebber.com/category/blog/">blog posts</a> will relate to JavaScript as it is a topic that I have recently...]]></description>
			<content:encoded><![CDATA[<p>Today marks the official launch of a site that I have had plans to create for a while now. I have always wanted to have a blog that I could update regularly with the latest <a title="Projects" href="http://tonybebber.com/category/projects/">projects</a> that I have been working on, as well as the latest UI development techniques that I learn.</p>
<p>Most of my projects and <a title="Blog" href="http://tonybebber.com/category/blog/">blog posts</a> will relate to JavaScript as it is a topic that I have recently become obsessed with. I am constantly looking to improve my skills as a JavaScript developer and I would like to use this blog to chronicle some of the interesting things that I get to learn on a day-to-day basis since I spend the majority of hours at my current job as a UI developer working with JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tonybebber.com/welcome/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

