<?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>mjama.com</title>
	<atom:link href="http://flawed.mjama.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://flawed.mjama.com</link>
	<description></description>
	<lastBuildDate>Tue, 21 Feb 2012 11:45:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>LocalStorage, Is it the answer?!</title>
		<link>http://flawed.mjama.com/localstorage-is-it-the-answer/</link>
		<comments>http://flawed.mjama.com/localstorage-is-it-the-answer/#comments</comments>
		<pubDate>Tue, 21 Feb 2012 11:45:14 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=51</guid>
		<description><![CDATA[hackers.mozilla  Talking storing images and files in localstorage while Thomas was ever so kind to point out steve&#8217;s earlier article  about bing/google mobile storing css/html in them.]]></description>
			<content:encoded><![CDATA[<p><a href="http://hacks.mozilla.org/2012/02/saving-images-and-files-in-localstorage/">hackers.mozilla </a> Talking storing images and files in localstorage while Thomas was ever so kind to point out steve&#8217;s<a href="www.stevesouders.com/blog/2011/03/28/storager-case-study-bing-google/"> earlier article </a> about bing/google mobile storing css/html in them.</p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/localstorage-is-it-the-answer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS Closures For Dummies</title>
		<link>http://flawed.mjama.com/js-closures-for-dummies/</link>
		<comments>http://flawed.mjama.com/js-closures-for-dummies/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 16:43:45 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=46</guid>
		<description><![CDATA[I don&#8217;t want this post to die from Morris Jones currently only available on the wayback archives Closures Are Not Magic This page explains closures so that a programmer can understand them &#8211; using working JavaScript code. It is not for gurus nor functional programmers. Closures are not hard to understand once the core concept is grokked. However, they [...]]]></description>
			<content:encoded><![CDATA[<h3 id="closure_magic">I don&#8217;t want this post to die from Morris Jones currently only available on <a href="http://web.archive.org/web/20080209105120/http://blog.morrisjohns.com/javascript_closures_for_dummies">the wayback archives</a></h3>
<h3><a href="http://flawed.mjama.com/wp-content/uploads/2012/02/fordummies.jpg"><img class="size-full wp-image-49 aligncenter" title="fordummies" src="http://flawed.mjama.com/wp-content/uploads/2012/02/fordummies.jpg" alt="" width="392" height="320" /></a></h3>
<h3>Closures Are Not Magic</h3>
<p>This page explains closures so that a programmer can understand them &#8211; using working JavaScript code. It is not for gurus nor functional programmers.</p>
<p>Closures are <em>not hard</em> to understand once the core concept is grokked. However, they are impossible to understand by reading any academic papers or academically oriented information about them!</p>
<p>This article is intended for programmers with some programming experience in a main-stream language, and who can read the following JavaScript function:</p>
<div id="sayhello">function sayHello(name) {<br />
var text = &#8216;Hello &#8217; + name;<br />
var sayAlert = function() { alert(text); }<br />
sayAlert();<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>&nbsp;</p>
<h3 id="closure_example">An Example of a Closure</h3>
<p>Two one sentence summaries:</p>
<ul>
<li>a closure is the local variables for a function &#8211; kept alive <em>after</em> the function has returned, or</li>
<li>a closure is a stack-frame which is <em>not deallocated</em> when the function returns. (as if a &#8216;stack-frame&#8217; were malloc&#8217;ed instead of being on the stack!)</li>
</ul>
<p>The following code returns a reference to a function:</p>
<div>function sayHello2(name) {<br />
var text = &#8216;Hello &#8217; + name; // local variable<br />
var sayAlert = function() { alert(text); }<br />
return sayAlert;<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>Most JavaScript programmers will understand how a reference to a function is returned to a variable in the above code. If you don&#8217;t, then you need to before you can learn closures. A C programmer would think of the function as returning a pointer to a function, and that the variables sayAlert and say2 were each a pointer to a function.</p>
<p>There is a critical difference between a C pointer to a function, and a JavaScript reference to a function. In JavaScript, you can think of a function reference variable as having both a pointer to a function <em>as well as</em> a hidden pointer to a closure.</p>
<p>The above code has a closure because the anonymous function function() { alert(text); } is declared <em>inside</em> another function, sayHello2() in this example. In JavaScript, if you use the function keyword <em>inside</em> another function, you are creating a closure.</p>
<p>In C, and most other common languages after a function returns, all the local variables are no longer accessable because the stack-frame is destroyed.</p>
<p>In JavaScript, if you declare a function within another function, then the local variables can remain accessable <em>after</em> returning from the function you called. This is demonstrated above, because we call the function say2(); after we have returned from sayHello2(). Notice that the code that we call references the variable text, which was a <em>local variable</em> of the functionsayHello2().</p>
<div>function() { alert(text); }</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>Click the button above to get JavaScript to print out the code for the anonymous function. You can see that the code refers to the variable text. The anonymous function can referencetext which holds the value &#8217;Jane&#8217; because the local variables of sayHello2() are kept in a closure.</p>
<p>The magic is that in JavaScript a function reference also has a secret reference to the closure it was created in &#8211; similar to how delegates are a method pointer plus a secret reference to an object.</p>
<h3 id="more_example">More examples</h3>
<p>For some reason closures seem really hard to understand when you read about them, but when you see some examples you can click to how they work (it took me a while).<br />
I recommend working through the examples carefully until you understand how they work. If you start using closures without fully understanding how they work, you would soon create some very wierd bugs!</p>
<h4 id="Example 3">Example 3</h4>
<p>This example shows that the local variables are not copied &#8211; they are kept by reference. It is kind of like keeping a stack-frame in memory when the outer function exits!</p>
<div>function say667() {<br />
// Local variable that ends up within closure<br />
var num = 666;<br />
var sayAlert = function() { alert(num); }<br />
num++;<br />
return sayAlert;<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>&nbsp;</p>
<h4 id="Example 4">Example 4</h4>
<p>All three global functions have a common reference to the <em>same</em> closure because they are all declared within a single call to setupSomeGlobals().</p>
<div>function setupSomeGlobals() {<br />
// Local variable that ends up within closure<br />
var num = 666;<br />
// Store some references to functions as global variables<br />
gAlertNumber = function() { alert(num); }<br />
gIncreaseNumber = function() { num++; }<br />
gSetNumber = function(x) { num = x; }<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>The three functions have shared access to the same closure &#8211; the local variables of setupSomeGlobals() when the three functions were defined.</p>
<p>Note that in the above example, if you click setupSomeGlobals() again, then a new closure (stack-frame!) is created. The old gAlertNumber, gIncreaseNumber, gSetNumber variables are overwritten with <em>new</em> functions that have the new closure. (In JavaScript, whenever you declare a function inside another function, the inside function(s) is/are recreated again <em>each</em>time the outside function is called.)</p>
<h4 id="Example 5">Example 5</h4>
<p>This one is a real gotcha for many people, so you need to understand it.<br />
Be very careful if you are defining a function within a loop: the local variables from the closure do not act as you might first think.</p>
<div>function buildList(list) {<br />
var result = [];<br />
for (var i = 0; i &lt; list.length; i++) {<br />
var item = &#8217;item&#8217; + list[i];<br />
result.push( function() {alert(item + &#8217; &#8217; + list[i])} );<br />
}<br />
return result;<br />
}</p>
<p>function testList() {<br />
var fnlist = buildList([1,2,3]);<br />
// using j only to help prevent confusion - could use i<br />
for (var j = 0; j &lt; fnlist.length; j++) {<br />
fnlist[j]();<br />
}<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>The line result.push( function() {alert(item + &#8216; &#8216; + list[i])} adds a reference to an anonymous function three times to the result array. If you are not so familiar with anonymous functions think of it like:</p>
<div>    pointer = function() {alert(item + &#8217; &#8217; + list[i])};<br />
result.push(pointer);</p>
</div>
<p>Note that when you run the example, &#8220;item3 undefined&#8221; is alerted three times! This is because just like previous examples, there is only one closure for the local variables forbuildList. When the anonymous functions are called on the line fnlist[j](); they all use the same single closure, and they use the <em>current</em> value for i and item within that one closure (where i has a value of 3 because the loop had completed, and item has a value of &#8217;item3&#8242;).</p>
<p>&nbsp;</p>
<h4 id="Example 6">Example 6</h4>
<p>This example shows that the closure contains any local variables that were declared inside the outer function before it exited. Note that the variable alice is actually declared after the anonymous function. The anonymous function is declared first: and when that function is called it can access the alice variable because alice is in the closure.<br />
Also sayAlice()(); just directly calls the function reference returned from sayAlice() - it is exactly the same as what was done previously, but without the temp variable.</p>
<div>function sayAlice() {<br />
var sayAlert = function() { alert(alice); }<br />
// Local variable that ends up within closure<br />
var alice = &#8216;Hello Alice&#8217;;<br />
return sayAlert;<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<p>Tricky: note also that the sayAlert variable is also inside the closure, and could be accessed by any other function that might be declared within sayAlice() or it could be accessed recursively within the inside function.</p>
<h4 id="Example 7">Example 7</h4>
<p>This final example shows that each call creates a separate closure for the local variables. There is <em>not</em> a single closure per function declaration. There is a closure for <em>each call</em> to a function.</p>
<div>function newClosure(someNum, someRef) {<br />
// Local variables that end up within closure<br />
var num = someNum;<br />
var anArray = [1,2,3];<br />
var ref = someRef;<br />
return function(x) {<br />
num += x;<br />
anArray.push(num);<br />
alert(&#8216;num: &#8217; + num +<br />
&#8216;\nanArray &#8217; + anArray.toString() +<br />
&#8216;\nref.someVar &#8217; + ref.someVar);<br />
}<br />
}</p>
<div style="text-align: center;"><span style="font-family: 'Lucida Grande';"><span style="font-size: 11px; line-height: normal; white-space: pre;"><br />
</span></span></div>
</div>
<h3 id="summary">Summary</h3>
<p>If everything seems completely unclear then the best thing to do is to play with the examples. Reading an explanation is much harder than understanding examples.<br />
My explanations of closures and stack-frames etc are not technically correct &#8211; they are gross simplifications intended to help understanding. Once the basic idea is grokked, you can pick up the details later.</p>
<p>Final points:</p>
<ul>
<li>Whenever you use function inside another function, a closure is used.</li>
<li>Whenever you use eval() inside a function, a closure is used. The text you eval can reference local variables of the function, and within eval you can even create new local variables by using eval(&#8216;var foo = …</li>
<li>When you use Function() inside a function, it does not create a closure. (The new function cannot reference the local variables of the function calling Function()).</li>
<li>A closure in JavaScript is like keeping a copy of the all the local variables, just as they were when a function exited.</li>
<li>It is probably best to think that a closure is always created just on entry to a function, and the local variables are added to that closure.</li>
<li>A new set of local variables is kept every time a function with a closure is called (Given that the function contains a function declaration inside it, and a reference to that inside function is either returned or an external reference is kept for it in some way).</li>
<li>Two functions might look like they have the same source text, but have completely different behaviour because of their &#8216;hidden&#8217; closure. I don&#8217;t think JavaScript code can actually find out if a function reference has a closure or not.</li>
<li>If you are trying to do any dynamic source code modifications ( for example: myFunction = Function(myFunction.toString().replace(/Hello/,&#8217;Hola&#8217;)); ), it won&#8217;t work if myFunction is a closure (Of course, you would never even think of doing source code string substitution at runtime, but&#8230;).</li>
<li>It is possible to get function declarations within function declarations within functions &#8211; and you can get closures at more than one level.</li>
<li>I think normally a closure is the term for both the function along with the variables that are captured. Note that I do not use that definition in this article!</li>
<li>I suspect that closures in JavaScript differ from those normally found in functional languages.</li>
</ul>
<h3 id="summary">Links</h3>
<ul>
<li><a href="http://web.archive.org/web/20080209105120/http://trimpath.com/project/wiki/TrimBreakpoint">TrimBreakpoint</a> is a tricky use of closures to let you inspect local variables for a function from a popup breakpoint window.</li>
<li>Douglas Crockford&#8217;s simulated <a href="http://web.archive.org/web/20080209105120/http://www.crockford.com/javascript/private.html">private attributes and private methods</a> for an object, using closures.</li>
<li>A great explanation of how closures can <a href="http://web.archive.org/web/20080209105120/http://www.codeproject.com/jscript/LeakPatterns.asp">cause memory leaks in IE</a> if you are not careful.</li>
</ul>
<h3 id="summary">Thanks</h3>
<p>If you have <em>just</em> learnt closures (here or elsewhere!), then I am interested in any feedback from you about any changes you might suggest that could make this article clearer. Send an email to morrisjohns.com (morris_closure @). Please note that I am not a guru on JavaScript &#8211; nor on closures.</p>
<p>Thanks for reading.</p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/js-closures-for-dummies/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do browsers parse javascript on every page load?</title>
		<link>http://flawed.mjama.com/do-browsers-parse-javascript-on-every-page-load/</link>
		<comments>http://flawed.mjama.com/do-browsers-parse-javascript-on-every-page-load/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 15:41:07 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=43</guid>
		<description><![CDATA[I dug this gem off stackoverflow! &#8211; These are the details that I&#8217;ve been able to dig up. It&#8217;s worth noting first that although JavaScript is usually considered to be interpreted and run on a VM, this isn&#8217;t really the case with the modern interpreters, which tend to compile the source directly into machine code [...]]]></description>
			<content:encoded><![CDATA[<p>I dug this gem off stackoverflow!</p>
<p>&#8211;</p>
<p>These are the details that I&#8217;ve been able to dig up. It&#8217;s worth noting first that although JavaScript is usually considered to be interpreted and run on a VM, this isn&#8217;t really the case with the modern interpreters, which tend to compile the source directly into machine code (with the exception of IE).</p>
<hr />
<p><strong>Chrome : V8 Engine</strong></p>
<p>V8 has a compilation cache. This stores compiled JavaScript using a hash of the source for up to 5 garbage collections. This means that two identical pieces of source code will share a cache entry in memory regardless of how they were included. This cache is not cleared when pages are reloaded.</p>
<p><a href="http://code.google.com/p/v8/source/browse/branches/bleeding_edge/src/compilation-cache.h">Source</a></p>
<hr />
<p><strong>Opera : Carakan Engine</strong></p>
<blockquote><p>In practice this means that whenever a script program is about to be compiled, whose source code is identical to that of some other program that was recently compiled, we reuse the previous output from the compiler and skip the compilation step entirely. This cache is quite effective in typical browsing scenarios where one loads page after page from the same site, such as different news articles from a news service, since each page often loads the same, sometimes very large, script library.</p></blockquote>
<p>Therefore JavaScript is cached across page reloads, two requests to the same script will not result in re-compilation.</p>
<p><a href="http://my.opera.com/core/blog/2009/12/22/carakan-revisited">Source</a></p>
<hr />
<p><strong>Firefox : SpiderMonkey Engine</strong></p>
<p>SpiderMonkey uses <code>Nanojit</code> as its native back-end, a JIT compiler. The process of compiling the machine code can be seen <a href="https://developer.mozilla.org/En/Nanojit">here</a>. In short, it <em>appears</em> to recompile scripts as they are loaded. However, if<a href="https://developer.mozilla.org/En/SpiderMonkey/Internals/Tracing_JIT">we take a closer look</a> at the internals of <code>Nanojit</code> we see that the higher level monitor <code>jstracer</code>, which is used to track compilation can transition through three stages during compilation, providing a benefit to <code>Nanojit</code>:</p>
<blockquote><p>The trace monitor&#8217;s initial state is monitoring. This means that spidermonkey is interpreting bytecode. Every time spidermonkey interprets a backward-jump bytecode, the monitor makes note of the number of times the jump-target program-counter (PC) value has been jumped-to. This number is called the hit count for the PC. If the hit count of a particular PC reaches a threshold value, the target is considered hot.</p>
<p>When the monitor decides a target PC is hot, it looks in a hashtable of fragments to see if there is a fragment holding native code for that target PC. If it finds such a fragment, it transitions to executing mode. Otherwise it transitions to recording mode.</p></blockquote>
<p>This means that for <code>hot</code> fragments of code the native code is cached. Meaning that will not need to be recompiled. It is not made clear is these hashed native sections are retained between page refreshes. But I would assume that they are. <strong>If anyone can find supporting evidence for this then excellent.</strong></p>
<p><strong>EDIT</strong>: It&#8217;s been pointed out that Mozilla developer Boris Zbarsky has stated that Gecko does not cache compiled scripts <em>yet</em>. Taken from <a href="http://stackoverflow.com/questions/5957720/if-javascript-interpreter-does-jit-compilation-does-it-cache-results-of-it-fo">this SO answer</a>.</p>
<hr />
<p><strong>Safari : JavaScriptCore/SquirelFish Engine</strong></p>
<p>I think that the best answer for this implementation has already <a href="http://comments.gmane.org/gmane.os.opendarwin.webkit.devel/7639">been given by someone else</a>.</p>
<blockquote><p>We don&#8217;t currently cache the bytecode (or the native code). It is an<br />
option we have considered, however, currently, code generation is a<br />
trivial portion of JS execution time (&lt; 2%), so we&#8217;re not pursuing<br />
this at the moment.</p></blockquote>
<p>This was written by <a href="http://en.wikipedia.org/wiki/Maciej_Stachowiak">Maciej Stachowiak</a>, the lead developer of Safari. So I think we can take that to be true.</p>
<p>I was unable to find any other information but you can read more about the speed improvements of the latest <code>SquirrelFish Extreme</code> engine <a href="http://www.webkit.org/blog/214/introducing-squirrelfish-extreme/">here</a>, or browse the source code <a href="http://trac.webkit.org/browser">here</a> if you&#8217;re feeling adventurous.</p>
<hr />
<p><strong>IE : Chakra Engine</strong></p>
<p>There is no current information regarding IE9&#8242;s JavaScript Engine (Chakra) in this field. <strong>If anyone knows anything, please comment.</strong></p>
<p>This is quite unofficial, but for IE&#8217;s older engine implementations, Eric Lippert (<a href="http://blogs.msdn.com/b/ericlippert/about.aspx">a MS developer of JScript</a>) states in a blog reply <a href="http://blogs.msdn.com/b/ptorr/archive/2003/09/14/56184.aspx">here</a> that:</p>
<blockquote><p>JScript Classic acts like a compiled language in the sense that before any JScript Classic program runs, we fully syntax check the code, generate a full parse tree, and generate a bytecode. We then run the bytecode through a bytecode interpreter. In that sense, JScript is every bit as &#8220;compiled&#8221; as Java. <strong>The difference is that JScript does not allow you to persist or examine our proprietary bytecode</strong>. Also, the bytecode is much higher-level than the JVM bytecode &#8212; the JScript Classic bytecode language is little more than a linearization of the parse tree, whereas the JVM bytecode is clearly intended to operate on a low-level stack machine.</p></blockquote>
<p>This suggests that the bytecode does not persist in any way, and thus bytecode is not cached.</p>
<p>&nbsp;</p>
<p>http://stackoverflow.com/questions/1096907/do-browsers-parse-javascript-on-every-page-load/9261355#9261355</p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/do-browsers-parse-javascript-on-every-page-load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Func&#8217;s</title>
		<link>http://flawed.mjama.com/jquery-funcs/</link>
		<comments>http://flawed.mjama.com/jquery-funcs/#comments</comments>
		<pubDate>Wed, 15 Feb 2012 13:24:50 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=38</guid>
		<description><![CDATA[Gets the next parent DOM element with a given attribute and attribute value starting above the first given element jQuery.fn.parentByAttribute = function parentByAttribute(sAttribute, sValue) { if (this.length&#62;0) { if (sValue) { return this.first().parents("["+sAttribute+"='"+sValue+"']").get(0); } else { return this.first().parents("["+sAttribute+"]").get(0); } } }; ********* * Example: * &#60;pre&#62; * getObject() -- returns the context object (either param [...]]]></description>
			<content:encoded><![CDATA[<pre>Gets the next parent DOM element with a given attribute and attribute value starting above the first given element</pre>
<pre>	jQuery.fn.parentByAttribute = function parentByAttribute(sAttribute, sValue) {
		if (this.length&gt;0) {
			if (sValue) {
				return this.first().parents("["+sAttribute+"='"+sValue+"']").get(0);
			} else {
				return this.first().parents("["+sAttribute+"]").get(0);
			}
		}
	};</pre>
<pre>*********</pre>
<pre>	 * Example:
	 * &lt;pre&gt;
	 *   getObject()            -- returns the context object (either param or window)
	 *   getObject("a.b.C")     -- will only try to get a.b.C and return undefined if not found.
	 *   getObject("a.b.C", 0)  -- will create a, b, and C in that order if they don't exists
	 *   getObject("a.b.c", 1)  -- will create a and b, but not C.
	 * &lt;/pre&gt;</pre>
<pre>	getObject = function getObject(sName, iNoCreates, oContext) {
		var oObject = oContext || _window,
			aNames = (sName || "").split("."),
			l = aNames.length,
			iEndCreate = isNaN(iNoCreates) ? 0 : l - iNoCreates;

		for (var i=0; oObject &amp;&amp; i&lt;l; i++) {
			if (!oObject[aNames[i]] &amp;&amp; i&lt;iEndCreate ) {
				oObject[aNames[i]] = {};
			}
			oObject = oObject[aNames[i]];
		}
		return oObject;

	};</pre>
<pre></pre>
<pre>***********</pre>
<pre>* Shortcut for document.getElementById(...)</pre>
<pre>	var domByIdInternal = function(sId, oWindow) {

		if (!oWindow) {
			oWindow = window;
		}
		if (!sId || sId=="") {
			return null;
		}

		var oDomRef = oWindow.document.getElementById(sId);

		// IE also returns the element with the name or id whatever is first
		// =&gt; the following line makes sure that this was the id
		if (oDomRef &amp;&amp; oDomRef.id == sId) {
			return oDomRef;
		}

		// otherwise try to lookup the name
		var oRefs = oWindow.document.getElementsByName(sId);
		for (var i=0;i&lt;oRefs.length;i++) {
			oDomRef = oRefs[i];
			if (oDomRef &amp;&amp; oDomRef.id == sId) {
				return oDomRef;
			}
		}

		return null;

	};</pre>
<pre></pre>
<pre>************</pre>
<pre>//is there tabindex?</pre>
<pre></pre>
<pre>hasTabIndex = function hasTabIndex() {
		var oDomRef = this.get(0);
		var iTabIndex = jQuery(oDomRef).attr("tabIndex");
		return !isNaN(iTabIndex) &amp;&amp; iTabIndex &gt;= 0;
	};</pre>
<pre></pre>
<pre></pre>
<pre>****************</pre>
<pre></pre>
<pre>	var UriParams = function(sUri) {
		this.mParams = {};
		var sQueryString = sUri || window.document.location.href;
		if ( sQueryString.indexOf('#') &gt;= 0 ) {
			sQueryString = sQueryString.slice(0, sQueryString.indexOf('#'));
		}
		if(sQueryString.indexOf("?") &gt;= 0){
			sQueryString = sQueryString.slice(sQueryString.indexOf("?") + 1);
			var aParameters = sQueryString.split("&amp;"),
				mParameters = {},
				aParameter,
				sName,
				sValue;
			for(var i=0; i&lt;aParameters.length; i++){
				aParameter = aParameters[i].split("=");
				sName = decodeURIComponent(aParameter[0]);
				sValue = aParameter.length &gt; 1 ? decodeURIComponent(aParameter[1].replace(/\+/g,' ')) : "";
				if(sName){
					if(!Object.prototype.hasOwnProperty.call(mParameters, sName)){
						mParameters[sName] = [];
					}
					mParameters[sName].push(sValue);
				}
			}
			this.mParams = mParameters;
		}
	};</pre>
<pre>************</pre>
<pre></pre>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/jquery-funcs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ShadowDom</title>
		<link>http://flawed.mjama.com/shadowdom/</link>
		<comments>http://flawed.mjama.com/shadowdom/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 15:23:47 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=35</guid>
		<description><![CDATA[Good news, Everyone! First bits of Shadow DOM landed in WebKit. Try it in the next Chrome Canary (http://tools.google.com/dlpage/chromesxs) or if you&#8217;re really impatient, grab the latest continuous build (http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html). Just follow these steps: * Open chrome://flags * Find Shadow DOM flag and click to enable * Restart Chrome * Navigate to http://jsfiddle.net/dglazkov/eQSZd/embedded/result/ * If you see SHADOW DOM IS WORKING, you&#8217;re all set. [...]]]></description>
			<content:encoded><![CDATA[<div>Good news, Everyone! First bits of <strong>Shadow DOM</strong> landed in WebKit. Try it in the next <strong>Chrome Canary</strong> (<a href="http://tools.google.com/dlpage/chromesxs">http://tools.google.com/dlpage/chromesxs</a>) or if you&#8217;re really impatient, grab the latest continuous build (<a href="http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html">http://commondatastorage.googleapis.com/chromium-browser-continuous/index.html</a>). Just follow these steps:</p>
<p>* Open <em>chrome://flags</em><br />
* Find <strong>Shadow DOM</strong> flag and click to enable<br />
* Restart Chrome<br />
* Navigate to <a href="http://jsfiddle.net/dglazkov/eQSZd/embedded/result/">http://jsfiddle.net/dglazkov/eQSZd/embedded/result/</a><br />
* If you see <strong>SHADOW DOM IS WORKING</strong>, you&#8217;re all set.<br />
* Otherwise, go &#8220;hmmmm&#8230;&#8221; and try again?</p>
<p>This first drop supports:<br />
* creating a shadow root (vendor-prefixed, so <strong>WebKitShadowRoot</strong>)<br />
* one shadow root per element<br />
* most of the event/CSS plumbing</p>
<p>Coming soon:<br />
* &lt;content&gt; and &lt;shadow&gt; element support<br />
* multiple shadow roots per element<br />
* and more!</p>
<p>Try it, and don&#8217;t forget to file bugs at <a href="https://bugs.webkit.org/enter_bug.cgi?product=WebKit&amp;blocked=63606&amp;component=HTML%20DOM">https://bugs.webkit.org/enter_bug.cgi?product=WebKit&amp;blocked=63606&amp;component=HTML%20DOM</a></div>
<div></div>
<div>&#8211; Extract from Web Components Google plus page.</div>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/shadowdom/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Differences Between jQuery .bind() vs .live() vs .delegate() vs .on()</title>
		<link>http://flawed.mjama.com/differences-between-jquery-bind-vs-live-vs-delegate-vs-on/</link>
		<comments>http://flawed.mjama.com/differences-between-jquery-bind-vs-live-vs-delegate-vs-on/#comments</comments>
		<pubDate>Mon, 06 Feb 2012 14:42:13 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=32</guid>
		<description><![CDATA[Useful read… &#160; http://www.elijahmanor.com/2012/02/differences-between-jquery-bind-vs-live.html]]></description>
			<content:encoded><![CDATA[<p>Useful read…</p>
<p>&nbsp;</p>
<p><a href="http://www.elijahmanor.com/2012/02/differences-between-jquery-bind-vs-live.html">http://www.elijahmanor.com/2012/02/differences-between-jquery-bind-vs-live.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/differences-between-jquery-bind-vs-live-vs-delegate-vs-on/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTML building blocks</title>
		<link>http://flawed.mjama.com/html-building-blocks/</link>
		<comments>http://flawed.mjama.com/html-building-blocks/#comments</comments>
		<pubDate>Sat, 04 Feb 2012 20:40:36 +0000</pubDate>
		<dc:creator>t00ka</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=29</guid>
		<description><![CDATA[http://www.99lime.com/]]></description>
			<content:encoded><![CDATA[<p>http://www.99lime.com/</p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/html-building-blocks/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript-Garden</title>
		<link>http://flawed.mjama.com/javascript-garden/</link>
		<comments>http://flawed.mjama.com/javascript-garden/#comments</comments>
		<pubDate>Thu, 02 Feb 2012 13:22:22 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=26</guid>
		<description><![CDATA[http://bonsaiden.github.com/JavaScript-Garden/]]></description>
			<content:encoded><![CDATA[<p>http://bonsaiden.github.com/JavaScript-Garden/</p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/javascript-garden/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Firefox Adds Powerful New Developer Tools</title>
		<link>http://flawed.mjama.com/firefox-adds-powerful-new-developer-tools/</link>
		<comments>http://flawed.mjama.com/firefox-adds-powerful-new-developer-tools/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 11:43:35 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=20</guid>
		<description><![CDATA[&#160; Link to article]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://www.youtube.com/embed/VcuQ2Bn5bTA" frameborder="0" width="560" height="315"></iframe></p>
<p>&nbsp;</p>
<p><a href="http://blog.mozilla.com/blog/2012/01/31/firefox-adds-powerful-new-developer-tools/">Link to article</a></p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/firefox-adds-powerful-new-developer-tools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simon Sinek: How great leaders inspire action</title>
		<link>http://flawed.mjama.com/simon-sinek-how-great-leaders-inspire-action/</link>
		<comments>http://flawed.mjama.com/simon-sinek-how-great-leaders-inspire-action/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 10:29:47 +0000</pubDate>
		<dc:creator>Mohamed</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://flawed.mjama.com/?p=9</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p><object width="526" height="374" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="wmode" value="transparent" /><param name="bgColor" value="#ffffff" /><param name="flashvars" value="vu=http://video.ted.com/talk/stream/2009X/Blank/SimonSinek_2009X-320k.mp4&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/SimonSinek-2009X.embed_thumbnail.jpg&amp;vw=512&amp;vh=288&amp;ap=0&amp;ti=848&amp;lang=&amp;introDuration=15330&amp;adDuration=4000&amp;postAdDuration=830&amp;adKeys=talk=simon_sinek_how_great_leaders_inspire_action;year=2009;theme=not_business_as_usual;theme=unconventional_explanations;event=TEDxPuget+Sound+;tag=bullseye;tag=business;tag=entrepreneur;tag=leadership;tag=sales;tag=selling;tag=success;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" /><param name="src" value="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" /><param name="pluginspace" value="http://www.macromedia.com/go/getflashplayer" /><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><embed width="526" height="374" type="application/x-shockwave-flash" src="http://video.ted.com/assets/player/swf/EmbedPlayer.swf" allowFullScreen="true" allowScriptAccess="always" wmode="transparent" bgColor="#ffffff" flashvars="vu=http://video.ted.com/talk/stream/2009X/Blank/SimonSinek_2009X-320k.mp4&amp;su=http://images.ted.com/images/ted/tedindex/embed-posters/SimonSinek-2009X.embed_thumbnail.jpg&amp;vw=512&amp;vh=288&amp;ap=0&amp;ti=848&amp;lang=&amp;introDuration=15330&amp;adDuration=4000&amp;postAdDuration=830&amp;adKeys=talk=simon_sinek_how_great_leaders_inspire_action;year=2009;theme=not_business_as_usual;theme=unconventional_explanations;event=TEDxPuget+Sound+;tag=bullseye;tag=business;tag=entrepreneur;tag=leadership;tag=sales;tag=selling;tag=success;&amp;preAdTag=tconf.ted/embed;tile=1;sz=512x288;" pluginspace="http://www.macromedia.com/go/getflashplayer" allowfullscreen="true" allowscriptaccess="always" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://flawed.mjama.com/simon-sinek-how-great-leaders-inspire-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

