<?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>Jim Sangwine</title>
	<atom:link href="http://www.sangwine.net/jim/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sangwine.net/jim</link>
	<description>a BritGeek in the Netherlands</description>
	<lastBuildDate>Mon, 20 May 2013 20:50:17 +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>How to detect when ALL your nested ng-includes have loaded their content in angularjs</title>
		<link>http://www.sangwine.net/jim/index.php/2013/05/how-to-detect-when-all-your-nested-includes-have-loaded-their-content-in-angularjs/</link>
		<comments>http://www.sangwine.net/jim/index.php/2013/05/how-to-detect-when-all-your-nested-includes-have-loaded-their-content-in-angularjs/#comments</comments>
		<pubDate>Tue, 14 May 2013 19:47:56 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[$includeContentLoaded]]></category>
		<category><![CDATA[angularjs]]></category>
		<category><![CDATA[ng-include]]></category>
		<category><![CDATA[ngInclude]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=348</guid>
		<description><![CDATA[angularjs provides an $includeContentLoaded event that is fired by every instance of the ngInclude directive whenever it's content is (re)loaded. In situations where you have multiple nested ngIncludes, the event is of limited use since it is fiddly to detect<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2013/05/how-to-detect-when-all-your-nested-includes-have-loaded-their-content-in-angularjs/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p><a href="http://angularjs.org/" title="angularjs">angularjs</a> provides an <a href="http://docs.angularjs.org/api/ng.directive:ngInclude#$includeContentLoaded" title="angularjs - $includeContentLoaded event">$includeContentLoaded</a> event that is fired by every instance of the <a href="http://docs.angularjs.org/api/ng.directive:ngInclude" title="angularjs - ngInclude">ngInclude directive</a> whenever it's content is (re)loaded.</p>
<p>In situations where you have multiple nested ngIncludes, the event is of limited use since it is fiddly to detect which include has loaded, and there is no out of the box way to detect when ALL of them have loaded.</p>
<p>Check out <a href="http://jsfiddle.net/JimSangwine/Tzg49/" title="AngularJS $includeContentLoaded demo">this jsFiddle</a> showing how to use the $includeContentLoaded event to detect when specific includes have loaded based on their scopes.</p>
<p><i>But what if you want to know when ALL the includes beneath a given scope have been loaded?</i></p>
<p>On a recent project I needed to use <a href="http://docs.angularjs.org/api/ng.$anchorScroll" title="angularjs = $anchorScroll">$anchorScroll</a> on a long form built out of a lot of nested includes. If I called it too early, the page would get longer and the scroll position wouldn't be correct. Obviously I didn't want to just listen for $includeContentLoaded on the main page scope and call $anchorScroll every time it was fired... Not only would this be wasteful, it might also make the page jump and jitter visibly.</p>
<p>Luckily, it is possible to extend on the built in angularjs directives, including ngInclude.<br />
So, I wrote a simple extension that registers instances of ngInclude up the scope chain, and <a href="http://docs.angularjs.org/api/ng.$rootScope.Scope#$emit" title="angularjs - Scope.$emit">$emit</a>s a custom event at every level when all child $includeContentLoaded events have been fired.<br />
This means I can listen at any level in the application (e.g. a form, a menu wrapper etc.) and know when angularjs has finished laying out all the nested visual elements. Of course this does not guarantee that any asynchronous calls to webservices have been completed, only that the DOM rendering is ready.</p>
<p>Here is a working example of the directive in action with a load of debug info so you can see what's going on: <a href="http://jsfiddle.net/gh/gist/AngularJS/1.1.1/5586190/">jsFiddle</a> / <a href="https://gist.github.com/JimSangwine/5586190" title="GitHub Gist">gist</a><br />
Here is a cleaner version with minimal code and only the allContentLoaded events being printed: <a href="http://jsfiddle.net/gh/gist/AngularJS/1.1.1/5586086/">jsFiddle</a> / <a href="https://gist.github.com/JimSangwine/5586086" title="GitHub Gist">gist</a></p>
<p>And if you just want the code for the directive, here it is:</p>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">/**</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp;* Extends the built-in angularjs IncludeDirective</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp;*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">myApp.<span style="color: #006600;">directive</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'ngInclude'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #003366; font-weight: bold;">function</span> recursivelyRegister<span style="color: #66cc66;">&#40;</span>scopeToRegister, scopeToRegisterWith<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>!scopeToRegisterWith.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'includesLoading'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            scopeToRegisterWith.<span style="color: #006600;">includesLoading</span> = <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>scopeToRegisterWith.<span style="color: #006600;">includesLoading</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>scopeToRegister.$id<span style="color: #66cc66;">&#41;</span> === <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            scopeToRegisterWith.<span style="color: #006600;">includesLoading</span>.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span>scopeToRegister.$id<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scopeToRegister.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; scopeToRegisterWith.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                scopeToRegister.<span style="color: #006600;">logToConsole</span><span style="color: #66cc66;">&#40;</span>scopeToRegister.<span style="color: #000066;">name</span> + <span style="color: #3366CC;">' was linked under '</span> + scopeToRegisterWith.<span style="color: #000066;">name</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scopeToRegisterWith.$parent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            recursivelyRegister<span style="color: #66cc66;">&#40;</span>scopeToRegister, scopeToRegisterWith.$parent<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #003366; font-weight: bold;">function</span> recursivelyDeRegisterAndNotify<span style="color: #66cc66;">&#40;</span>scopeToDeRegister, scopeToDeRegisterFrom<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #003366; font-weight: bold;">var</span> i = scopeToDeRegisterFrom.<span style="color: #006600;">includesLoading</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span>scopeToDeRegister.$id<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>i !== <span style="color: #CC0000;">-1</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            scopeToDeRegisterFrom.<span style="color: #006600;">includesLoading</span>.<span style="color: #006600;">splice</span><span style="color: #66cc66;">&#40;</span>i, <span style="color: #CC0000;">1</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scopeToDeRegisterFrom.<span style="color: #006600;">includesLoading</span>.<span style="color: #006600;">length</span> === <span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scopeToDeRegisterFrom.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                    scopeToDeRegister.<span style="color: #006600;">logToConsole</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'all includes were loaded under '</span> + scopeToDeRegisterFrom.<span style="color: #000066;">name</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                scopeToDeRegisterFrom.$emit<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'allIncludesLoaded'</span> + scopeToDeRegisterFrom.$id<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scopeToDeRegisterFrom.$parent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            recursivelyDeRegisterAndNotify<span style="color: #66cc66;">&#40;</span>scopeToDeRegister, scopeToDeRegisterFrom.$parent<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #003366; font-weight: bold;">function</span> recursivelyReset<span style="color: #66cc66;">&#40;</span>scope<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        scope.<span style="color: #006600;">includesLoading</span>.<span style="color: #006600;">length</span> = <span style="color: #CC0000;">0</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scope.$parent<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            recursivelyReset<span style="color: #66cc66;">&#40;</span>scope.$parent<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        restrict: <span style="color: #3366CC;">'A'</span>,</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        link: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>scope, element, attr, ngModel<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            recursivelyRegister<span style="color: #66cc66;">&#40;</span>scope, scope.$parent<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            scope.$on<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'$routeChangeSuccess'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #009900; font-style: italic;">// empty the tracking arrays on route changes</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                recursivelyReset<span style="color: #66cc66;">&#40;</span>scope<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            scope.$on<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'$includeContentLoaded'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>event<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span>scope.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; scope.$parent.<span style="color: #006600;">hasOwnProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'name'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                    scope.<span style="color: #006600;">logToConsole</span><span style="color: #66cc66;">&#40;</span>scope.<span style="color: #000066;">name</span> + <span style="color: #3366CC;">' was loaded under '</span> + scope.$parent.<span style="color: #000066;">name</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">                recursivelyDeRegisterAndNotify<span style="color: #66cc66;">&#40;</span>scope, scope.$parent<span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">            <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">        <span style="color: #66cc66;">&#125;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #66cc66;">&#125;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2013/05/how-to-detect-when-all-your-nested-includes-have-loaded-their-content-in-angularjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to stop Twitter Bootstrap modal dialogs breaking on browser history navigation in angularjs</title>
		<link>http://www.sangwine.net/jim/index.php/2013/05/how-to-stop-twitter-bootstrap-modal-dialogs-breaking-on-browser-history-navigation-in-angularjs/</link>
		<comments>http://www.sangwine.net/jim/index.php/2013/05/how-to-stop-twitter-bootstrap-modal-dialogs-breaking-on-browser-history-navigation-in-angularjs/#comments</comments>
		<pubDate>Mon, 13 May 2013 19:34:48 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[angularjs]]></category>
		<category><![CDATA[Bootstrap]]></category>
		<category><![CDATA[Twitter]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=338</guid>
		<description><![CDATA[Twitter's Bootstrap modal dialogs are susceptible to a problem when used in conjunction with angularjs... when your users navigate using their browser's history buttons or keyboard shortcuts (the Backspace key for example), they stay open. Because the scope from which<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2013/05/how-to-stop-twitter-bootstrap-modal-dialogs-breaking-on-browser-history-navigation-in-angularjs/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>Twitter's Bootstrap modal dialogs are susceptible to a problem when used in conjunction with angularjs... when your users navigate using their browser's history buttons or keyboard shortcuts (the Backspace key for example), they stay open.</p>
<p>Because the scope from which they were opened has been destroyed, I was ending up with orphaned, broken dialogs that could no longer be closed.</p>
<p>If you are targeting modern <a href="http://caniuse.com/#search=history" title="caniuse.com - History API browser support">browsers that support</a> the <a href="http://www.w3.org/TR/html5/browsers.html#history" title="W3 - History API">History API</a>, a simple fix is available using the <a href="http://www.w3.org/html/wg/drafts/html/master/browsers.html#event-popstate" title="W3 - the popstate event">popstate</a> Window event:</p>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">/* Watches the HTML5 History API history changed event to avoid the bug with </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp;* modal dialogs being catastrophically broken when backspace or the</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp;* browser back button is clicked. </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp;*/</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">window.<span style="color: #006600;">onpopstate</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// hideDialog is a method on my rootScope that looks after cleanly </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// closing any open dialog ... </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// it basically boils down to $('#someModalElement').modal('hide');</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// I'll write a post about it sometime.</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    $rootScope.<span style="color: #006600;">hideDialog</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// The hiding animation was causing a race condition that resulted</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// in the overlay div that is loaded under dialogs being left behind</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    <span style="color: #009900; font-style: italic;">// sometimes, so I had to explicitly remove it.</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">    $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.modal-backdrop'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">remove</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li></ol></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2013/05/how-to-stop-twitter-bootstrap-modal-dialogs-breaking-on-browser-history-navigation-in-angularjs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Yet more JS wierdness &#8211; how to zero out (or just set) the time part of a date object</title>
		<link>http://www.sangwine.net/jim/index.php/2012/12/yet-more-js-wierdness-how-to-zero-out-or-just-set-the-time-part-of-a-date-object/</link>
		<comments>http://www.sangwine.net/jim/index.php/2012/12/yet-more-js-wierdness-how-to-zero-out-or-just-set-the-time-part-of-a-date-object/#comments</comments>
		<pubDate>Thu, 13 Dec 2012 11:49:48 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=327</guid>
		<description><![CDATA[I love JavaScript, warts and all, but occasionally I stumble across quirks that are so unintuitive that I feel the need to write them down. Today, I needed to compare two dates, but without taking into account the time element<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2012/12/yet-more-js-wierdness-how-to-zero-out-or-just-set-the-time-part-of-a-date-object/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>I love JavaScript, warts and all, but occasionally I stumble across quirks that are so unintuitive that I feel the need to write them down.</p>
<p>Today, I needed to compare two dates, but without taking into account the time element (so only  day, month and year). Obviously there are plenty of more verbose ways to achieve this, but I just wanted to do a straight comparison between two Date objects. So, I dove into the specs looking for a way to set an existing Date object's time element to exactly midnight (00:00).</p>
<p>I found <a title="setHours" href="http://www.w3schools.com/jsref/jsref_sethours.asp" target="_blank">setHours</a>, <a title="setMinutes" href="http://www.w3schools.com/jsref/jsref_setminutes.asp" target="_blank">setMinutes</a>, <a title="setSeconds" href="http://www.w3schools.com/jsref/jsref_setseconds.asp" target="_blank">setSeconds</a> and <a title="setMilliseconds" href="http://www.w3schools.com/jsref/jsref_settime.asp" target="_blank">setMilliseconds</a>... but surely simple old <a href="http://www.w3schools.com/jsref/jsref_settime.asp" title="setTime">setTime</a> would do the job? Of course not, that would be far too logical:</p>
<blockquote><p>The setTime() method sets a date and time by adding or subtracting a specified number of milliseconds to/from midnight January 1, 1970.</p></blockquote>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> d = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">d.<span style="color: #006600;">setTime</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">1332403882588</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p>But a closer look at the documentation for the other methods reveals that each one is not only capable of setting it's implied unit of time, but also all those <i>below</i> it. </p>
<p>For example: </p>
<blockquote><p>The setMinutes() method sets the minutes of a date object.<br />
This method can also be used to set the seconds and milliseconds.</p></blockquote>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Date.<span style="color: #006600;">setMinutes</span><span style="color: #66cc66;">&#40;</span>min,sec,millisec<span style="color: #66cc66;">&#41;</span></div></li></ol></pre>
<p>and:</p>
<blockquote><p>The setHours() method sets the hour of a date object.<br />
This method can also be used to set the minutes, seconds and milliseconds.</p></blockquote>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Date.<span style="color: #006600;">setHours</span><span style="color: #66cc66;">&#40;</span>hour,min,sec,millisec<span style="color: #66cc66;">&#41;</span></div></li></ol></pre>
<p>Therefore, to achieve the goal of setting the time part of an existing date object, you can use the setHours() method:</p>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">​<span style="color: #003366; font-weight: bold;">var</span> d = <span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span>d<span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// Thu Dec 13 2012 12:48:32 GMT+0100 (CET) </span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">d.<span style="color: #006600;">setHours</span><span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;">0</span>,<span style="color: #CC0000;">0</span>,<span style="color: #CC0000;">0</span>,<span style="color: #CC0000;">0</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">console.<span style="color: #006600;">log</span><span style="color: #66cc66;">&#40;</span>d<span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// Thu Dec 13 2012 00:00:00 GMT+0100 (CET) ​​​​</span></div></li></ol></pre>
<p>Logical, right?</p>
<p>Source: <a href="http://www.w3schools.com/jsref/jsref_obj_date.asp" title="setTime" target="_blank">w3schools.com - JavaScript Date Object</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2012/12/yet-more-js-wierdness-how-to-zero-out-or-just-set-the-time-part-of-a-date-object/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>1989 Jeep Wrangler YJ radio / stereo wiring</title>
		<link>http://www.sangwine.net/jim/index.php/2012/04/1989-jeep-wrangler-yj-radio-stereo-wiring/</link>
		<comments>http://www.sangwine.net/jim/index.php/2012/04/1989-jeep-wrangler-yj-radio-stereo-wiring/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 09:30:08 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[Cars]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=236</guid>
		<description><![CDATA[My '89 Jeep had no wiring harness / block so I needed to research how to connect it up to a modern ISO head unit. For anyone else in the same situation, here is what I found: removing the dash<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2012/04/1989-jeep-wrangler-yj-radio-stereo-wiring/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>My '89 Jeep had no wiring harness / block so I needed to research how to connect it up to a modern ISO head unit.<br />
For anyone else in the same situation, here is what I found:</p>
<p><strong>removing the dash fascia to remove / install the head unit</strong><br />
Source: Autozone free repair docs (free site membership required).</p>
<p>* Disconnect the battery ground cable.<br />
* Remove the gauge cluster bezel as outlined under Gauge Cluster removal and installation.<br />
* Remove the control knobs, nuts, and bezel.<br />
* If equipped with air conditioning, remove the screws and lower the assembly.<br />
* Disconnect the radio bracket from the instrument panel.<br />
* Tilt the radio down and remove it toward the steering wheel.<br />
* Detach the antenna, speaker, and power wires.<br />
* Reverse the procedure for installation.</p>
<div id="attachment_239" class="wp-caption aligncenter" style="width: 510px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2012/04/dash.jpeg" rel="lightbox[236]" title="removing a Jeep YJ dash / fascia"><img class="size-full wp-image-239" title="removing a Jeep YJ dash / fascia" src="http://www.sangwine.net/jim/wp-content/uploads/2012/04/dash.jpeg" alt="removing a Jeep YJ dash / fascia" width="500" height="327" /></a><p class="wp-caption-text">removing a Jeep YJ dash / fascia</p></div>
<hr />
<p><strong>1990 Jeep Wrangler Car Stereo Radio Wiring</strong><br />
Source: http://www.modifiedlife.com/1990-jeep-wrangler-car-stereo-radio-wiring-diagram/</p>
<p>Car Radio Constant 12V+ Wire: Pink<br />
Car Radio Switched 12V+ Wire: Purple/White<br />
Car Radio Ground Wire: Black<br />
Car Radio Illumination Wire: Blue/Red<br />
Car Radio Dimmer Wire: Red/Black<br />
Car Radio Antenna Trigger: N/A<br />
Car Radio Amp Trigger Wire: N/A<br />
Front Speakers Size: 4″ x 6″ Speakers<br />
Front Speakers Location: Dash<br />
Left Front Speaker Wire (+): Gray<br />
Left Front Speaker Wire (-): Yellow<br />
Right Front Speaker Wire (+): White/Red<br />
Right Front Speaker Wire (-): Black/Red<br />
Rear Speakers Size: 4″ Speakers<br />
Rear Speakers Location: Rear Roof<br />
Left Rear Speaker Wire (+): Gray/White<br />
Left Rear Speaker Wire (-): Brown/White<br />
Right Rear Speaker Wire (+): White/Black<br />
Right Rear Speaker Wire (-): Brown</p>
<h3>OR…</h3>
<p><strong>1988-89 Jeep Wrangler Stereo Wiring </strong><br />
Source: http://www.the12volt.com/installbay/stereodetail/1232.html</p>
<p>Constant 12V+ Red/White<br />
Switched 12V+ Purple/White<br />
Ground Black<br />
Illumination Blue/Red<br />
Dimmer Red/Black<br />
Antenna Right Front<br />
Front Speakers 4" x 6" Dash<br />
Left Front (+) Gray<br />
Left Front (-) Yellow<br />
Right Front (+) White/Red<br />
Right Front (-) Brown/Red<br />
Rear Speakers 4" Rear Roof<br />
Left Rear (+) Gray/White<br />
Left Rear (-) Brown/White<br />
Right Rear (+) White/Black<br />
Right Rear (-) Brown</p>
<hr />
<p>In case yours does have the wiring block, here is the pinout for a YJ radio connector:</p>
<div id="attachment_237" class="wp-caption aligncenter" style="width: 257px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2012/04/Jeep-pinout.jpeg" rel="lightbox[236]" title="Jeep Wrangler YJ radio pinout"><img class="size-full wp-image-237" title="Jeep Wrangler YJ radio pinout" src="http://www.sangwine.net/jim/wp-content/uploads/2012/04/Jeep-pinout.jpeg" alt="Jeep Wrangler YJ radio pinout" width="247" height="400" /></a><p class="wp-caption-text">Jeep Wrangler YJ radio pinout</p></div>
<p>(source: some forum post I have now lost - will try to find it back)</p>
<hr />
<p>And here is the ISO pinout (viewed from the back of the plugs that go into the head unit - the side the wires go in):</p>
<div id="attachment_238" class="wp-caption aligncenter" style="width: 275px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2012/04/ISO-pinout.jpeg" rel="lightbox[236]" title="ISO radio / stereo pinout"><img class="size-full wp-image-238" title="ISO radio / stereo pinout" src="http://www.sangwine.net/jim/wp-content/uploads/2012/04/ISO-pinout.jpeg" alt="ISO radio / stereo pinout" width="265" height="333" /></a><p class="wp-caption-text">ISO radio / stereo pinout</p></div>
<p>(source: http://en.wikipedia.org/wiki/File:ISO_10487_connector_pinout.svg)</p>
<hr />
<p>And finally, the standard ISO colours:</p>
<p><strong>Power plug</strong><br />
Yellow - Permanent power<br />
Red - Switched power<br />
Orange - Illumination<br />
Blue - Remote (electric aerial/amplifier switch on)<br />
Black - Earth</p>
<p><strong>Speaker plug</strong><br />
Grey - Front right speaker<br />
White - Front left speaker<br />
Purple - Rear right speaker<br />
Green - Rear left speaker</p>
<p>These wires are in pairs. The speaker wires with the tracers are usually the returns.</p>
<p>Note that these colours might not be adhered to by all manufacturers, so <strong>be careful!</strong><br />
The wires themselves often have their purpose printed on them in small text, otherwise <a title="RTFM!" href="http://en.wikipedia.org/wiki/RTFM" target="_blank">RTFM</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2012/04/1989-jeep-wrangler-yj-radio-stereo-wiring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Last day at Philips</title>
		<link>http://www.sangwine.net/jim/index.php/2012/01/last-day-at-philips/</link>
		<comments>http://www.sangwine.net/jim/index.php/2012/01/last-day-at-philips/#comments</comments>
		<pubDate>Wed, 25 Jan 2012 22:20:56 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[Scrum]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=226</guid>
		<description><![CDATA[]]></description>
				<content:encoded><![CDATA[<div id="attachment_227" class="wp-caption alignnone" style="width: 560px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2012/01/IMG_20120124_152258-e1368640976512.jpg" rel="lightbox[226]" title="Last day at Philips"><img class="size-large wp-image-227" alt="A special task sticky added by my team for my last day." src="http://www.sangwine.net/jim/wp-content/uploads/2012/01/IMG_20120124_152258-1024x768.jpg" width="550" height="412" /></a><p class="wp-caption-text">A special task sticky added by my team for my last day.</p></div>
<div id="attachment_228" class="wp-caption alignnone" style="width: 560px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2012/01/IMG_20120124_140205-e1368640878891.jpg" rel="lightbox[226]" title="Last day at Philips"><img class="size-large wp-image-228" alt="I am going to really miss all these people." src="http://www.sangwine.net/jim/wp-content/uploads/2012/01/IMG_20120124_140205-1024x768.jpg" width="550" height="412" /></a><p class="wp-caption-text">I am going to really miss all these people.</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2012/01/last-day-at-philips/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>What? You tattooed code on your arm?</title>
		<link>http://www.sangwine.net/jim/index.php/2011/09/what-you-tattooed-code-on-your-arm/</link>
		<comments>http://www.sangwine.net/jim/index.php/2011/09/what-you-tattooed-code-on-your-arm/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 18:47:01 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Rants]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=205</guid>
		<description><![CDATA[[OPPORTUNISTIC UPDATE] Since I'm seeing so many hits for this page, and since most of you are developers, I thought it might be worth trying to do a little blatant recruiting If you are an exceptional, passionate front end developer<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2011/09/what-you-tattooed-code-on-your-arm/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>[OPPORTUNISTIC UPDATE]<br />
Since I'm seeing so many hits for this page, and since most of you are developers, I thought it might be worth trying to do a little blatant recruiting <img src='http://www.sangwine.net/jim/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
If you are an exceptional, passionate front end developer (HTML, CSS, JS) and you want to work in an awesome SCRUM team at a huge multinational company in the South of the Netherlands, please drop me a line (DM my <a href="https://twitter.com/#!/JimSangwine" title="My Twitter account" target="_blank">Twitter account</a>).<br />
There are also opportunities for developers (front and/or back end) and UNIX gurus at another brilliant company (<a href="http://www.competa.com" title="Competa" target="_blank">Competa</a>) in the Randstad. Basically, if you love tech and you're looking for work in Holland, get in touch!</p>
<p>[UPDATE]<br />
This code isn't meant to <strong>do</strong> anything - it's purely symbolic.<br />
And yes, I know it will cause a stack overflow if you run it - that's the point that I die, "run out" of memory or suffer some other system failure. Clearly I'm not immortal, so there needs to be some end to the recursion eventually <img src='http://www.sangwine.net/jim/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>(function(){var k=[];return function j(){k.push(i);j();}})()();</h2>
<p>That's what I got tattooed on my forearm last week. Reactions have ranged from incredulity to hilarity, but I love it.</p>
<p>So why <strong>did</strong> I decide to spend the rest of my life with an obscure snippet of JavaScript on my body? Well, because I wanted a tattoo that meant something to <strong>me</strong>, not anyone else. I wanted something linked to my work and my passion: web development. And I wanted something no one else would have.</p>
<p>I briefly Googled "developer tattoos" and "programmer tattoos" looking for inspiration, but the only good thing that came up was the (admittedly brilliant) &lt;/head&gt; &lt;body&gt; tattoo that you've doubtless already seen:</p>
<div id="attachment_206" class="wp-caption aligncenter" style="width: 360px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/09/head-body-tattoo.jpg" rel="lightbox[205]" title="head-body-tattoo"><img src="http://www.sangwine.net/jim/wp-content/uploads/2011/09/head-body-tattoo.jpg" alt="head-body-tattoo" title="head-body-tattoo" width="350" height="389" class="size-full wp-image-206" /></a><p class="wp-caption-text">ingenious</p></div>
<p>Having been let down by the Interwebs, I thought "how better to commemorate my love for code than in code?".</p>
<p>The obvious choice of language was JavaScript. It's the language I've been using the longest (although I've only been seriously into it for the past year or so since I got to work on <a href="http://jiglibjs.org" title="JigLibJS" target="_blank">JigLibJS</a>). JavaScript is also one of core foundations of the web, and looking at recent developments that's not likely to change anytime soon. Also, it's an open standard, which is what I believe the web should be all about.</p>
<p>So, what should I say with my code? I decided I wanted something to remind me of the values and philosophies I strive to apply every day in my work, and in my life. </p>
<h2>(<span class="red">function(){</span>var k=[];<span class="red">return function j(){</span>k.push(i);j();<span class="red">}}</span>)()();</h2>
<p>This code structure is called a closure. If you don't know what a closure is, you can read about it here: <a href="http://en.wikipedia.org/wiki/Closure_%28computer_science%29" title="closure: via Wikipedia" target="_blank">via Wikipedia</a>. The short version: it's a function that returns another function. The returned function has access to anything created in the scope of the parent function - just like private class members in full blown object oriented languages like C# or Java. I decided to go for this structure for 2 reasons: firstly because I find it very beautiful, and secondly because I wanted the code to support growth or accumulation in some way. </p>
<h2>(function(){<span class="red">var k=[];</span>return function j(){k.push(i);j();}})()();</h2>
<p>The <strong>k</strong> array represents knowledge or experience. </p>
<h2>(function(){var k=[];return <span class="red">function j(){</span>k.push(i);<span class="red">j();}</span>})()();</h2>
<p>The function <strong>j</strong> returned by the closure is recursive. This is to remind me that I should maintain my own drive and motivation - that I should always expect more of myself.</p>
<h2>(function(){var k=[];return function j(){<span class="red">k.push(i);</span>j();}})()();</h2>
<p>On every call, the function <strong>j</strong> attempts to add the contents of variable <strong>i</strong> out of the global scope to the enclosed array <strong>k</strong>. The eagle eyed will notice that I have not included a safety check here so that if <strong>i</strong> is undefined, the code will error out and the recursion of <strong>j</strong> will fail. This is intentional. The variable <strong>i</strong> represents input from other people, and I want to remember that I should always seek the advice and opinions of those around me. I know that I cannot grow in isolation, hence the catastrophic consequences of failing to garner the contributions of others. As I mentioned above, the <strong>k</strong> array represents knowledge or experience, and this part of the code also reminds me that I should always <strong>learn</strong> from the input I elicit. This doesn't mean to say that I should always accept or act upon advice I receive, just that I should learn from it. Even poor opinions can teach us a lot about the people who offer them <img src='http://www.sangwine.net/jim/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>(function(){var k=[];return function j(){k.push(i);j();}})<span class="red">()()</span>;</h2>
<p>Both the closure and the returned function <strong>j</strong> are self invoking. That means that the code will run itself: the functions do not need to be invoked from elsewhere. This is to remind me that I should take the initiative in my life and work, not rely on external influences for the impetus to start new things.</p>
<p>So, that's it. Every time I look at my arm I will be reminded of the values that are important to me, and of my love for code.</p>
<p>Much better than some Chinese characters that may or may not mean "luck" or "strength" I think, and every bit as cryptic. </p>
<div id="attachment_211" class="wp-caption aligncenter" style="width: 610px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/09/tattoo-2011-09-12.jpg" rel="lightbox[205]" title="JavaScript tattoo 2011-09-12"><img src="http://www.sangwine.net/jim/wp-content/uploads/2011/09/tattoo-2011-09-12.jpg" alt="My new tattoo" title="JavaScript tattoo 2011-09-12" width="600" height="242" class="size-full wp-image-211" /></a><p class="wp-caption-text">I wear my geek-ness with pride</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2011/09/what-you-tattooed-code-on-your-arm/feed/</wfw:commentRss>
		<slash:comments>70</slash:comments>
		</item>
		<item>
		<title>IE, images and labels</title>
		<link>http://www.sangwine.net/jim/index.php/2011/07/ie-images-and-labels/</link>
		<comments>http://www.sangwine.net/jim/index.php/2011/07/ie-images-and-labels/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 16:47:56 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=159</guid>
		<description><![CDATA[Internet Explorer doesn't handle clicks on images in labels: &#60;label for=&#34;someCheckbox&#34;&#62; &#60;input name=&#34;someCheckbox&#34; type=&#34;checkbox&#34; /&#62;&#60;img src=&#34;aPrettyPicture.png&#34; /&#62;&#60;/label&#62; So, I did a quick Google to see how others have solved this issue, and the first hit was this site which included<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2011/07/ie-images-and-labels/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>Internet Explorer doesn't handle clicks on images in labels:</p>
<pre class="html4strict"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/label.html"><span style="color: #000000; font-weight: bold;">&lt;label</span></a> <span style="color: #000066;">for</span>=<span style="color: #ff0000;">&quot;someCheckbox&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> </div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000; font-weight: bold;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;someCheckbox&quot;</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;checkbox&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000; font-weight: bold;">&lt;img</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;aPrettyPicture.png&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/label&gt;</span></span></div></li></ol></pre>
<p>So, I did a quick Google to see how others have solved this issue, and the first hit was <a href="http://snook.ca/archives/javascript/using_images_as" target="_blank">this site</a> which included this reader-submitted jQuery solution:</p>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;label img&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">live</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;#&quot;</span> + $<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parents</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;label&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;for&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
<p>This solution was pretty buggy for me (required double clicks on the images) and uses <code>jQuery.live()</code> which seems <a href="http://api.jquery.com/live/" target="_blank">overkill</a> to me since the problem presented in the original article does not specify a need to support dynamically added labels. Also, use of <code>jQuery.live()</code> can be <a href="http://jupiterit.com/news/why-you-should-never-use-jquery-live" target="_blank">considered inadvisable</a>, especially if it's not actually necessary to achieve the required behaviour. Finally, I didn't understand why the code didn't just select the image's direct parent.</p>
<p>So, I settled on this simplified version which works perfectly for me:</p>
<pre class="javascript"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;label img&quot;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">bind</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">&quot;click&quot;</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	$<span style="color: #66cc66;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">parent</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2011/07/ie-images-and-labels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Can Google see JavaScript content?</title>
		<link>http://www.sangwine.net/jim/index.php/2011/07/can-google-see-javascript-content/</link>
		<comments>http://www.sangwine.net/jim/index.php/2011/07/can-google-see-javascript-content/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 18:19:21 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=144</guid>
		<description><![CDATA[I made this simple page to test if Googlebot can parse content loaded or generated via JavaScript. There are two divs on the page - one has it's content loaded via AJAX using jQuery.load() and the other using jQuery.html(). [update]<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2011/07/can-google-see-javascript-content/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>I made <a href="http://sangwine.net/js_seo_poc/">this simple page</a> to test if Googlebot can parse content loaded or generated via JavaScript.</p>
<p>There are two divs on the page - one has it's content loaded via AJAX using jQuery.load() and the other using jQuery.html().</p>
<p>[update] I have added an extra content block whose AJAX request is triggered by a link in case Googlebot treats onload JS differently to onclick.</p>
<p>I then used Google's <a href="http://www.google.com/support/webmasters/bin/answer.py?answer=158587">Fetch as Googlebot</a> tool to see if the content would be visible during spidering.</p>
<p>This is how Googlebot saw the page:</p>
<pre class="html4strict"><ol><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">HTTP/1.1 200 OK</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Content-Length: 639</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Content-Type: text/html</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Content-Location: http://www.sangwine.net/js_seo_poc/index.html</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Last-Modified: Thu, 14 Jul 2011 17:53:30 GMT</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Accept-Ranges: bytes</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ETag: W/&quot;ec7d4f14e42cc1:7d83e&quot;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Server: Microsoft-IIS/6.0</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">X-Powered-By: ASP.NET</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Date: Thu, 14 Jul 2011 17:54:16 GMT</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00bbdd;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #00bbdd;">	&quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;</span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000; font-weight: bold;">&lt;html</span></a> xmlns=<span style="color: #ff0000;">&quot;http://www.w3.org/1999/xhtml&quot;</span> xml:<span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span> <span style="color: #000066;">lang</span>=<span style="color: #ff0000;">&quot;en&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000; font-weight: bold;">&lt;head&gt;</span></a></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">&quot;Content-Type&quot;</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">&quot;text/html;charset=utf-8&quot;</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000; font-weight: bold;">&lt;title&gt;</span></a></span>Sample Title<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/title&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;http://code.jquery.com/jquery-1.6.2.min.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000; font-weight: bold;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">&quot;text/javascript&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;script.js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/script&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/head&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000; font-weight: bold;">&lt;body&gt;</span></a></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">&lt;h1&gt;</span></a></span>simple AJAX content loading (jQuery.load();):<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contentBlock1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/h1.html"><span style="color: #000000; font-weight: bold;">&lt;h1&gt;</span></a></span>Dynamically built content:<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/h1&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">	<span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000; font-weight: bold;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;contentBlock2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/div&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/body&gt;</span></span></div></li><li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;"><div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/html&gt;</span></span></div></li></ol></pre>
<p>So, it would seem that Google cannot spider content created after the original HTTP response. </p>
<p>I will be reviewing how Google really spiders my test page in a day or two to confirm if the "Fetch as Googlebot" tool is really accurate.</p>
<p>If anyone can shed any light on techniques for writing SEO client-side dynamic content, please shout out in the comments!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2011/07/can-google-see-javascript-content/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MacBook Pro SSD Upgrade: is it worth it?</title>
		<link>http://www.sangwine.net/jim/index.php/2011/06/ssd-upgrade-is-it-worth-it/</link>
		<comments>http://www.sangwine.net/jim/index.php/2011/06/ssd-upgrade-is-it-worth-it/#comments</comments>
		<pubDate>Fri, 17 Jun 2011 22:56:21 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=119</guid>
		<description><![CDATA[I've been trying to find ways to make my late 2008 unibody MacBook Pro run faster because I want to hold out on upgrading at least until the end of the year, and preferably after the next range refresh. I<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2011/06/ssd-upgrade-is-it-worth-it/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>I've been trying to find ways to make my late 2008 unibody MacBook Pro run faster because I want to hold out on upgrading at least until the end of the year, and preferably after the next range refresh.</p>
<p>I run a lot of applications simultaneously, especially at work. I also use Windows virtual machines a lot for cross-browser testing (I'm a web developer), and so a lot of my day is spent waiting for stuff to load.</p>
<p>I also run a lot of persistent menubar widgets for everything from managing my VPN connections to quickly accessing my code snippets:</p>
<div id="attachment_63" class="wp-caption aligncenter" style="width: 549px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_menubar.png" rel="lightbox[119]" title="mbp_menubar"><img class="size-full wp-image-63" title="mbp_menubar" src="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_menubar.png" alt="My menubar" width="539" height="23" /></a><p class="wp-caption-text">My menubar</p></div>
<p>The first step was to up my RAM to 6Gb (Apple says it will only take 4, but 6 has been found to be the real stable maximum by the community). This helped a little, especially when running VM's, but I still found myself spending way too much time on the Apple site with my cursor hovering over the buy button for the 17 inch i7.</p>
<p>The next obvious upgrade was an SSD drive, and after seeing this video I decided to take the plunge:</p>
<p><iframe width="425" height="349" src="http://www.youtube.com/embed/XK0zLmbQxKA" frameborder="0" allowfullscreen></iframe></p>
<p>After quite a bit of research I settled on the 240Gb <a href="http://www.ocztechnology.com/ocz-vertex-2-sata-ii-2-5-ssd.html" target="_blank">OCZ Vertex 2</a> as my drive of choice. Big enough to not need a second internal drive (I didn't want to trade the increased battery drain and heat for extra space) but not so big as to break the bank. It still wasn't cheap (£285 GBP / ~ €325 EUR <a href="http://www.amazon.co.uk/OCZ-Vertex-240GB-2-5-inch-Internal/dp/B003NE5JCY/ref=sr_1_1?ie=UTF8&qid=1308348958&sr=8-1" target="_blank">from Amazon UK</a>), but having installed it this morning and used it at work for a day, I have to say it was money well spent!</p>
<p>In fact the results are nothing short of stunning. I will never go back to rotational media again for my main workhorse machine.<br />
I put together a series of tests while I was waiting for the drive to turn up so I could empirically compare it with my old 5200rpm stock drive.</p>
<p>First, the specs of my system and the two drives:</p>
<div id="attachment_59" class="wp-caption aligncenter" style="width: 410px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_sys_specs1.gif" rel="lightbox[119]" title="mbp_sys_specs"><img class="size-full wp-image-59" title="mbp_sys_specs" src="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_sys_specs1.gif" alt="My late 2008 unibody MacBook Pro specs" width="400" height="229" /></a><p class="wp-caption-text">My late 2008 unibody MacBook Pro specs</p></div>
<div id="attachment_56" class="wp-caption aligncenter" style="width: 416px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_orig_hdd_specs.gif" rel="lightbox[119]" title="mbp_orig_hdd_specs"><img class="size-full wp-image-56" title="mbp_orig_hdd_specs" src="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_orig_hdd_specs.gif" alt="my original 320Gb 5400RPM hdd" width="406" height="305" /></a><p class="wp-caption-text">my original hard drive</p></div>
<div id="attachment_104" class="wp-caption aligncenter" style="width: 418px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/06/ssd_specs.gif" rel="lightbox[119]" title="ssd_specs"><img class="size-full wp-image-104" title="ssd_specs" src="http://www.sangwine.net/jim/wp-content/uploads/2011/06/ssd_specs.gif" alt="OCZ Vertex 2 SSD specs" width="408" height="305" /></a><p class="wp-caption-text">OCZ Vertex 2 SSD specs</p></div>
<hr />
<h2>cold boot test</h2>
<p><strong>HDD:</strong><br />
Dock appears: 1:20<br />
Desktop loads: 1:40<br />
Finder and menubar loaded: 2:10</p>
<p><strong>SSD:</strong><br />
Dock appears: 0:30<br />
Desktop loads: 0:31<br />
Finder and menubar loaded: 0:36</p>
<hr />
<h2>Multiple application loading test</h2>
<p>I made a simple AppleScript that loads a selection of my most commonly used work apps: Photoshop CS5, iTerm2, CSSEdit, Espresso, Versions, EclipseJEE and Firefox.</p>
<p><strong>HDD:</strong> 1:15<br />
<strong>SSD:</strong> ~ 14 seconds</p>
<hr />
<h2>grep test</h2>
<p>I recursively grepped for "wp" in the root of a WordPress site</p>
<pre>grep -ri "wp*" ./</pre>
<p><strong>HDD:</strong> ~ 9 seconds<br />
<strong>SSD:</strong> ~ 5 seconds</p>
<hr />
<h2>tar test</h2>
<p>I timed how long it took to tar up a joomla application (5283 files, 69.2Mb) from the commandline.</p>
<pre>tar -cvf testdump.tar sangwine.net_2010</pre>
<p><strong>HDD:</strong> ~ 13 seconds<br />
<strong>SDD:</strong> ~ 5 seconds</p>
<hr />
<h2>XBench test</h2>
<div id="attachment_66" class="wp-caption aligncenter" style="width: 488px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_xbench_hdd.gif" rel="lightbox[119]" title="mbp_xbench_hdd"><img class="size-full wp-image-66" title="mbp_xbench_hdd" src="http://www.sangwine.net/jim/wp-content/uploads/2011/06/mbp_xbench_hdd.gif" alt="XBench results with the original hdd" width="478" height="479" /></a><p class="wp-caption-text">XBench results with the original hdd</p></div>
<div id="attachment_102" class="wp-caption aligncenter" style="width: 519px"><a href="http://www.sangwine.net/jim/wp-content/uploads/2011/06/ssd_xbench.gif" rel="lightbox[119]" title="ssd_xbench"><img class="size-full wp-image-102" title="ssd_xbench" src="http://www.sangwine.net/jim/wp-content/uploads/2011/06/ssd_xbench.gif" alt="OCZ Vertex 2 SSD XBench results" width="509" height="478" /></a><p class="wp-caption-text">OCZ Vertex 2 SSD XBench results</p></div>
<hr />
<p>The test results really don't convey the feeling of working on a system that loads applications and accesses data so fast.</p>
<p>To put it in perspective, here are a few application load times I am getting with the new SSD drive:</p>
<ul>
<li>Mac Mail: < 1 second</li>
<li>Outlook 2011: ~ 2 seconds</li>
<li>Windows XP VM running under Parallels: ~ 30 seconds</li>
</ul>
<p>I downloaded a tarball earlier today, and Archiver unpacked it so quickly that it didn't even get a chance render to the screen.</p>
<p>If you are considering making the switch, I highly recommend it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2011/06/ssd-upgrade-is-it-worth-it/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Really? A glory hole?</title>
		<link>http://www.sangwine.net/jim/index.php/2011/06/really-a-glory-hole/</link>
		<comments>http://www.sangwine.net/jim/index.php/2011/06/really-a-glory-hole/#comments</comments>
		<pubDate>Wed, 15 Jun 2011 20:03:21 +0000</pubDate>
		<dc:creator>jim</dc:creator>
				<category><![CDATA[Games]]></category>

		<guid isPermaLink="false">http://www.sangwine.net/jim/?p=94</guid>
		<description><![CDATA[I have just encountered my first (and probably last) video game glory hole. And not just any glory hole... one surrounded by graffiti depicting a woman (the hole is in her mouth) along with the words "yum" and "slurp". And<span class="ellipsis">&#8230;</span><div class="read-more"><a href="http://www.sangwine.net/jim/index.php/2011/06/really-a-glory-hole/">Read more &#8250;</a></div><!-- end of .read-more -->]]></description>
				<content:encoded><![CDATA[<p>I have just encountered my first (and probably last) video game <a href="http://en.wikipedia.org/wiki/Glory_hole_%28sexual_slang%29" target="_blank">glory hole</a>. And not just any glory hole... one surrounded by graffiti depicting a woman (the hole is in her mouth) along with the words "yum" and "slurp".</p>
<p>And yes, it's interactive.</p>
<p><iframe width="425" height="349" src="http://www.youtube.com/embed/CpoZABbt7M8" frameborder="0" allowfullscreen></iframe></p>
<p>What game hero would dare openly use a glory hole? Why <a href="http://www.dukenukemforever.com/" target="_blank">Duke Nukem</a> of course!</p>
<p>What is less Duke-ish is the fact that when you peek through the hole it is a man you see sitting in the neighboring stall, although the voice is a woman's. Bizarre. Is this some kind of hidden hint that Duke's bread is buttered on both sides, or just another symptom of an incomplete game?</p>
<p>Regardless, it kind of puts GTA San Andreas' infamous <a href="http://en.wikipedia.org/wiki/Hot_Coffee_mod" target="_blank">hot coffee mod</a> in perspective.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sangwine.net/jim/index.php/2011/06/really-a-glory-hole/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
