<?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>gregs &#187; JavaScript</title>
	<atom:link href="http://gregs.tcias.co.uk/category/comps/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://gregs.tcias.co.uk</link>
	<description>helping me remember what I figure out</description>
	<lastBuildDate>Fri, 03 Feb 2012 01:04:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Small update to my jasmine BDD post</title>
		<link>http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/</link>
		<comments>http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/#comments</comments>
		<pubDate>Sun, 25 Sep 2011 19:55:31 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[jasmine]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=720</guid>
		<description><![CDATA[Following on from my post way back in July, I have created a repository over at the github, with some updated examples surrounding validation, adding comments to posts and some refactoring. I am currently looking into DI for javascript objects, &#8230; <a href="http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Following on from my post way back in July, I have created a <a href="https://github.com/gregstewart/node-blog" title="Node-blog github repository">repository</a> over at the github, with some updated examples surrounding validation, adding comments to posts and some refactoring. </p>
<p>I am currently looking into DI for javascript objects, as well as <a href="http://www.phantomjs.org/" title="PhantomJS: Headless WebKit with JavaScript API">phantom.js</a> and <a href="https://github.com/velesin/jasmine-jquery" title="Jasmine-jquery github repository">jasmine-jquery</a> to start putting together some examples for user journey testing and easier testing of jquery widgets and fixture loading.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/09/25/small-update-to-my-jasmine-bdd-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First steps with Jasmine</title>
		<link>http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/</link>
		<comments>http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 16:27:08 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[tdd]]></category>
		<category><![CDATA[bdd]]></category>
		<category><![CDATA[jasmine]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=712</guid>
		<description><![CDATA[New job and opportunities. One of the core approaches to developing here, is the use TDD. Now in a JS/UI kind of role this is really novel approach (well at least for me). I don't know how many times in &#8230; <a href="http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>New job and opportunities. One of the core approaches to developing here, is the use TDD. Now in a JS/UI kind of role this is really novel approach (well at least for me). I don't know how many times in the past I have lamented the fact that I needed to click through way too many steps to get to the issue at hand and then rinse and repeat to debug/fix. Even once I had wrapped my head round Chrome's debugger this approach still took way too long. I had dabbled a little in TDD and BDD on personal ruby projects, but never from a UI perspective and when faced with a monumental UI code base I just didn't have the stomach to tackle the problem retro fit tests. Also to be honest the JavaScript testing frameworks just didn't click with me, until Node.js and Jasmine that is.</p>
<p>With Node.js installed grab the following modules using npm</p>
<ul>
<li>coffee-script</li>
<li>jasmine-node</li>
</ul>
<p>Easiest way to get tests running type 'node ./spec.js ' at the command line, which is pointing to ./spec/ folder</p>
<p>In my BlogSpec.js file let's start with some basic tests</p>
<div class="igBar"><span id="lcode-9"><a href="#" onclick="javascript:showPlainTxt('code-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-9">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'blog creation'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title attribute'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toBeDefined</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">not</span>.<span style="">toBeNull</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>When you run the spec with : 'node-blog git:(master) ✗ node spec.js' the test should fail</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Started</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">FF</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Spec blog creation</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it should have a title attribute</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Error: ReferenceError: testBlog is not defined</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at new &amp;lt;anonymous&amp;gt; <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">94</span>:<span style="color:#800000;color:#800000;">50</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">fail</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">1963</span>:<span style="color:#800000;color:#800000;">27</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">execute</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">970</span>:<span style="color:#800000;color:#800000;">15</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">next_</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">1739</span>:<span style="color:#800000;color:#800000;">31</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">start</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">1692</span>:<span style="color:#800000;color:#800000;">8</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">execute</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmine-<span style="color:#800000;color:#800000;">1</span>.<span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">1</span>.<span style="">js</span>:<span style="color:#800000;color:#800000;">2018</span>:<span style="color:#800000;color:#800000;">14</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; at <span style="color:#006600; font-weight:bold;">&#91;</span>object Object<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="">next_</span> <span style="color:#006600; font-weight:bold;">&#40;</span>/Users/gregstewart/Projects/node-blog/node_modules/jasmine-node/lib/jasmine-node/jasmin% </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So everything is as expected at this stage, let's start work on getting the basic tests to pass. First off let's create out Blog object</p>
<div class="igBar"><span id="lcode-11"><a href="#" onclick="javascript:showPlainTxt('code-11'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-11">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog = function<span style="color:#006600; font-weight:bold;">&#40;</span>title<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; this.<span style="">title</span> = title;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog.<span style="">prototype</span>.<span style="">getTitle</span> = function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; return this.<span style="">title</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="">Blog</span> = Blog; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And not let's bring the Blog object into our test and initialise it:</p>
<div class="igBar"><span id="lcode-12"><a href="#" onclick="javascript:showPlainTxt('code-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-12">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var Blog = require<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'../Blog'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Blog</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'blog creation'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; var testBlog;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; beforeEach<span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; testBlog = new Blog<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title attribute'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toBeDefined</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">not</span>.<span style="">toBeNull</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now let's get the first test to pass, by editing our Blog.js file</p>
<div class="igBar"><span id="lcode-13"><a href="#" onclick="javascript:showPlainTxt('code-13'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-13">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog = function<span style="color:#006600; font-weight:bold;">&#40;</span>title<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; this.<span style="">title</span> = typeof title !== <span style="color:#CC0000;">'undefined'</span> ? title : null;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Blog.<span style="">prototype</span>.<span style="">getTitle</span> = function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; return this.<span style="">title</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="">Blog</span> = Blog; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Nearly there, only problem is that our second test is failing because we require a title to not be null.</p>
<div class="igBar"><span id="lcode-14"><a href="#" onclick="javascript:showPlainTxt('code-14'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-14">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">var Blog = require<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'../Blog'</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">Blog</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">describe<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'blog creation'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; var testBlog;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; beforeEach<span style="color:#006600; font-weight:bold;">&#40;</span>function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; testBlog = new Blog<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'test'</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title attribute'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">toBeDefined</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; it<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#CC0000;">'should have a title value'</span>, function<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; expect<span style="color:#006600; font-weight:bold;">&#40;</span>testBlog.<span style="">title</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="">not</span>.<span style="">toBeNull</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Let's see what the output looks like:</p>
<div class="igBar"><span id="lcode-15"><a href="#" onclick="javascript:showPlainTxt('code-15'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-15">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">➜  node-blog git:<span style="color:#006600; font-weight:bold;">&#40;</span>master<span style="color:#006600; font-weight:bold;">&#41;</span> ✗ node spec.<span style="">js</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Started</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">..</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="">Spec</span> blog creation</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Finished in <span style="color:#800000;color:#800000;">0</span>.<span style="color:#800000;color:#800000;">001</span> seconds</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#800000;color:#800000;">1</span> test, <span style="color:#800000;color:#800000;">2</span> assertions, <span style="color:#800000;color:#800000;">0</span> failures </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And just because I can, let's rewrite the Blog.js in Coffee Script:</p>
<div class="igBar"><span id="lcode-16"><a href="#" onclick="javascript:showPlainTxt('code-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-16">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">class Blog</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; constructor:<span style="color:#006600; font-weight:bold;">&#40;</span>@title<span style="color:#006600; font-weight:bold;">&#41;</span> -&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="">getTitle</span>: -&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @title</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">exports.<span style="">Blog</span> = Blog; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>How much terser is that?</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/07/12/first-steps-with-jasmine/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>node.js chat server</title>
		<link>http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/</link>
		<comments>http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/#comments</comments>
		<pubDate>Tue, 05 Apr 2011 14:28:55 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[node.js]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[socket.io]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=656</guid>
		<description><![CDATA[Since I have a bit of time on my hands right now, I took a look at node.js and socket.io. The outcome, a really simple chat client/server written in JavaScript. Source is up over at Github, with some instructions on &#8230; <a href="http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Since I have a bit of time on my hands right now, I took a look at node.js and socket.io. The outcome, a really simple chat client/server written in JavaScript. Source is up over at <a href="https://github.com/gregstewart/chat.io">Github</a>, with some instructions on getting started.</p>
<p style="text-align: center;"><a href="http://gregs.tcias.co.uk/wp-content/uploads/2011/04/Screen-shot-2011-04-05-at-3.25.59-PM.png"><img class="size-full wp-image-659" title="Screen shot 2011-04-05 at 3.25.59 PM" src="http://gregs.tcias.co.uk/wp-content/uploads/2011/04/Screen-shot-2011-04-05-at-3.25.59-PM.png" alt="" width="463" height="500" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2011/04/05/node-js-chat-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AJAX calls and expired sessions</title>
		<link>http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/</link>
		<comments>http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/#comments</comments>
		<pubDate>Thu, 19 Jun 2008 08:12:44 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=477</guid>
		<description><![CDATA[I have been updating a bunch of code recently to make use of the new features in Prototype 1.6 and one of the great additions in this release was the introduction of Automatic JavaScript response evaluation. This allowed me to &#8230; <a href="http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been updating a bunch of code recently to make use of the new features in <a href="http://prototypejs.org/">Prototype 1.6</a> and one of the great additions in this release was the introduction of <a href="http://prototypejs.org/api/ajax/request">Automatic JavaScript response evaluation</a>. This allowed me to improve on my session checking code without having to fuff around with the response information sent back to the client. The problem was with XHR requests: i.e. if the user initiated such a request when his session had expired, then usually the response would fail or worse just hang.</p>
<p>The snippet below shows my new session checking code.</p>
<div class="igBar"><span id="ljavascript-20"><a href="#" onclick="javascript:showPlainTxt('javascript-20'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-20">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;script type=<span style="color: #3366CC;">"text/javascript"</span>&gt;&lt;!--</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> myAjaxCall<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;url = <span style="color: #3366CC;">"index.cfm"</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;pars=<span style="color: #3366CC;">"?fuseaction.someFuseaction&amp;par1=1&amp;par2=2"</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #006600;">Updater</span><span style="color: #66cc66;">&#40;</span>\\<span style="color: #3366CC;">'div_to_populate<span style="color: #000099; font-weight: bold;">\\</span>'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;url, <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;method: \\<span style="color: #3366CC;">'post<span style="color: #000099; font-weight: bold;">\\</span>'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;postBody: pars,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;onLoading: <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #009900; font-style: italic;">//code to run while making the request</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;onComplete : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>transport,json<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>json &amp;&amp; json<span style="color: #66cc66;">&#91;</span>\\<span style="color: #3366CC;">'session<span style="color: #000099; font-weight: bold;">\\</span>'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;setSessionExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Code to run when the request has completed</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;onFailure: <span style="color: #003366; font-weight: bold;">function</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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>\\<span style="color: #3366CC;">'something went wrong<span style="color: #000099; font-weight: bold;">\\</span>'</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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp;&nbsp; &nbsp; evalScripts:<span style="color: #003366; font-weight: bold;">true</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;<span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">function</span> setSessionExpired<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;<span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>\\<span style="color: #3366CC;">'Your session has timed out<span style="color: #000099; font-weight: bold;">\\</span>'</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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;&nbsp; &nbsp;window.<span style="color: #006600;">location</span>=\\<span style="color: #3366CC;">'http://&lt;cfoutput&gt;#cgi.HTTP_HOST#&lt;/cfoutput&gt;/?fuseaction=home.home<span style="color: #000099; font-weight: bold;">\\</span>'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">// --&gt;&lt;/script&gt; </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>The trick is to intercept the call when you do your session checking at the back end. Let's say you have a fuseaction called login.login (see below and yes this is fusebox 3 :S) where you display the login form when a user is not logged in, this is where I inserted the check for an XHR request, by looking at the http headers sent along with the request. The key here is a new header attribute passed in with Prototype "X-Requested-With". If this attribute exists then I know it's an XHR request and I can create a custom JSON header with an error struct that holds a key called session with a value of timeout. All I then need to do is encode the struct as JSON and pass that encoded struct back to the browser.</p>
<div class="igBar"><span id="lcode-21"><a href="#" onclick="javascript:showPlainTxt('code-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-21">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;cfcase value=<span style="color:#CC0000;">"login"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;!--- gvs 1Feb08 - handles XHR requests that session timeout ---&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfset attributes.<span style="">request</span> = GetHttpRequestData<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#41;</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfif StructKeyExists<span style="color:#006600; font-weight:bold;">&#40;</span>attributes.<span style="">request</span>.<span style="">headers</span>,<span style="color:#CC0000;">"X-Requested-With"</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfsetting showdebugoutput=<span style="color:#CC0000;">"false"</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfparam name=<span style="color:#CC0000;">"attributes.jsonObj"</span> default=<span style="color:#CC0000;">"#CreateObject('component','com.jehiah.json')#"</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfparam name=<span style="color:#CC0000;">"error"</span> default=<span style="color:#CC0000;">"#StructNew()#"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfset error<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0000;">'session'</span><span style="color:#006600; font-weight:bold;">&#93;</span>=<span style="color:#CC0000;">'timeout'</span>/&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfif StructKeyExists<span style="color:#006600; font-weight:bold;">&#40;</span>attributes,<span style="color:#CC0000;">"jsonObj"</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfheader name=<span style="color:#CC0000;">"X-JSON"</span> value=<span style="color:#CC0000;">"#trim(attributes.jsonObj.encode(error))#"</span> /&gt;&lt;cfabort&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfif&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfif&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfif StructKeyExists<span style="color:#006600; font-weight:bold;">&#40;</span>session,<span style="color:#CC0000;">'login'</span><span style="color:#006600; font-weight:bold;">&#41;</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfset attributes.<span style="">login</span> = session.<span style="">login</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfelse&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;cfparam name=<span style="color:#CC0000;">"attributes.login"</span> default=<span style="color:#CC0000;">""</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfif&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfscript&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; xfa.<span style="">submitform</span>=<span style="color:#CC0000;">'index.cfm?fuseaction=login.processlogin'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;/cfscript&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &lt;cfinclude template=<span style="color:#CC0000;">"#affiliate('dsp_login.cfm')#"</span>/&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/cfcase&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>Now let's jump back to the JavaScript code and take a look at the onComplete function again:</p>
<div class="igBar"><span id="ljavascript-22"><a href="#" onclick="javascript:showPlainTxt('javascript-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JAVASCRIPT:</span>
<div id="javascript-22">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">onComplete : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span>transport,json<span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span>json &amp;amp;&amp;amp; json<span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'session'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; setSessionExpired<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</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;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">//Code to run when the request has completed</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>If there's a JSON object and it has a key of session then I call my setSessionExpired function which redirects the users. Now the json session key only exists in these situations since the call normally just passes back the result of the call.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2008/06/19/ajax-calls-and-expired-sessions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reflow</title>
		<link>http://gregs.tcias.co.uk/2008/05/30/reflow/</link>
		<comments>http://gregs.tcias.co.uk/2008/05/30/reflow/#comments</comments>
		<pubDate>Fri, 30 May 2008 04:27:42 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[browser]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[rendering]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=468</guid>
		<description><![CDATA[Or more appropriately what is it? Fascinating...]]></description>
			<content:encoded><![CDATA[<p>Or more appropriately <a title="What is reflow" href="http://dougt.wordpress.com/2008/05/24/what-is-a-reflow/">what is it</a>? Fascinating...</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2008/05/30/reflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Embedded images an IE work around</title>
		<link>http://gregs.tcias.co.uk/2008/05/18/embedded-images-an-ie-work-around/</link>
		<comments>http://gregs.tcias.co.uk/2008/05/18/embedded-images-an-ie-work-around/#comments</comments>
		<pubDate>Mon, 19 May 2008 02:13:04 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=466</guid>
		<description><![CDATA[A while back I posted about using the data:image/jpeg;base64 to directly embed the image in to the source attribute of an image tag, however this did not work with IE. Today I stumbled across this JavasScript solution. Certainly an option, &#8230; <a href="http://gregs.tcias.co.uk/2008/05/18/embedded-images-an-ie-work-around/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A while back <a title="Embedded image" href="http://gregs.tcias.co.uk/2007/03/13/embedded-image/">I posted</a> about using the <em>data:image/jpeg;base64</em> to directly embed the image in to the source attribute of an image tag, however this did not work with IE. Today <a title="jsimgs: embedded images in web pages - php encoder" href="http://ddzoom.net/jsimages/out.htm">I stumbled across</a> this JavasScript solution. Certainly an option, though in my case it was overkill, however I thought others might find it useful.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2008/05/18/embedded-images-an-ie-work-around/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IE , the dom and long numbers</title>
		<link>http://gregs.tcias.co.uk/2007/04/27/ie-the-dom-and-long-numbers/</link>
		<comments>http://gregs.tcias.co.uk/2007/04/27/ie-the-dom-and-long-numbers/#comments</comments>
		<pubDate>Fri, 27 Apr 2007 02:47:39 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=451</guid>
		<description><![CDATA[I just spent the best part of 45 minutes trying to figure out a weird issue with a value I was pulling out of a select box (using $F(element)). The value in question was a long number: 1000002229651626, which IE &#8230; <a href="http://gregs.tcias.co.uk/2007/04/27/ie-the-dom-and-long-numbers/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just spent the best part of 45 minutes trying to figure out a weird issue with a value I was pulling out of a select box (using $F(element)).  The value in question was a long number: 1000002229651626, which IE converted at the time of writing the value to the page (this was an AJAX call) to: 1.00000222965163e+15.</p>
<p>IE decided to convert my number when I was using the new Option() method to populate the drop down, making the debug process even harder. I personally can't wait until we get a firebug like extension for IE, right now I'd just settle for an option to view the rendered source.</p>
<p>Rant over, the solution is to convert the number to a string:</p>
<div class="igBar"><span id="ljavascript-26"><a href="#" onclick="javascript:showPlainTxt('javascript-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">JavaScript:</span>
<div id="javascript-26">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">selectBox<span style="color: #66cc66;">&#91;</span>x<span style="color: #66cc66;">&#93;</span> = <span style="color: #003366; font-weight: bold;">new</span> Option<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'Some text'</span>,<span style="color: #003366; font-weight: bold;">new</span> String<span style="color: #66cc66;">&#40;</span><span style="color: #CC0000;color:#800000;">1000002229651626</span><span style="color: #66cc66;">&#41;</span>,<span style="color: #003366; font-weight: bold;">false</span><span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>On the plus side I came across a neat way to debug values in a form field using the address the browser address bar:</p>
<div class="igBar"><span id="lcode-27"><a href="#" onclick="javascript:showPlainTxt('code-27'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-27">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javascript:alert<span style="color:#006600; font-weight:bold;">&#40;</span>document.<span style="">all</span>.<span style="">myfield</span>.<span style="">value</span><span style="color:#006600; font-weight:bold;">&#41;</span>; void<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And to see what IE had actually written to the page:</p>
<div class="igBar"><span id="lcode-28"><a href="#" onclick="javascript:showPlainTxt('code-28'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">CODE:</span>
<div id="code-28">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">javascript:alert<span style="color:#006600; font-weight:bold;">&#40;</span>document.<span style="">all</span>.<span style="">myfield</span>.<span style="">innerHTML</span> <span style="color:#006600; font-weight:bold;">&#41;</span>; void<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#800000;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2007/04/27/ie-the-dom-and-long-numbers/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>encodeURIComponent()</title>
		<link>http://gregs.tcias.co.uk/2006/06/30/encodeuricomponent/</link>
		<comments>http://gregs.tcias.co.uk/2006/06/30/encodeuricomponent/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=160</guid>
		<description><![CDATA[I just stumbled across this post from the Red Balloon guys, which reminded me that I wanted to blog about this great little resource about the subtle differences of URL encoding and JavaScript. The bottom line of this article is &#8230; <a href="http://gregs.tcias.co.uk/2006/06/30/encodeuricomponent/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I just stumbled across <a title="Update to Spelling Integration" href="http://labs.redbd.net/blog/index.cfm/2006/6/22/Update-to-Spelling-Integration">this post</a> from the <a title="RedBalloon Days - Gift Ideas - Certificates &amp; Experience Vouchers - Australia" href="http://www.redballoondays.com.au/">Red Balloon</a> guys, which reminded me that I wanted to blog about this great little resource about <a title="Comparing escape(), encodeURI(), and encodeURIComponent()" href="http://xkr.us/articles/javascript/encode-compare/">the subtle differences of URL encoding and JavaScript</a>.</p>
<p>The bottom line of this article is that 9 times out of 10 you'll want to be using <em>encodeURIComponent()</em> to encode vars that are to be passed as part of a URL instead of the <em>escape()</em> method.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2006/06/30/encodeuricomponent/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FireBug</title>
		<link>http://gregs.tcias.co.uk/2006/02/23/firebug/</link>
		<comments>http://gregs.tcias.co.uk/2006/02/23/firebug/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.tcias.co.uk/?p=163</guid>
		<description><![CDATA[Now I can't remember where I stumbled across this little gem of a plug in for FireFox: FireBug, but yesterday it completely surprised me. I originally had installed it because it was meant to be far better at debugging JS, &#8230; <a href="http://gregs.tcias.co.uk/2006/02/23/firebug/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Now I can't remember where I stumbled across this little gem of a plug in for FireFox: <a href="https://addons.mozilla.org/extensions/moreinfo.php?id=1843&amp;application=firefox">FireBug</a>, but yesterday it completely surprised me.</p>
<p>I originally had installed it because it was meant to be far better at debugging <acronym title="JavaScript">JS</acronym>, than the new version of the JavaScript Console that was shipped with FireFox 1.5 and that it was. So I have been using it for a while now, but yesterday I stumbled across a feature that makes it utterly invaluable now. I do a lot of <acronym title="Asynchronous JavaScript + XML">Ajax</acronym> based development these days and sometimes trying to figure out what is going on under the hood is a little problematic. However if you open it up and look at the options, you'll see an option to show XmlHttpRequests disabled. Enable it and make a remoting call.</p>
<p>Along with the usual <acronym title="JavaScript">JS</acronym>/<acronym title="Cascading Style Sheets">CSS</acronym> debug you should now see something like this:</p>
<p><a href="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/firebug1.png" title="Firebug screenshot 1"><img src="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/firebug1.png" alt="Firebug screenshot 1" /></a></p>
<p>If you click on the Response Tab you can see what has been returned to the browser.</p>
<p><a href="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/firebug2.png" title="Firebug screenshot 2"><img src="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/firebug2.png" alt="Firebug screenshot 2" /></a></p>
<p>And if you click on the <acronym title="JavaScript">JS</acronym> tab you can inspect the whole response object.</p>
<p><a href="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/firebug3.png" title="Firebug screenshot 3"><img src="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/firebug3.png" alt="Firebug screenshot 3" /></a></p>
<p>Awesome!</p>
<p>And since it's been so long between posts here a couple of other useful <acronym title="Asynchronous JavaScript + XML">Ajax</acronym>/prototype links:</p>
<ul>
<li>It's all over the Internet but getting started can be tricky: <a href="http://www.sitepoint.com/article/painless-javascript-prototype" title="Painless JavaScript Using Prototype">Painless JavaScript Using Prototype</a></li>
<li><a href="http://www.prototypedoc.com/" title="Prototype Documentation&lt;br&gt;&lt;/a&gt;">More prototype</a> documentation</li>
<li><a href="http://bennolan.com/behaviour/" title="Behaviour : Using CSS selectors to apply Javascript behaviours">Behaviour</a> the perfect way to write unobtrusive JavaScript</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2006/02/23/firebug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic Form validation part ii</title>
		<link>http://gregs.tcias.co.uk/2005/10/31/generic-form-validation-part-ii/</link>
		<comments>http://gregs.tcias.co.uk/2005/10/31/generic-form-validation-part-ii/#comments</comments>
		<pubDate>Wed, 30 Nov -0001 00:00:00 +0000</pubDate>
		<dc:creator>gregs</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://gregs.teacupinastorm.com/?p=211</guid>
		<description><![CDATA[A few weeks back someone on the CFDJ list enquired about JavaScript form validation and pointed them in the direction of my script, however I only just realised that the script itself was no longer working. Oops... so apologies, but &#8230; <a href="http://gregs.tcias.co.uk/2005/10/31/generic-form-validation-part-ii/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>A few weeks back someone on the CFDJ list enquired about JavaScript form validation and pointed them in the direction of my script, however I only just realised that the script itself was no longer working. Oops... so apologies, but I have fixed up the problems and done made it sure it works for the following browsers.</p>
<ul>
<li>Win XP / Netscape 4.7x</li>
<li>Win XP / IE 6</li>
<li>Win XP / Mozilla 1.4</li>
<li>Win 2K / IE 6</li>
<li>Win 2K / Mozilla 1.5</li>
<li>Win XP / Firefox 0.8</li>
</ul>
<p>If you have access to ones not on the list, I'd be grateful for any feedback. The revised version with sample file can be found <a href="http://gregs.tcias.co.uk/wp-content/uploads/2007/02/validate.zip" title="Validate zip file">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://gregs.tcias.co.uk/2005/10/31/generic-form-validation-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

