<?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>Jamal Jackson&#039;s Portfolio</title>
	<atom:link href="http://www.5alarmint.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.5alarmint.com</link>
	<description>The Portfolio and Blog for Jamal Jackson</description>
	<lastBuildDate>Thu, 16 May 2013 18:24:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>jQuery Quickie: Sticky Sidebar</title>
		<link>http://www.5alarmint.com/jquicke/sticky-sidebar</link>
		<comments>http://www.5alarmint.com/jquicke/sticky-sidebar#comments</comments>
		<pubDate>Thu, 16 May 2013 18:24:52 +0000</pubDate>
		<dc:creator>jamal</dc:creator>
				<category><![CDATA[jQuery Quicke]]></category>
		<category><![CDATA[fixed]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[sidebar]]></category>
		<category><![CDATA[stick]]></category>
		<category><![CDATA[sticky]]></category>

		<guid isPermaLink="false">http://www.5alarmint.com/?p=1843</guid>
		<description><![CDATA[Welcome to jQuery quickie, and here is where I share some of the jQuery goodness that is in something I have done for a project. Then again, there are still going to be those days where I just want to try something out to see if I can do it and post it. Either way, [...]<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href='http://www.5alarmint.com/jquicke/tab-navigation' rel='bookmark' title='jQuery Quickie: Tab Navigation'>jQuery Quickie: Tab Navigation</a></li>
<li><a href='http://www.5alarmint.com/jquicke/tag-filter' rel='bookmark' title='jQuery Quickie: Tag Filter'>jQuery Quickie: Tag Filter</a></li>
<li><a href='http://www.5alarmint.com/jquicke/tooltip' rel='bookmark' title='jQuery Quickie: 5 second Tooltip'>jQuery Quickie: 5 second Tooltip</a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Welcome to jQuery quickie, and here is where I share some of the jQuery goodness that is in something I have done for a project. Then again, there are still going to be those days where I just want to try something out to see if I can do it and post it. Either way, you&#8217;re going to be getting something to use and take away the need for a plugin in your project one at a time.</p>
<p>Today our quickie is on sticky sidebars. Its a pretty sloppy one this time around because I didn&#8217;t have the time I&#8217;d normally take to write this one, so I&#8217;ll update it in a part 2 post. Until that time comes, enjoy!</p>
<p>&nbsp;</p>
<p><iframe src="http://jsfiddle.net/bwTaP/1/embedded/" height="300" width="100%" allowfullscreen="allowfullscreen" frameborder="0"></iframe></p>
<div class='yarpp-related-rss'>
<p>Related posts:</p><ol>
<li><a href='http://www.5alarmint.com/jquicke/tab-navigation' rel='bookmark' title='jQuery Quickie: Tab Navigation'>jQuery Quickie: Tab Navigation</a></li>
<li><a href='http://www.5alarmint.com/jquicke/tag-filter' rel='bookmark' title='jQuery Quickie: Tag Filter'>jQuery Quickie: Tag Filter</a></li>
<li><a href='http://www.5alarmint.com/jquicke/tooltip' rel='bookmark' title='jQuery Quickie: 5 second Tooltip'>jQuery Quickie: 5 second Tooltip</a></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.5alarmint.com/jquicke/sticky-sidebar/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Breakdown: Object Oriented JS Pt. 2</title>
		<link>http://www.5alarmint.com/development/code-breakdown-js-pt2</link>
		<comments>http://www.5alarmint.com/development/code-breakdown-js-pt2#comments</comments>
		<pubDate>Thu, 09 May 2013 12:00:58 +0000</pubDate>
		<dc:creator>jamal</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[object oriented]]></category>
		<category><![CDATA[oop]]></category>

		<guid isPermaLink="false">http://www.5alarmint.com/?p=1814</guid>
		<description><![CDATA[What seems like a long time ago I posted this article which featured one of my early attempts at OOJS. Of course in the article I mentioned that we would be going over every detail of it, and be improving on it afterwards. Well, my schedule got busy and I forgot all about this one. [...]<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href='http://www.5alarmint.com/development/code-breakdown-js' rel='bookmark' title='Code Breakdown: Object Oriented JS'>Code Breakdown: Object Oriented JS</a></li>
<li><a href='http://www.5alarmint.com/101-series/js-cookies' rel='bookmark' title='Development 101: JS Cookies'>Development 101: JS Cookies</a></li>
<li><a href='http://www.5alarmint.com/jquicke/tab-navigation' rel='bookmark' title='jQuery Quickie: Tab Navigation'>jQuery Quickie: Tab Navigation</a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>What seems like a long time ago I <a href="http://wp.me/p2AP5c-pT">posted this article</a> which featured one of my early attempts at OOJS. Of course in the article I mentioned that we would be going over every detail of it, and be improving on it afterwards. Well, my schedule got busy and I forgot all about this one. Luckily though I remember now, and I&#8217;m in a really good JS mood. So without anymore waiting, lets get to this code!</p>
<p>&nbsp;</p>
<h3 style="text-align: center;">The Premise</h3>
<p>&nbsp;</p>
<p>So as I first began my trials with OOJS, really OOP in general, I came up with an idea that it would be much easier to learn if my learning would involve automating a task for myself. While I was having this eureka moment with my coding experience I was doing a little project management  work for client work I was doing at the time. If you add these two things together, then what do you get? You get a developer who writes the bare functionality of an app that can manage the time and budget of my projects for me.</p>
<p>Amazing right!</p>
<p>&nbsp;</p>
<h3 style="text-align: center;">The Code</h3>
<p>&nbsp;</p>
<pre><code class="language-javascript">
function Project(projName,endingAmount,totalHours,days,rate){
	this.projName = projName;
	this.endingAmount = endingAmount;
	this.totalHours = totalHours;
	this.days = days;
	this.rate = rate;
	this.hoursUsed = function(hours){
		var hoursToday = this.hoursToday;
		hoursToday += hours;
		var hoursLeft = this.totalHours - hoursToday;
		console.log("You've worked " + hours + "today");
		console.log("You've worked " + hoursToday + " total.");
		console.log("You have " + hoursleft + " remaining.");
	}
	this.hoursRemain = function(hours){
		console.log(this.totalHours);
	}
	this.amountLeft = function(){
		this.amountLeft = this.endingAmount - (this.hoursUsed * rate);
		if(this.amountLeft &gt; 0){
			console.log(this.amountLeft);
		}
		else{
			console.log("You workd overtime for the amount of " + Math.abs(this.amountLeft));
		}
	}
}</code></pre>
<p>If you want to play around with it yourself, just pop it in your favorite browser debug tool&#8217;s console and have fun! Of course its broken by the way <img src='http://www.5alarmint.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
<h3 style="text-align: center;">The Breakdown</h3>
<p>Now that all the cordial introductions are over, lets get to the breakdown!</p>
<h4>Constructor Class</h4>
<p>&nbsp;</p>
<pre><code class="language-javascript">
function Project(){

}
</code></pre>
<p>The Project function acts as a object constructor class. A constructor class is a function that is used to create new instances of an Project object. See below for examples.</p>
<pre><code class="language-javascript">
var AT&amp;T = new Project();
var MIEN = new Project();
var Apple = new Project();

</code></pre>
<p>&nbsp;</p>
<h4>Object Attributes</h4>
<p>&nbsp;</p>
<pre><code class="language-javascript">this.projName = projName;
this.endingAmount = endingAmount;
this.totalHours = totalHours;
this.days = days;
this.rate = rate;
</code></pre>
<p>The Project class takes in 5 parameters when trying to create a object, and these parameters are taken to be used as attributes of an instance of a project. These instance attributes are declared by setting a parameter to an instance of this.{attribute}.</p>
<h4>Object Methods</h4>
<p>&nbsp;</p>
<pre><code class="language-javascript">
this.hoursUsed = function(hours){
		var hoursToday = this.hoursToday;
		hoursToday += hours;
		var hoursLeft = this.totalHours - hoursToday;
		console.log("You've worked " + hours + "today");
		console.log("You've worked " + hoursToday + " total.");
		console.log("You have " + hoursleft + " remaining.");
	}
	this.hoursRemain = function(hours){
		console.log(this.totalHours);
	}
	this.amountLeft = function(){
		this.amountLeft = this.endingAmount - (this.hoursUsed * rate);
		if(this.amountLeft &gt; 0){
			console.log(this.amountLeft);
		}
		else{
			console.log("You workd overtime for the amount of " + Math.abs(this.amountLeft));
		}
	}

</code></pre>
<p>&nbsp;</p>
<p>The Project class has three methods for its object instances(hoursUsed, hoursRemain, and amountLeft). These methods are nothing more than object specific functions that can be called on an object created with the Project constructor. In theory the object methods used here do the following:</p>
<ul>
<li>the <em>hoursUsed</em> function takes in the amount of hours you used and reports it to you with your total and how much you have left</li>
<li>the <em>hoursRemain</em> function tells you how many hours you have left, and</li>
<li>the <em>amountLeft</em> function lets you know how much is left on the projects budget.</li>
</ul>
<p>&nbsp;</p>
<h3 style="text-align: center;">What&#8217;s Next</h3>
<p>Next up in the article that will be a lot sooner than this one is from the series starter post, we will go over why this Project constructor isn&#8217;t working and how to fix it.</p>
<div class='yarpp-related-rss'>
<p>Related posts:</p><ol>
<li><a href='http://www.5alarmint.com/development/code-breakdown-js' rel='bookmark' title='Code Breakdown: Object Oriented JS'>Code Breakdown: Object Oriented JS</a></li>
<li><a href='http://www.5alarmint.com/101-series/js-cookies' rel='bookmark' title='Development 101: JS Cookies'>Development 101: JS Cookies</a></li>
<li><a href='http://www.5alarmint.com/jquicke/tab-navigation' rel='bookmark' title='jQuery Quickie: Tab Navigation'>jQuery Quickie: Tab Navigation</a></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.5alarmint.com/development/code-breakdown-js-pt2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Weekly Inspiration #95</title>
		<link>http://www.5alarmint.com/inspiration/weekly-inspiration-95</link>
		<comments>http://www.5alarmint.com/inspiration/weekly-inspiration-95#comments</comments>
		<pubDate>Sun, 05 May 2013 14:32:03 +0000</pubDate>
		<dc:creator>jamal</dc:creator>
				<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[quote]]></category>

		<guid isPermaLink="false">http://www.5alarmint.com/?p=1805</guid>
		<description><![CDATA[Every Sunday I plan on posting a Weekly Inspiration post. This is where I showcase a song and quote that is inspiring my creative side for the upcoming week. &#160; The quote of the week is,&#8221;Challenge and difficulties are what make a journey memorable.&#8221; &#8211; Jamal Jackson The song of the week is Again&#38;Again by Holly [...]<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-68' rel='bookmark' title='Weekly Inspiration #68'>Weekly Inspiration #68</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-62' rel='bookmark' title='Weekly Inspiration #62'>Weekly Inspiration #62</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-88' rel='bookmark' title='Weekly Inspiration #88'>Weekly Inspiration #88</a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Every Sunday I plan on posting a Weekly Inspiration post. This is where I showcase a song and quote that is inspiring my creative side for the upcoming week.<span id="more-1805"></span></p>
<p>&nbsp;</p>
<p>The quote of the week is,&#8221;Challenge and difficulties are what make a journey memorable.&#8221; &#8211; Jamal Jackson</p>
<p>The song of the week is Again&amp;Again by <a href="http://en.wikipedia.org/wiki/Skylar_Grey">Holly Brook(Skyler Grey)</a></p>
<p><iframe src="http://www.youtube.com/embed/yY8j2CxfpQk" height="315" width="420" allowfullscreen="" frameborder="0"></iframe></p>
<div class='yarpp-related-rss'>
<p>Related posts:</p><ol>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-68' rel='bookmark' title='Weekly Inspiration #68'>Weekly Inspiration #68</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-62' rel='bookmark' title='Weekly Inspiration #62'>Weekly Inspiration #62</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-88' rel='bookmark' title='Weekly Inspiration #88'>Weekly Inspiration #88</a></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.5alarmint.com/inspiration/weekly-inspiration-95/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Guide on How to Earn Passive Income by Writing Tutorials</title>
		<link>http://www.5alarmint.com/freelance/passive-income-blogging</link>
		<comments>http://www.5alarmint.com/freelance/passive-income-blogging#comments</comments>
		<pubDate>Mon, 29 Apr 2013 14:30:47 +0000</pubDate>
		<dc:creator>jamal</dc:creator>
				<category><![CDATA[Freelance]]></category>
		<category><![CDATA[articles]]></category>
		<category><![CDATA[blogging]]></category>
		<category><![CDATA[freelance]]></category>
		<category><![CDATA[passive income]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.5alarmint.com/?p=1788</guid>
		<description><![CDATA[The freelancing lifestyle is defined by one word, uncertainty! As a freelance designer or developer you are building a company as a service provider, and that means you’ll experience times where no income is coming from your service. You aren’t going to have steady client work all the time. So how do you go about [...]<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href='http://www.5alarmint.com/tutorials/best-photshop-tutorials' rel='bookmark' title='Best Photshop Tutorials'>Best Photshop Tutorials</a></li>
<li><a href='http://www.5alarmint.com/freelance/considerations-freelancing' rel='bookmark' title='Considerations Before Freelancing'>Considerations Before Freelancing</a></li>
<li><a href='http://www.5alarmint.com/editorials/blogging-industry-downturn' rel='bookmark' title='Is the Blogging Industry In a Downturn?'>Is the Blogging Industry In a Downturn?</a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>The freelancing lifestyle is defined by one word, uncertainty! As a freelance designer or developer you are building a company as a service provider, and that means you’ll experience times where no income is coming from your service. You aren’t going to have steady client work all the time. So how do you go about to prepare for this, <strong>CREATE SOURCES OF PASSIVE INCOME! </strong>And what better way to do that than creating tutorials?</p>
<p>Creating tutorials is great even outside passive income because it gives you a chance to grow your name, showcase your talents to potential clients, and gets you active in the community. This is enough talking about doing, lets get to it!</p>
<p>&nbsp;</p>
<p><a href="http://www.1stwebdesigner.com/design/earn-passive-income-tutorial-blogging/">Continue reading this article on 1stwebdesigner</a></p>
<div class='yarpp-related-rss'>
<p>Related posts:</p><ol>
<li><a href='http://www.5alarmint.com/tutorials/best-photshop-tutorials' rel='bookmark' title='Best Photshop Tutorials'>Best Photshop Tutorials</a></li>
<li><a href='http://www.5alarmint.com/freelance/considerations-freelancing' rel='bookmark' title='Considerations Before Freelancing'>Considerations Before Freelancing</a></li>
<li><a href='http://www.5alarmint.com/editorials/blogging-industry-downturn' rel='bookmark' title='Is the Blogging Industry In a Downturn?'>Is the Blogging Industry In a Downturn?</a></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.5alarmint.com/freelance/passive-income-blogging/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Weekly Inspiration #94</title>
		<link>http://www.5alarmint.com/inspiration/weekly-inspiration-94</link>
		<comments>http://www.5alarmint.com/inspiration/weekly-inspiration-94#comments</comments>
		<pubDate>Sun, 28 Apr 2013 15:16:00 +0000</pubDate>
		<dc:creator>jamal</dc:creator>
				<category><![CDATA[Inspiration]]></category>
		<category><![CDATA[inspiration]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[quote]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://www.5alarmint.com/?p=1799</guid>
		<description><![CDATA[Every Sunday I plan on posting a Weekly Inspiration post. This is where I showcase a song and quote that is inspiring my creative side for the upcoming week. &#160; The quote of the week is &#8220;Individuality is an overcoming of pain derived being uninfluenced and full acceptance.&#8221; &#8211; Jamal Jackson Now instead of a song, [...]<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-80' rel='bookmark' title='Weekly Inspiration #80'>Weekly Inspiration #80</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-84' rel='bookmark' title='Weekly Inspiration #84'>Weekly Inspiration #84</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-60' rel='bookmark' title='Weekly Inspiration #60'>Weekly Inspiration #60</a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Every Sunday I plan on posting a Weekly Inspiration post. This is where I showcase a song and quote that is inspiring my creative side for the upcoming week.<span id="more-1799"></span></p>
<p>&nbsp;</p>
<p>The quote of the week is &#8220;Individuality is an overcoming of pain derived being uninfluenced and full acceptance.&#8221; &#8211; Jamal Jackson</p>
<p>Now instead of a song, I&#8217;m going to put a short film up. Its a great piece by the people over at <a href="https://twitter.com/WSPictures">WingSpan Pictures</a> out of Burbank, CA. It&#8217;s a great piece, and I hope you enjoy viewing it as well.</p>
<p>&nbsp;</p>
<p><iframe src="http://www.youtube.com/embed/XCoFoKvfc6Y" height="315" width="560" allowfullscreen="" frameborder="0"></iframe></p>
<div class='yarpp-related-rss'>
<p>Related posts:</p><ol>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-80' rel='bookmark' title='Weekly Inspiration #80'>Weekly Inspiration #80</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-84' rel='bookmark' title='Weekly Inspiration #84'>Weekly Inspiration #84</a></li>
<li><a href='http://www.5alarmint.com/inspiration/weekly-inspiration-60' rel='bookmark' title='Weekly Inspiration #60'>Weekly Inspiration #60</a></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.5alarmint.com/inspiration/weekly-inspiration-94/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Development 101: JS Cookies</title>
		<link>http://www.5alarmint.com/101-series/js-cookies</link>
		<comments>http://www.5alarmint.com/101-series/js-cookies#comments</comments>
		<pubDate>Mon, 22 Apr 2013 13:00:26 +0000</pubDate>
		<dc:creator>jamal</dc:creator>
				<category><![CDATA[101 Series]]></category>
		<category><![CDATA[browser trail]]></category>
		<category><![CDATA[dev]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[js]]></category>

		<guid isPermaLink="false">http://www.5alarmint.com/?p=1756</guid>
		<description><![CDATA[Remember back in class in college how the professor would be talking about what was on the outlined lesson plan for that session and out of nowhere they switched it up and started telling you a story related to the class? Well that is what this post today will be. I know I promised a [...]<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href='http://www.5alarmint.com/development/code-breakdown-js' rel='bookmark' title='Code Breakdown: Object Oriented JS'>Code Breakdown: Object Oriented JS</a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Remember back in class in college how the professor would be talking about what was on the outlined lesson plan for that session and out of nowhere they switched it up and started telling you a story related to the class? Well that is what this post today will be. I know I promised a little while ago that we would be going over databases, specifically MySQL, but I&#8217;m in a JavaScript(JS) mood and just gotta let it out.</p>
<p>That is why in this post we will do a quick crash into JS cookies. Sounds delicious right? Let&#8217;s go!!!!!!</p>
<p>&nbsp;</p>
<h3 style="text-align: center;">What Are Cookies?</h3>
<p>&nbsp;</p>
<p>Cookies are delicious baked goods that are great when oatmeal rasion! Okay seriously cookies are a tracking method used to give off a temporary trail of where a user of a website has been. For an example think of when you login to a site, it can be anything from Amazon to your favorite online shop. After you&#8217;ve logged in go ahead and delete all your cookies. Now when you go back to that site you&#8217;ll likely be logged out, don&#8217;t worry if your not because we&#8217;ll be covering that later.</p>
<p>What you just did was when you removed your cookies is delete the temporary data that they hold. Now don&#8217;t cookies sound fun? Let&#8217;s get to making some.</p>
<p>&nbsp;</p>
<h3 style="text-align: center;">Creating Cookies</h3>
<p>&nbsp;</p>
<pre><code class="language-javascript">
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i &lt; ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function eraseCookie(name) {
  createCookie(name,"",-1);
}

</code></pre>
<p>Well that looks pretty fun and easy right? Thanks to the people at <a href="http://www.quirksmode.org/js/cookies.html">Quirksmode.com</a>. Okay let&#8217;s take some time and go over what is happening with all these JS functions.</p>
<h4>createCookie</h4>
<p>&nbsp;</p>
<pre><code class="language-javascript">
function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else var expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}
</code></pre>
<p>&nbsp;</p>
<p>What this function here is doing should be pretty obvious from its name, but lets take a minute to break down how this is happening. It takes in three values for the cookie: name, value, and days. What this does is set what you&#8217;ll name the cookie, what value the cookie should store, and how long it should last. So everything here should be pretty straightforward, except for what is going on with the days value. So let&#8217;s break that down a little further.</p>
<p>Okay so when you want to first get minutes. As we all know there are 60 seconds in a minute, but in development we count with milliseconds and there are 1000 milliseconds in a second. So that explains the 60*1000. Moving on to the 60 next to it, that is used to get the number of milliseconds in an hour. The 24 after that is used to get the number of milliseconds in a day, and the days value you passed into the function is the number of days you want this cookie to last.</p>
<h4>readCookie</h4>
<p>&nbsp;</p>
<pre><code class="language-javascript">
function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i &lt; ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}
</code></pre>
<p>&nbsp;</p>
<p>What readCookie is doing here is taking the name of the cookie your trying to find the value of of, it then uses that to search through all cookies that are set in your browser by first storing them into an array and searching through that array. If nothing is able to be found, this function will return null.</p>
<h4>eraseCookie</h4>
<p>&nbsp;</p>
<pre><code class="language-javascript">
function eraseCookie(name) {
  createCookie(name,"",-1);
}
</code></pre>
<p>&nbsp;</p>
<p>The eraseCookie function is a great example of DRY(Don&#8217;t Repeat Yourself) programming. It is using the already defined function createCookie to delete cookies by passing in the name of the cookie, setting its value to an empty string, and giving it the amount of days for it to last to a negative number so it will be expired.</p>
<div class='yarpp-related-rss'>
<p>Related posts:</p><ol>
<li><a href='http://www.5alarmint.com/development/code-breakdown-js' rel='bookmark' title='Code Breakdown: Object Oriented JS'>Code Breakdown: Object Oriented JS</a></li>
</ol>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.5alarmint.com/101-series/js-cookies/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
