<?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>36Flavours.com &#187; js</title>
	<atom:link href="http://36flavours.com/tag/js/feed/" rel="self" type="application/rss+xml" />
	<link>http://36flavours.com</link>
	<description>A taste of something different...</description>
	<lastBuildDate>Mon, 19 Apr 2010 20:01:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Today I wrote my first JavaScript tutorial</title>
		<link>http://36flavours.com/2009/09/today-i-wrote-my-first-javascript-tutorial/</link>
		<comments>http://36flavours.com/2009/09/today-i-wrote-my-first-javascript-tutorial/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 08:50:15 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[first]]></category>
		<category><![CDATA[fubra]]></category>
		<category><![CDATA[help]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[sixcrayons]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://36flavours.com/?p=370</guid>
		<description><![CDATA[Today saw the launch of SixCrayons.com, a new design blog focussing on six main categories of front end web development, from design to additional enhancements using scripting languages such as Flash and JavaScript. Although I have a hand in the majority of categories, JavaScript is something I have a keen interest in and was asked [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Today saw the launch of <a href="http://sixcrayons.com/" target="_blank">SixCrayons.com</a>, a new design blog focussing on six main categories of front end web development, from design to additional enhancements using scripting languages such as Flash and JavaScript.</p>
<p>Although I have a hand in the majority of categories, JavaScript is something I have a keen interest in and was asked to write a short tutorial on a JS related subject.<span id="more-370"></span></p>
<p><img class="aligncenter size-full wp-image-373" title="SixCrayons.com" src="http://36flavours.com/wp-content/uploads/2009/09/sixcrayons.png" alt="SixCrayons.com" width="600" height="430" /></p>
<p>It took me a while to think of something to base the blog post on, but it eventually coincided well with something I needed for another project I am currently working on.</p>
<p>We&#8217;ve all seen the use of pre-filled input areas, where a faded description or hint of what should be entered by the user is inserted into the input and disappears when it is clicked on.</p>
<p>I am a big <a href="http://jquery.com/" target="_blank">jQuery</a> fan, so writing a plug-in to solve the issue I had seemed like a good solution, so wrote the first draft of my plug-in whilst trying to describe what was happening along the way.</p>
<p>Hopefully what I&#8217;ve written is fairly simple to follow but it is my first attempt at writing a tutorial of this length and detail, so if you have any hints or comments (aka constructive criticism) then do let me know <img src='http://36flavours.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
<p>Head over to SixCrayons and have a scan through my tutorial on writing <a href="http://sixcrayons.com/2009/09/10/a-simple-jquery-input-hint-plug-in/" target="_blank">a simple jQuery input hint plug-in</a>, or even just browse through the other categories.</p>
<p style="text-align: center;"><a href="http://sixcrayons.com/2009/09/10/a-simple-jquery-input-hint-plug-in/" target="_blank"><img class="aligncenter size-full wp-image-372" title="Simple jQuery input hint plug-iin" src="http://36flavours.com/wp-content/uploads/2009/09/sixcrayons_inputhint.png" alt="Simple jQuery input hint plug-iin" width="596" height="251" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/09/today-i-wrote-my-first-javascript-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS preload image &#039;bug&#039; in Opera</title>
		<link>http://36flavours.com/2009/03/js-preload-image-bug-in-opera/</link>
		<comments>http://36flavours.com/2009/03/js-preload-image-bug-in-opera/#comments</comments>
		<pubDate>Mon, 02 Mar 2009 14:48:39 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[preload]]></category>

		<guid isPermaLink="false">http://sha.re.it/?p=181</guid>
		<description><![CDATA[I have recently attempted to load an image in JavaScript (using jQuery) and once loaded get it&#8217;s dimensions. Using the following code I managed to successfully read the width and height properties in FireFox 2/3, IE 6/7, Windows Safari 3/4 and Google Chrome, but the dimensions were not available in Opera (10). $&#40;'&#60;img alt=&#34;&#34; /&#62;'&#41; [...]]]></description>
			<content:encoded><![CDATA[<p class="first">I have recently attempted to load an image in JavaScript (using <a href="http://jquery.com/">jQuery</a>) and once loaded get it&#8217;s dimensions.</p>
<p>Using the following code I managed to successfully read the width and height properties in <a href="http://www.mozilla-europe.org/en/firefox/">FireFox</a> 2/3, <a href="http://www.microsoft.com/windows/products/winfamily/ie/default.mspx">IE</a> 6/7, <a href="http://www.apple.com/safari/download/">Windows Safari</a> 3/4 and <a href="http://www.google.co.uk/chrome/">Google Chrome</a>, but the dimensions were not available in <a href="http://www.opera.com/">Opera</a> (10).<span id="more-181"></span></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;img alt=&quot;&quot; /&gt;'</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">load</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: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</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: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> w <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">width</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> h <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">height</span><span style="color: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//..</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">error</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: #006600; font-style: italic;">//..</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'/path/to/image.jpg'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>After a fair bit of time playing around trying to debug this small snippet of code, I <em>eventually</em> discovered that if the image was appended to the DOM <strong>after</strong> the width and height had been read then Opera would report the values correctly.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">		<span style="color: #003366; font-weight: bold;">var</span> w <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">width</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> h <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">height</span><span style="color: #339933;">;</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'body'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">append</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: #339933;">;</span>
		<span style="color: #006600; font-style: italic;">//..</span></pre></div></div>

<p>Simply moving line 3 down to below the reading of dimensions solved this issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/03/js-preload-image-bug-in-opera/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple jQuery string padding function</title>
		<link>http://36flavours.com/2009/02/simple-jquery-string-padding-function/</link>
		<comments>http://36flavours.com/2009/02/simple-jquery-string-padding-function/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 12:27:57 +0000</pubDate>
		<dc:creator>Steve Whiteley</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[str_pad]]></category>

		<guid isPermaLink="false">http://sha.re.it/?p=142</guid>
		<description><![CDATA[I&#8217;ve written a very simple jQuery function to return a string padded to a specified length, similar to the php equivalent str_pad. 1 2 3 4 5 6 7 8 $.strPad = function&#40;i,l,s&#41; &#123; var o = i.toString&#40;&#41;; if &#40;!s&#41; &#123; s = '0'; &#125; while &#40;o.length &#60; l&#41; &#123; o = s + o; [...]]]></description>
			<content:encoded><![CDATA[<p class="first">I&#8217;ve written a very simple <a href="http://jquery.com/" target="_blank">jQuery</a> function to return a string padded to a specified length, similar to the php equivalent <a href="http://uk2.php.net/manual/en/function.str-pad.php" target="_blank">str_pad</a>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">strPad</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">,</span>l<span style="color: #339933;">,</span>s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> o <span style="color: #339933;">=</span> i.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><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>s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> s <span style="color: #339933;">=</span> <span style="color: #3366CC;">'0'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>o.<span style="color: #660066;">length</span> <span style="color: #339933;">&lt;</span> l<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		o <span style="color: #339933;">=</span> s <span style="color: #339933;">+</span> o<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000066; font-weight: bold;">return</span> o<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Example Usage:</p>
</pre>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">strPad</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">12</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns 00012</span>
$.<span style="color: #660066;">strPad</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'abc'</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">6</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// returns ###abc</span></pre></div></div>

<p>This version only supports left padding, which is why it is labelled as only a simple version <img src='http://36flavours.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .</p>
]]></content:encoded>
			<wfw:commentRss>http://36flavours.com/2009/02/simple-jquery-string-padding-function/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
