<?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>Ryan Rampersad &#187; JavaScript</title>
	<atom:link href="http://blog.ryanrampersad.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ryanrampersad.com</link>
	<description>Thoughts, Ideas &#38; Opinions</description>
	<lastBuildDate>Thu, 17 May 2012 17:11:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-beta4-20825</generator>
		<item>
		<title>★ POST 405 (Method Not Allowed)</title>
		<link>http://blog.ryanrampersad.com/2011/05/23/post-405-method-not-allowed/</link>
		<comments>http://blog.ryanrampersad.com/2011/05/23/post-405-method-not-allowed/#comments</comments>
		<pubDate>Mon, 23 May 2011 18:30:14 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=3320</guid>
		<description><![CDATA[I was attempting to XHR a simple plain text file. MooTools sets the default request method to post. On my local testing development machine, it wasn&#8217;t a problem, but out in the wild on my 1and1 server, apparently post cannot be used to get a text file. I recived this error from the console. POST [...]]]></description>
			<content:encoded><![CDATA[<p>I was attempting to XHR a simple plain text file. <a href="http://mootools.net/docs/core/Request/Request">MooTools</a> sets the default request method to <em>post</em>. On my local testing development machine, it wasn&#8217;t a problem, but out in the wild on my 1and1 server, apparently <em>post</em> cannot be used to <em>get</em> a text file. I recived this error from the console.</p>
<blockquote><p>POST http://ifupdown.com/app/manifest/m.txt 405 (Method Not Allowed)</p></blockquote>
<p>I <a href="http://www.google.com/search?sourceid=chrome&#038;ie=UTF-8&#038;q=POST+http%3A%2F%2Fifupdown.com%2Fdnc%2Ftext.txt+405+(Method+Not+Allowed)">searched for the error</a> of course but there were shockingly few results. I reasoned though that it had something to do with using <em>post</em> to get a non-server interacting document. I overrode my request object in MooTools to use <em>get</em>.</p>
<pre class="brush: jscript; title: ; notranslate">
var r = new Request({url: &quot;manifest/m.txt&quot;});
// ... onComplete, onError, other goodies
r.post(); // won't work on 1and1 for some reason
r.get(); // will work perfectly
</pre>
<p>And with that, I uploaded it back to the server and it was error free! 1and1 blocks post-requests to regular text files, so just watch out for it. Requesting via <em>post</em> a PHP file is just fine though. Oh, the mysteries.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/05/23/post-405-method-not-allowed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ Replace Line Endings in JavaScript</title>
		<link>http://blog.ryanrampersad.com/2011/05/16/replace-line-endings-in-javascript/</link>
		<comments>http://blog.ryanrampersad.com/2011/05/16/replace-line-endings-in-javascript/#comments</comments>
		<pubDate>Mon, 16 May 2011 18:05:37 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=3310</guid>
		<description><![CDATA[I was bringing text in via XHR and I needed to replace the natural \n line endings with a true &#60;br /&#62; break line so that it would be legitimate HTML when injected into the DOM. It&#8217;s pretty easy, but you just need to remember: replace returns! Since there are multiple versions of line endings, [...]]]></description>
			<content:encoded><![CDATA[<p>I was bringing text in via XHR and I needed to replace the natural <code>\n</code> line endings with a true <code>&lt;br /&gt;</code> break line so that it would be legitimate HTML when injected into the DOM. It&#8217;s pretty easy, but you just need to remember: <em>replace returns</em>!</p>
<p>Since there are multiple versions of line endings, like Unix <code>\n</code> but also Windows <code>\r\n</code> and Mac&#8217;s old <code>\r</code>, you need to replace them all just to keep your bases covered. It&#8217;s all pretty easy.</p>
<pre class="brush: jscript; title: ; notranslate">
var string = 'this is a sentence.\r\n and this is another sentence about nothing!';

// notice that is reassigned? .replace returns!
string = string.replace(/(\r\n|\n|\r)/gm, &quot;&lt;br /&gt;&quot;);

console.log(string);
</pre>
<p>This code is simple. Just a string with a line ending followed by a replace statement. I make an explicit note that <code>replace</code> will return the new string, not simply mutate it in place. This caused me a bit of confusion. Also note that the <em>gm</em> at the end of the regular expression means that it will match globally and over different lines, just in case.</p>
<p>You can read the <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/Replace">MDC documentation about String.replace</a> too.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/05/16/replace-line-endings-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ Factorial in Java Script</title>
		<link>http://blog.ryanrampersad.com/2011/03/19/factorial-in-java-script/</link>
		<comments>http://blog.ryanrampersad.com/2011/03/19/factorial-in-java-script/#comments</comments>
		<pubDate>Sat, 19 Mar 2011 18:57:22 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=2678</guid>
		<description><![CDATA[A factorial is a series of integers multiplied together. You might remember 1 * 2 * 3 * 4 * 5 * &#8230; * (n-1) * n. That&#8217;s a factorial. Traditionally, a factorial can be presented in just about any programming language easily with a tiny bit of recursion. The real problem though is the [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://en.wikipedia.org/wiki/Factorial">factorial</a> is a series of integers multiplied together. You might remember <em>1 * 2 * 3 * 4 * 5 * &#8230; * (n-1) * n</em>. That&#8217;s a factorial. Traditionally, a factorial can be presented in just about any programming language easily with a tiny bit of recursion. The real problem though is the percision at which factorials can be stored. For instance, just <em>15!</em> (that is 15 factorial) yields a gigantic <em>1,307,674,368,000</em>. Java Script can certainly store large numbers but even then there is a major limit. Imagine <em>100!</em>.</p>
<p><a href="http://blog.ryanrampersad.com/wp-content/uploads/2010/10/js-factorial-recursion.png"><img src="http://blog.ryanrampersad.com/wp-content/uploads/2010/10/js-factorial-recursion.png" alt="" title="Factorial - Recursion - Java Script" width="325" height="534" class="aligncenter size-full wp-image-2679" /></a></p>
<p>In Java Script, you can easily make a factorial function.</p>
<pre class="brush: jscript; title: ; notranslate">
  function factorial(n) {
    if ( n &lt;= 1 ) return 1;
    return n * factorial(n-1);
  }
</pre>
<p>Let&#8217;s break down the function. The first line establishes the odd case of zero-factorial, the case where it turns out to be one. Secondly, it accounts for one-factorial which is also one. The second line contains the recursion that everyone is so fond of. You take some value of &#8220;n&#8221; and multiply it against the value of the value recursed from subsequent factorials.</p>
<p>There&#8217;s not really an easier and more meaningful example of recursion than the factorial.</p>
<p>Happy factorialing.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2011/03/19/factorial-in-java-script/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ My First MooTools Presentation</title>
		<link>http://blog.ryanrampersad.com/2010/08/25/my-first-mootools-presentation/</link>
		<comments>http://blog.ryanrampersad.com/2010/08/25/my-first-mootools-presentation/#comments</comments>
		<pubDate>Wed, 25 Aug 2010 18:12:19 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=2178</guid>
		<description><![CDATA[On Thursday, May 27th, I gave my very first MooTools presentation to an eagerly awaiting AP Computer Science class. The presentation was in three parts, the first a general overview of javascript itself, the second a micro-guide to MooTools glowing finesse with elements, events and effects, and finally a complete section on MooTools classes to [...]]]></description>
			<content:encoded><![CDATA[<p>On Thursday, May 27<sup>th</sup>, I gave my very first MooTools presentation to an eagerly awaiting AP Computer Science class. The presentation was in three parts, the first a general overview of javascript itself, the second a micro-guide to MooTools glowing finesse with elements, events and effects, and finally a complete section on MooTools classes to compared to those in Java.</p>
<p><a href="http://blog.ryanrampersad.com/wp-content/uploads/2010/07/mootools-first-slide.png"><img src="http://blog.ryanrampersad.com/wp-content/uploads/2010/07/mootools-first-slide.png" alt="An introduction slide for my first mootools presentation" title="First Slide" width="580" height="385" class="aligncenter size-full wp-image-2348" /></a></p>
<p>The <a href="http://mootools.net/">MooTools website</a>, the <a href="http://mootorial.com/wiki/">MooTorial</a> and the <a href="http://walkthrough.ifupdown.com/">mooWalkthrough</a> all made appearances, giving extra credit to the third as my own project.</p>
<p>The presentation in all was 54 slides and lasted about 52 minutes with a Q&amp;A segment. The content in the presentation was in fact enough to get the class to work on a not-too-rudimentary project involving MooTools the next day. </p>
<h2>The Presentation</h2>
<div class="aligncenter" style="width:425px" id="__ss_5050993"><strong style="display:block;margin:12px 0 4px"><a href="http://www.slideshare.net/ryanrampersad/ap-computer-science-mootools-presentation" title="AP Computer Science MooTools Presentation">AP Computer Science MooTools Presentation</a></strong><object id="__sse5050993" width="425" height="355"><param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mootools-100825003039-phpapp02&#038;stripped_title=ap-computer-science-mootools-presentation" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed name="__sse5050993" src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=mootools-100825003039-phpapp02&#038;stripped_title=ap-computer-science-mootools-presentation" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="padding:5px 0 12px">View more <a href="http://www.slideshare.net/">presentations</a> from <a href="http://www.slideshare.net/ryanrampersad">Ryan Rampersad</a>.</div>
</div>
<p>You can also download the <a href="http://blog.ryanrampersad.com/wp-content/uploads/2010/07/MooTools.pdf">PDF</a> or the <a href="http://blog.ryanrampersad.com/wp-content/uploads/2010/07/MooTools.pptx">PPTX</a>. <em>(If I wasn&#8217;t poor, I would have used Keynote.)</em></p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2010/08/25/my-first-mootools-presentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>★ missing argument 1 when calling function mutator.call</title>
		<link>http://blog.ryanrampersad.com/2010/06/25/missing-argument-1-when-calling-function-mutator-call/</link>
		<comments>http://blog.ryanrampersad.com/2010/06/25/missing-argument-1-when-calling-function-mutator-call/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 08:20:37 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[Errors]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[errors]]></category>
		<category><![CDATA[solution]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=2241</guid>
		<description><![CDATA[I&#8217;ve been doing some hefty MooTools development lately, and I ran into a odd ball error in that endeavor. I put it aside for a while, ignoring it while I worked on other code. Eventuallly, I had to face it though, so here are my remarks in that journey. First, the error in question is [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been doing some hefty <a href="http://mootools.net">MooTools</a> development lately, and I ran into a odd ball error in that endeavor. I put it aside for a while, ignoring it while I worked on other code. Eventuallly, I had to face it though, so here are my remarks in that journey.</p>
<p>First, the error in question is formally given in Firefox/Firebug as follows:</p>
<blockquote><p>
missing argument 1 when calling function mutator.call<br />
value = mutator.call(this, value);<br />
mootoo&#8230;e-nc.js (line 1226)
</p></blockquote>
<p><span id="more-2241"></span></p>
<p>I&#8217;m not a MooTools source code expert but I&#8217;ve read through it, so I remembered that that mutator business had something to do with class creation. That didn&#8217;t help much. I brought this to the attention of those in the IRC channel, and while most of the people were sleeping or busy, I got one helpful hand.</p>
<blockquote title="from the mootools irc channel on freenode"><p>
 15:47:08 | &lt;d_mitar&gt; odd<br />
 15:47:11 | &lt;d_mitar&gt; works in chrome<br />
 15:47:49 | &lt;ryanmr&gt; I didn&#8217;t realize :) it didn&#8217;t used to work there either<br />
 15:48:51 | &lt;d_mitar&gt; if you set a breakpoint on the mutator call<br />
 15:49:01 | &lt;d_mitar&gt; and are very patient<br />
 15:49:08 | &lt;d_mitar&gt; you can trace it :D<br />
 15:49:24 | &lt;ryanmr&gt; I traced it back to Cookie but I never used Cookie :D<br />
 15:49:48 | &lt;d_mitar&gt; does mcl use it? hrm<br />
 15:49:54 | &lt;d_mitar&gt; shouldnt do<br />
 15:50:05 | &lt;ryanmr&gt; nope<br />
 15:51:05 | &lt;ryanmr&gt; when I step through the stack, I trace it back to the dispose method of cookie.
</p></blockquote>
<p>I certainly did attempt to add a break point to the mutator line, but it didn&#8217;t get me far. I ended up at cookie every time, so there again, I was stuck. So <a href="http://twitter.com/ryanmr/statuses/16956427722">I asked on twitter</a> too, but no luck there.</p>
<p>After working hard to patch some holes in my basement&#8217;s concrete, I came back to this conundrum. I decided to look over my code, and comment each class out as nessesary. That took quite a while, but I narrowed it down to an Observer class. It observes whatever items you attach to it, and then adds some events to reorder the items when certain conditions are met. If I commented out that specific class, the <em>missing argument 1 when calling function mutator.call</em> error would go away. I then tried to comment out all of the actual method bodies to see if I had some to do with it, but it appeared that wasn&#8217;t the case.</p>
<p>So then I went to <a href="http://jsfiddle.net/">jsfiddle </a>to write up some cleaner tests. The <a href="http://jsfiddle.net/5Z5mM/1/">first test was an almost exact copy</a> of my project code, with a few minor (non-error causing) bits of logic absent. Once I hit run after writing it up, I got the error! So my enviroment wasn&#8217;t causing the problem either.</p>
<p>The<a href="http://jsfiddle.net/5Z5mM/2/"> second version was error free</a>. I suspected reserved method names, similar to the way <code>initialize</code> is reserved for MooTools, had something to do with it. So I changed all of the method names, except <code>initialize</code> to end with an <code>XXX</code>. That clearly did something to solve the problem, as in Firefox, it was no longer showing that error at all. To narrow down which method was reserved or forbidden, I added the X&#8217;s to each one at a time. It appeared then that <code>watch</code> could not be a method without trouble.</p>
<p>So I wanted an even cleaner example, without all that classy cruft. So I ran the following two lines of code in the Firebug console:</p>
<blockquote>
<pre>
var c = new Class({initialize: function(){}});
var x = new c();
console.log(x.watch);
</pre>
</blockquote>
<p>That of course, confirm my suspicions. Firebug claimed that <code>watch()</code> was indeed a method &#8211; a native method. I <a href="http://twitter.com/ryanmr/statuses/16997250146">tweeted about this with a screenshot</a>. I ran the same code in Chrome (since the project code <em>was</em> working there, I wasn&#8217;t worried) and I <a href="http://twitter.com/ryanmr/statuses/16997539061">tweeted another screenshot with the results</a> &#8211; no problem.</p>
<p>It occured to me then to <a href="http://www.google.com/search?q=Firefox+watch+method">google <em>firefox watch method</em></a>. I made my way to the <a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Object/watch">MDC&#8217;s watch page</a>. It&#8217;s a non-standard apparently and the purpose is:</p>
<blockquote><p>
Watches for a property to be assigned a value and runs a function when that occurs.
</p></blockquote>
<p>I wouldn&#8217;t have expected that from some random method called watch. </p>
<p>The solution was now clear, I needed to rename my watch method. That is the fix. To fix the <strong>missing argument 1 when calling function mutator.call</strong> error when using MooTools in Firefox, do not use the <code>watch</code> method in your code. Instead, try <a href="http://thesaurus.com/browse/watch">a synonym</a> such as: observe, look, peer, listen, view or stare.</p>
<p>That was my wonderful adventure for the 24th and 25th of June, 2010. Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2010/06/25/missing-argument-1-when-calling-function-mutator-call/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>★ INDEX_SIZE_ERR: DOM Exception 1 &#8211; HTML Canvas</title>
		<link>http://blog.ryanrampersad.com/2010/06/04/index_size_err-dom-exception-1-html-canvas/</link>
		<comments>http://blog.ryanrampersad.com/2010/06/04/index_size_err-dom-exception-1-html-canvas/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 22:23:10 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=2199</guid>
		<description><![CDATA[Lately, I have been working with the fancy HTML 5 canvas element. One of the errors that I encountered during development was this oddity: Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1 After making sure every value was absolutely defined in the code and still getting the error, I was stumped. I asked on twitter what causes [...]]]></description>
			<content:encoded><![CDATA[<p>Lately, I have been working with the fancy HTML 5 canvas element.</p>
<p>One of the errors that I encountered during development was this oddity:</p>
<blockquote><p>Uncaught Error: INDEX_SIZE_ERR: DOM Exception 1</p></blockquote>
<p>After making sure every value was absolutely defined in the code and still getting the error, I was stumped. I asked on twitter what causes this error, but I didn&#8217;t get a response so I moved on to google. A <a href="http://stackoverflow.com/questions/2444073/javascript-uncaught-error-index-size-err-dom-exception-1">thread on stackoverflow provided</a> this insight:</p>
<blockquote><p>It happens because circlesR values can become negative at some point. The radius of a circle cannot be negative.</p></blockquote>
<p>This holds true for just about any canvas drawing method. I was using <code>drawImage</code> to draw a sliced up image on to the canvas. The error is alerting you to a negative value in one of the numeric arguments in whatever drawing method was called.</p>
<pre class="brush: jscript; title: ; notranslate">
ctx.drawImage(this.avatar, xAxis, yAxis,
			32, 64,
			this.position.x, this.position.y,
			32, 64);
</pre>
<p>It turns out that my xAxis was negative for some calls. That borked canvas and instead of just saying, <em>there is a negative number in your drawImage call, drawImage cannot accept negative numbers,</em> it gave an index size error.</p>
<p>So in short, make sure you don&#8217;t use negative numbers in any canvas calls. To make it easier, just use <code>console.log</code> and copy the arguments of the drawing call and put them inside an array.</p>
<p>Good luck with canvas!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2010/06/04/index_size_err-dom-exception-1-html-canvas/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>★ Invalid Object Initialization</title>
		<link>http://blog.ryanrampersad.com/2010/02/08/invalid-object-initialization/</link>
		<comments>http://blog.ryanrampersad.com/2010/02/08/invalid-object-initialization/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 22:30:40 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[errors]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=1949</guid>
		<description><![CDATA[Firebug will scream and shout about Invalid Object Initialization if you mess just a little something up. Firebug does this a lot. It is an unhelpful error because Firebug will direct you to the first line of your object, not where the problem is. Firebug gave me this, more or less. That wasn&#8217;t helpful. (Why [...]]]></description>
			<content:encoded><![CDATA[<p>Firebug will scream and shout about <strong>Invalid Object Initialization</strong> if you mess just a little something up. <a href="http://blog.ryanrampersad.com/2008/09/06/syntax-error-break-on-this-error-doctype-html-public-w3cdtd-xhtml3orgtr-xhtml1-dtd-xhtml1-strictdtd/">Firebug does this a lot</a>. It is an unhelpful error because Firebug will direct you to the first line of your object, not where the problem is.</p>
<p>Firebug gave me this, more or less. That wasn&#8217;t helpful. (Why did Firebug get full, anyway?)</p>
<blockquote><p>Firebug&#8217;s log limit has been reached. 0 entries not shown. Preferences <strong>invalid object initializer</strong>[Break on this error]</p></blockquote>
<p>Let&#8217;s say you have some code, and it looks like this.</p>
<pre class="brush: jscript; title: ; notranslate">
 var TranslationStrings = {
  onAdd: &quot;Do you want to add this?&quot;,
  onDelete, &quot;Do you want to delete this?&quot;
 };
</pre>
<p>If you don&#8217;t notice the mistake in the object, Firebug will. It&#8217;s just a little something. It is a <em>comma</em>.</p>
<p>The <code>onDelete, "Do...."</code> should have a colon between the key-value pair. Not a comma, those go after a pair. It should be formed like so, <code>onDelete: "Do..."</code>.</p>
<p>So remember, watch out for those javascript object literals with commas and colons.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2010/02/08/invalid-object-initialization/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>★ Javascript let</title>
		<link>http://blog.ryanrampersad.com/2009/11/24/javascript-let/</link>
		<comments>http://blog.ryanrampersad.com/2009/11/24/javascript-let/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 00:56:05 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=1695</guid>
		<description><![CDATA[Mozilla offers a let in javascript 1.7. The let keyword isn&#8217;t support by other browsers yet so using it isn&#8217;t generally recomended but it nice to catch up on the latest javascript constructs. A Parallel First, a parallel. I&#8217;ve coded in Java the last couple of months because of school. During said time, I discovered [...]]]></description>
			<content:encoded><![CDATA[<p>Mozilla offers a <strong>let</strong> in javascript 1.7. The let keyword isn&#8217;t support by other browsers yet so using it isn&#8217;t generally recomended but it nice to catch up on the latest javascript constructs.</p>
<h3>A Parallel</h3>
<p>First, a parallel. I&#8217;ve coded in Java the last couple of months because of school. During said time, I discovered scoped blocks in Java. A scoped block might be like this:</p>
<pre class="brush: java; title: ; notranslate">
public void myMethod() {
  int i = 100, j = 10;
  {
    int k = i * j;
    i = 10;
    j = 10;
  }
  // cannot reference k from here
}
</pre>
<p>If you&#8217;re a java programmer, you might never have seen this happen before. Basically, putting floating brackets, as long as they match up, around arbitrary code, it will be in a different scope. <em>k</em> won&#8217;t be accessible from the outside of those brackets. I call these structures scoped blocks.</p>
<h3>Now back to <em>javascript</em></h3>
<p><em>let</em> in javascript acts similarly to the scoped blocks mentioned above.</p>
<p>Using <em>let</em> as a block is similar to the scoped block in java. The let-block won&#8217;t allow g to be accessed from the outside, x and m are newly bound values, they will only be around in the block scope.</p>
<pre class="brush: jscript; title: ; notranslate">
 var i = 100, j = 10;
 let (x = 10+i, m = j + 5) {
   var g = x + m;
 }
</pre>
<p>let might make it easy to bind <em>this</em> to another variable in a certain scope, which could prove useful.</p>
<p>For more information about let, checkout the <a href="https://developer.mozilla.org/En/New_in_JavaScript_1.7">MDC page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2009/11/24/javascript-let/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>★ Stop console.log errors without deleting each call</title>
		<link>http://blog.ryanrampersad.com/2009/10/28/stop-console-log-errors-without-deleting-each-call/</link>
		<comments>http://blog.ryanrampersad.com/2009/10/28/stop-console-log-errors-without-deleting-each-call/#comments</comments>
		<pubDate>Wed, 28 Oct 2009 18:44:10 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[firebug]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=1573</guid>
		<description><![CDATA[Have you ever added a couple of console.log calls to your javascript, test it in Firefox, then go into Internet Explorer and see tons of mysterious errors popup? I sure have, I always forget about those console.logs that are interwoven in my code. While it isn&#8217;t hard to do a replace on them all, I [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever added a couple of <em>console.log</em> calls to your javascript, test it in Firefox, then go into Internet Explorer and see tons of mysterious errors popup? I sure have, I always forget about those <em>console.log</em>s that are interwoven in my code. While it isn&#8217;t hard to do a replace on them all, I usually want to keep them where they are.<br />
<div id="attachment_1575" class="wp-caption alignright" style="width: 310px"><a href="http://blog.ryanrampersad.com/wp-content/uploads/2009/10/firebug.png"><img src="http://blog.ryanrampersad.com/wp-content/uploads/2009/10/firebug-300x86.png" alt="Firebug" title="Firebug" width="300" height="86" class="size-medium wp-image-1575" /></a><p class="wp-caption-text">Firebug</p></div></p>
<p>I recently came up with a solution to this problem, <a title="If you don't want to include another script, the new one is better." href="http://blog.ryanrampersad.com/2008/08/29/stop-firebug-console-log-errors/">different from the one I wrote about before</a>. I wrote a little function called <em>log</em>. As you can see, it is the simplest thing in the world.</p>
<pre class="brush: jscript; title: ; notranslate">
function log(arg) {
 console.log(arg);
}
</pre>
<p>So what&#8217;s the big deal? Let me explain. If you&#8217;re testing in Firefox with Firebug, you won&#8217;t notice much difference. But if you need to test in Internet Explorer now, you can just comment one line, that internal <em>console.log</em> which is faster and easier than commenting out all of them by hand.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2009/10/28/stop-console-log-errors-without-deleting-each-call/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>★ GoodCarousel &#8211; A Carousel with Mootools</title>
		<link>http://blog.ryanrampersad.com/2009/10/24/goodcarousel-a-carousel-with-mootools/</link>
		<comments>http://blog.ryanrampersad.com/2009/10/24/goodcarousel-a-carousel-with-mootools/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 00:30:27 +0000</pubDate>
		<dc:creator>Ryan</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[unified]]></category>

		<guid isPermaLink="false">http://blog.ryanrampersad.com/?p=1487</guid>
		<description><![CDATA[Hey there. I&#8217;m trying to get this plugin into the Mootools Forge but I&#8217;ve been having a hard time getting it to work. So in the mean time, checkout the repository on github. GoodCarousel is a plugin made with Mootools 1.2.3. It is made to slide over to, not fade to, the next slide and [...]]]></description>
			<content:encoded><![CDATA[<div class="note">Hey there. I&#8217;m trying to get this plugin into the <a href="http://mootools.net/forge/">Mootools Forge</a> but I&#8217;ve been having a hard time getting it to work. So in the mean time, checkout the repository on <a href="http://github.com/ryanmr/GoodCarousel">github</a>.</div>
<p>GoodCarousel is a plugin made with Mootools 1.2.3. It is made to slide over to, not fade to, the next slide and uses inline elements to draw data for the slide titles, descriptions and images.</p>
<div id="attachment_1489" class="wp-caption alignright" style="width: 310px"><a href="http://ifupdown.com/js/good-carousel/?f=blog"><img src="http://blog.ryanrampersad.com/wp-content/uploads/2009/08/good-carousel-300x210.png" alt="GoodCarousel Demo" title="GoodCarousel Demo" width="300" height="210" class="size-medium wp-image-1489" /></a><p class="wp-caption-text">GoodCarousel Demo</p></div>
<h3>What it does</h3>
<p>It creates a carousel like those found on <a href="http://www.cnet.com/">cNet</a> but instead of fading, it will slide over. The carousel draws its data from inline elements: h3, p and img within in a div with a specific class. This allows you to use the carousel but also keep the data indexable.</p>
<h3>Usage</h3>
<p>You can see a fully working <a href="http://ifupdown.com/js/good-carousel/">demo page here</a>. There are a few steps you&#8217;ll need to follow in order to get it to work.</p>
<ol>
<li>You need to determine the space you have for your slides. The space cannot change so fluid layouts probably won&#8217;t work. The demo page uses 495&#215;300 pixel images for slides because that is the space alloted to it by the layout. I found the space by using the layout tab in firebug.</li>
<li>When you make your images, keep in mind that the title and description text will be displayed on the left side of the image so putting in the right-top corner is probably the best bet. Experiment with it.</li>
<li>Once you have your slides, you can easily build your html structure so GoodCarousel can draw data from it.
<pre class="brush: xml; title: ; notranslate">
&lt;div class=&quot;carousel-data&quot;&gt;
&lt;h3&gt;Slide Title&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;http://what.the.slide.links.to/&quot;&gt;Slide description or subtext&lt;/a&gt;&lt;/p&gt;
&lt;img src=&quot;path/to/slide-image.png&quot; title=&quot;image title&quot; rel=&quot;rel - for lightbox support&quot; /&gt;
&lt;/div&gt;
</pre>
<p>Each div with carousel data will make a slide in the carousel.
</li>
<li>The carousel nav is automatically sized based on options you set when initialize GoodCarousel.
<pre class="brush: jscript; title: ; notranslate">
	window.addEvent(&quot;domready&quot;, function() {
		gc = new GoodCarousel(&quot;good-carousel&quot;, {width: 495, height: 300});
	});
</pre>
<p>Make sure you set the width and height you used for your images. GoodCarousel will take of how big to make the container and how small each nav should be.
</li>
</ol>
<p>You have to include the <a href="http://blog.ryanrampersad.com/wp-content/uploads/2009/08/good-carousel-1.1.js">GoodCorners javascript</a> file and css file in the head of your page, as always.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;link rel=&quot;stylesheet&quot; href=&quot;path/to/good-carousel.css&quot; type=&quot;text/css&quot; /&gt;
&lt;script src=&quot;path/to/mootools-1.2.3.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;path/to/good-carousel.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	window.addEvent(&quot;domready&quot;, function() {
		var gc = new GoodCarousel(&quot;good-carousel&quot;, {width: 495, height: 300});
	});
&lt;/script&gt;
</pre>
<p>Remember to set the width and height that your slides will be.</p>
<h3>Downloads</h3>
<p>You can pick up GoodCarousel with the stylesheet, transparent background and double arrows on <a href="http://ifupdown.com/js/good-carousel/">the demo page</a> as a zip. The zip contains a compressed and uncompressed version for both the css and javascript. You can use the demo page for setup reference.</p>
<h3>Notes</h3>
<p>You may need to edit the stylesheet that accompanies GoodCarousel. You can easily customize the height of the nav, text color, hover color and so on by editing the uncompressed good-carousel.css file.</p>
<div class="note">This post was written for GoodCarousel 1.1 but will probably make sense with subsequent versions. It will also work just fine with Mootools 1.2.4.</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ryanrampersad.com/2009/10/24/goodcarousel-a-carousel-with-mootools/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
	</channel>
</rss>

