<?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"
	>

<channel>
	<title>Gen X Design &#124; Ian Selby</title>
	<atom:link href="http://www.gen-x-design.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gen-x-design.com</link>
	<description>All Things Web 2.0</description>
	<pubDate>Tue, 05 Aug 2008 18:48:11 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6</generator>
	<language>en</language>
			<item>
		<title>Jaxer 1.0 Now Available (RC B)</title>
		<link>http://www.gen-x-design.com/archives/jaxer-10-now-available-rc-b/</link>
		<comments>http://www.gen-x-design.com/archives/jaxer-10-now-available-rc-b/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 18:46:04 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Jaxer]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/jaxer-10-now-available-rc-b/</guid>
		<description><![CDATA[It&#8217;s been awhile since I&#8217;ve made any mention of Jaxer, and for good reason. The Jaxer team at Aptana has been hard at work getting Jaxer ready for 1.0 Release. That day has come, and I&#8217;m proud the first publicly available version of Jaxer 1.0: Jaxer 1.0 RCB. As far as functionality goes, this release [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been awhile since I&#8217;ve made any mention of Jaxer, and for good reason. The Jaxer team at <a href="http://www.aptana.com" target="_blank">Aptana</a> has been hard at work getting Jaxer ready for 1.0 Release. That day has come, and I&#8217;m proud the first publicly available version of Jaxer 1.0: Jaxer 1.0 RCB. As far as functionality goes, this release is pretty much feature-complete, and we just need some people to kick the tires a bit before we officially tag it as 1.0.</p>
<p>So, what&#8217;s new in this version of Jaxer? Quite a bit, actually, and if you&#8217;ve been using 0.9x releases of Jaxer until now, a lot has changed for you as well. As usual, Jaxer is available bundled into <a href="http://www.aptana.com/studio" target="_blank">studio</a> (starting with the recently released 1.2 version), as well as the usual stand-alone. Read on for a full summary of what&#8217;s new&#8230;</p>
<p><span id="more-60"></span></p>
<p>So, here&#8217;s a quick run-down of the shiny new version of Jaxer:</p>
<ul>
<li>Application context settings that allowing for easier app configuration, app properties, database settings, etc&#8230;</li>
<li>Database API enhancements with richer APIs for working with result sets.</li>
<li>Server-side image manipulation including server-side canvas support and ability to convert to other image types.</li>
<li>Native command execution API so that you can run system commands and handle the output from those.</li>
<li>Asynchronous server-side JavaScript processing lets you implement callbacks in your server-side code too.</li>
<li>Ability to return custom content types (e.g. json, xml, gif, html, etc&#8230;)</li>
<li>Full control of the request/response lifecycle including setting redirects, headers, content, etc&#8230;</li>
<li>Secure sandbox supporting cross domain calls, sandboxed JavaScript execution, META refreshes, &#8230;</li>
<li>Serialization support for JavaScript objects to and from XML, E4X and JSON</li>
</ul>
<p>Pretty cool stuff, huh? What&#8217;s really exciting to me (outside the functionality that was already there previously, such as database and filesystem access), is the ability to return custom content types, specifically JSON. JSON returns are nice since the server-side is already natively JavaScript, as well as the fact that this means creating JSON data services for your existing apps becomes a snap. If JSON&#8217;s not your cup of tea (and you&#8217;re crazy if it isn&#8217;t), or perhaps you need to deal with XML for whatever reason, the E4X (native XML for JS) support being baked in is also nice. This essentially means that you can use Jaxer as a JSON or XML service provider to not only Ajax clients, but other things like flash / flex, Silverlight, and more. Writing your own RESTful API in JavaScript = crazy delicious!</p>
<p>Another interesting feature that I have yet to play with personally is the new secure sandbox. What this essentially lets you do is load pages (or page fragments) on the server from other domains and let their JS execute without giving them access to the Jaxer API, or any of your other server-side code. Why is this neat, you may ask? Well, if you are aggregating content from a site (news.com in several of the Jaxer samples), the content you&#8217;re retrieving may have some JS code that could get evaluated. Before the sandbox existed, this meant a bunch of JS errors would bubble up to the client-side related to this JS code. No longer&#8230; and obviously this is also important as it means nobody could try and compromise your system by modifying the content you fetch to try and execute destructive statements (i.e. &#8220;DROP DATABASE&#8221;). Obviously, there&#8217;s a lot of room for neat mash-ups with this new goodness, and Uri Sarid has written a nice article on <a href="http://www.aptana.com/blog/uri/dom_scraping_with_jaxer_part_2" target="_blank">DOM Scraping with Jaxer</a>.</p>
<p>I hope to be cooking up some new articles related to this release in the coming days, and will definitely be covering this stuff in my upcoming speaking engagements. For now, enjoy these links:</p>
<ul>
<li><a href="http://www.aptana.com/studio/download" target="_blank">Download Aptana Studio w/ Jaxer 1.0 RC B</a></li>
<li><a href="http://www.aptana.com/jaxer/download" target="_blank">Download Jaxer 1.0 RC B Server and Stand-Alone</a></li>
<li><a href="http://www.aptana.com/docs/index.php/Migrating_from_Jaxer_beta" target="_blank">Learn about all the new goodness, and how to migrate from 0.x releases of Jaxer</a></li>
<li><a href="http://forums.aptana.com/index.php?c=12" target="_blank">Tell us what you love, or hate in the forums</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/jaxer-10-now-available-rc-b/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Firebug Lite 1.2 Released</title>
		<link>http://www.gen-x-design.com/archives/firebug-lite-12-released/</link>
		<comments>http://www.gen-x-design.com/archives/firebug-lite-12-released/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 15:49:00 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/firebug-lite-12-released/</guid>
		<description><![CDATA[If you&#8217;ve ever used Firebug for JS development, you know how indisposable it is.  If you haven&#8217;t, you&#8217;re insane, and you need to start using it now!  Firebug Lite was created to be able to embed a more limited version of the library in non-firefox browsers.  Previously, you couldn&#8217;t do much with [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever used Firebug for JS development, you know how indisposable it is.  If you haven&#8217;t, you&#8217;re insane, and you need to <a href="http://www.getfirebug.com" target="_blank">start</a> using it now!  Firebug Lite was created to be able to embed a more limited version of the library in non-firefox browsers.  Previously, you couldn&#8217;t do much with it outside of the console. functions and use a JS command-line.  Looks like that&#8217;s a thing of the past with the new release.  It&#8217;s pretty much as functional as the actual Firefox extension, and is well worth checking out:<br />
<a href="http://ajaxian.com/archives/firebug-lite-12-now-with-improved-lite-ness" target="_blank">Firebug Lite 1.2 Released</a> (via Ajaxian)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/firebug-lite-12-released/feed/</wfw:commentRss>
		</item>
		<item>
		<title>BgPatterns.com - Cool Background Image Generator</title>
		<link>http://www.gen-x-design.com/archives/bgpatternscom-cool-background-image-generator/</link>
		<comments>http://www.gen-x-design.com/archives/bgpatternscom-cool-background-image-generator/#comments</comments>
		<pubDate>Thu, 10 Jul 2008 03:41:33 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/bgpatternscom-cool-background-image-generator/</guid>
		<description><![CDATA[While its generally not my style, I would have loved to have something like this several times in the past.  Slick, easy, classy, fun, and actually worthwhile.  Check it out:
www.bgpatterns.com
]]></description>
			<content:encoded><![CDATA[<p>While its generally not my style, I would have loved to have something like this several times in the past.  Slick, easy, classy, fun, and actually worthwhile.  Check it out:<br />
<a href="http://bgpatterns.com" target="_blank">www.bgpatterns.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/bgpatternscom-cool-background-image-generator/feed/</wfw:commentRss>
		</item>
		<item>
		<title>savethedevlopers.org - Save a Developer. Upgrade Your Browser</title>
		<link>http://www.gen-x-design.com/archives/savethedevlopersorg-save-a-developer-upgrade-your-browser/</link>
		<comments>http://www.gen-x-design.com/archives/savethedevlopersorg-save-a-developer-upgrade-your-browser/#comments</comments>
		<pubDate>Mon, 30 Jun 2008 21:01:45 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/savethedevlopersorg-save-a-developer-upgrade-your-browser/</guid>
		<description><![CDATA[&#8220;Say No To IE 6!
Our current campaign focuses on assisting users in upgrading their Internet Explorer 6 web browser. This campaign will result in former IE 6 users having a more enjoyable experience on the web while (hopefully) creating a less stressful and complicated environment for web developers by hastening the retirement of an outdated [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;Say No To IE 6!<br />
Our current campaign focuses on assisting users in upgrading their Internet Explorer 6 web browser. This campaign will result in former IE 6 users having a more enjoyable experience on the web while (hopefully) creating a less stressful and complicated environment for web developers by hastening the retirement of an outdated browser.&#8221;<br />
<br /><a href="http://www.savethedevelopers.org/" target="_blank">http://www.savethedevelopers.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/savethedevlopersorg-save-a-developer-upgrade-your-browser/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Evernote - Awesome Note Capturing Software</title>
		<link>http://www.gen-x-design.com/archives/evernote-awesome-note-capturing-software/</link>
		<comments>http://www.gen-x-design.com/archives/evernote-awesome-note-capturing-software/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 16:27:29 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/evernote-awesome-note-capturing-software/</guid>
		<description><![CDATA[I know, yet another note capture / organize program&#8230; but this one&#8217;s different.  It&#8217;s got really powerful OCR software (it will pull text from images, even handwriting) that automatically finds words in your images and indexes them, making it easier to find later.  Works on the web, your mobile phone, and PC or [...]]]></description>
			<content:encoded><![CDATA[<p>I know, yet another note capture / organize program&#8230; but this one&#8217;s different.  It&#8217;s got really powerful OCR software (it will pull text from images, even handwriting) that automatically finds words in your images and indexes them, making it easier to find later.  Works on the web, your mobile phone, and PC or Mac.  Best of all, it&#8217;s free!<br />
<a href="http://www.evernote.com/" target="_blank">Evernote - Capture. Sync. Find</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/evernote-awesome-note-capturing-software/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Magic Toolbox - High Quality JS Tools</title>
		<link>http://www.gen-x-design.com/archives/magic-toolbox-high-quality-js-tools/</link>
		<comments>http://www.gen-x-design.com/archives/magic-toolbox-high-quality-js-tools/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 22:55:49 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/magic-toolbox-high-quality-js-tools/</guid>
		<description><![CDATA[Nice little suite of JS tools&#8230; they&#8217;re commercial, but reasonably priced.  The names kinda imply what they do: Magic Zoom, Magnify, and Thumbs.  Definitely worth a look:
Magic Toolbox
]]></description>
			<content:encoded><![CDATA[<p>Nice little suite of JS tools&#8230; they&#8217;re commercial, but reasonably priced.  The names kinda imply what they do: Magic Zoom, Magnify, and Thumbs.  Definitely worth a look:<br />
<a href="http://www.magictoolbox.com/" target="_blank">Magic Toolbox</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/magic-toolbox-high-quality-js-tools/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Is “finally” the answer to all IE6 memory leak issues?</title>
		<link>http://www.gen-x-design.com/archives/is-%e2%80%9cfinally%e2%80%9d-the-answer-to-all-ie6-memory-leak-issues/</link>
		<comments>http://www.gen-x-design.com/archives/is-%e2%80%9cfinally%e2%80%9d-the-answer-to-all-ie6-memory-leak-issues/#comments</comments>
		<pubDate>Mon, 09 Jun 2008 18:12:18 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/is-%e2%80%9cfinally%e2%80%9d-the-answer-to-all-ie6-memory-leak-issues/</guid>
		<description><![CDATA[Via Ajaxian:
Hedger Wang has been scanning a lot of Chinese blogs lately for solutions to IE6 and memory leak issues. One of the things he stumbled upon is a pretty nifty way of nulling the objects to stop memory leaks by using the try &#8230; finally construct.
Read the article ad Hedger&#8217;s Site
]]></description>
			<content:encoded><![CDATA[<p>Via <a href="http://ajaxian.com" target="_blank">Ajaxian</a>:<br />
Hedger Wang has been scanning a lot of Chinese blogs lately for solutions to IE6 and memory leak issues. One of the things he stumbled upon is a pretty nifty way of nulling the objects to stop memory leaks by using the try &#8230; finally construct.<br />
<a href="http://www.hedgerwow.com/360/dhtml/ie6_memory_leak_fix/" target="_blank">Read the article ad Hedger&#8217;s Site</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/is-%e2%80%9cfinally%e2%80%9d-the-answer-to-all-ie6-memory-leak-issues/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Server-Side JavaScript - All the Cool Kids Are Doing It!</title>
		<link>http://www.gen-x-design.com/archives/server-side-javascript-all-the-cool-kids-are-doing-it/</link>
		<comments>http://www.gen-x-design.com/archives/server-side-javascript-all-the-cool-kids-are-doing-it/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 23:30:42 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[AJAX]]></category>

		<category><![CDATA[General]]></category>

		<category><![CDATA[JavaScript]]></category>

		<category><![CDATA[Jaxer]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/?p=53</guid>
		<description><![CDATA[That&#8217;s right kids, I&#8217;m speaking at the 6th International AJAX World RIA Conference &#038; Expo!  I&#8217;ll be giving a session on server-side javascript, and how it will make your life better, your apps cooler, and your friends jealous!
Read the full entry for details on the session, but here&#8217;s a little introductory overview (for the [...]]]></description>
			<content:encoded><![CDATA[<p>That&#8217;s right kids, I&#8217;m speaking at the 6th International AJAX World RIA Conference &#038; Expo!  I&#8217;ll be giving a session on server-side javascript, and how it will make your life better, your apps cooler, and your friends jealous!</p>
<p>Read the full entry for details on the session, but here&#8217;s a little introductory overview (for the sake of not re-writing everything, I have just copied and pasted the announcement)&#8230;</p>
<blockquote><p>Server-side JavaScript (SSJS) is growing in popularity fast since developers realize it can drastically simplify Web app creation by letting you use using the same technology stack on both the client and the server. While server-side JavaScript is not new - it was a part of Netscape’s vision 10 years ago - times have significantly changed with 10x faster hardware and networks, making that original vision for the Web now a reality.</p>
<p>In this session delegates will learn how to:</p>
<ul>
<li>Overcome common hurdles and pitfalls of client-side only JavaScript development.</li>
<li>Speed up development time by cutting out extra server-side code and processing scripts that are no longer necessary.</li>
<li>Clean up your code base by reducing (or even eliminating) the number of languages needed to leverage to accomplish common tasks (i.e. Why bother with server-side PHP scripts to fetch database results when you can do it all in JavaScript on the server? Why mess with Curl to fetch content that your JavaScript code can grab in one line?)</li>
</ul>
</blockquote>
<p><span id="more-53"></span><br />
Selby will also get hands-on with a live demonstration of how to:</p>
<ul>
<li>Create JSON data services for your Ajax, Flash, Flex and Silverlight apps</li>
<li>Implement JavaScript RMI</li>
<li>Use your favorite Ajax libraries server-side.</li>
<li>Manipulate the DOM server-side</li>
<li>Talk to databases, file systems, networks, and remote sites or services (cross-domain XHRs are now a possibility!</li>
</ul>
<p>The session will show Web developers how they can put their JavaScript skills to work on the server side using technologies like Mozilla Rhino and <a href="http://www.aptana.com/jaxer" target="_blank">Aptana Jaxer</a>, which embeds the entire Mozilla browser on the server side.</p>
<h2>About AjaxWorld&#8230;</h2>
<p>AJAXWorld RIA Conference &#038; Expo 2008 West<br />
The days when AJAX is the only game in town are over, and the 6th International AJAXWorld RIA Conference &#038; Expo in San Jose, CA, on October 20-22, 2008 is your chance to come and see it and hear it for yourself.</p>
<p>Because it&#8217;s easy to misjudge priorities and invest in the wrong technology, AJAXWorld will help you invest in the right one for your particular business. It will help you find the optimal balance between business needs, technology potential, and enhanced user experience. AJAXWorld RIA Conference &#038; Expo 2008 West is where you can find what you&#8217;re going to need for business survival and Web success in 2008, 2009 and beyond.</p>
<p>AJAXWorld&#8217;s 80+ technical sessions, Keynotes, Power Panels and General Session Demos will help you determine which Rich Internet Technology will provide the most meaningful impact in your business, organization or service. The conference program aims to inform and inspire you toward the detailed implementation plan that you&#8217;re going to need in the next 12 months in your own initiative whether that&#8217;s SaaS, financial services, healthcare, enterprise portals, ISV applications, or whatever.</p>
<p>The Expo floor additionally will allow you to follow up on the premier solutions already available and to choose which best suits your needs.</p>
<p><a href="http://www.ajaxworld.com/" target="_blank">http://www.ajaxworld.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/server-side-javascript-all-the-cool-kids-are-doing-it/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Make Your JavaScript Data Model Smarter - With Object.Event</title>
		<link>http://www.gen-x-design.com/archives/make-your-data-javascript-data-model-smarter/</link>
		<comments>http://www.gen-x-design.com/archives/make-your-data-javascript-data-model-smarter/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 17:26:26 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/?p=50</guid>
		<description><![CDATA[As today&#8217;s web applications continue to evolve and get more complex, it has become a lot more commonplace to keep a data model present inside of your javascript.  You would then write various widgets, modules, or whatever that would get their data from the model, rather than querying some other web service independently (and [...]]]></description>
			<content:encoded><![CDATA[<p>As today&#8217;s web applications continue to evolve and get more complex, it has become a lot more commonplace to keep a data model present inside of your javascript.  You would then write various widgets, modules, or whatever that would get their data from the model, rather than querying some other web service independently (and if you aren&#8217;t doing this, you should!).  While centralizing all your data into a nice, organized model that different parts of your code can access, it&#8217;s often a challenge to integrate an efficient way to notify the code that depends on these models when the stored data is updated.  Lucky for us, <a href="http://livepipe.net/" target="_blank">Ryan Johnson</a> has created a  surprisingly small library that will allow our data model to notify anything that depends on it that it has updated (or loaded, or whatever you&#8217;d like in fact).</p>
<p>Before we dig in to the notifications, let&#8217;s do a little work to set up an example and some assumptions we&#8217;ll be operating under for the sake of this article.  First, as <a href="http://prototypejs.org" target="_blank">prototype</a> is my weapon of choice, that&#8217;s what we&#8217;ll be using.  We&#8217;ll also be using prototype as Object.Event uses it as well!  Now, let&#8217;s pretend that we have a website that has some social networking aspect of some kind.  We want to display a short list of who&#8217;s currently online (say the 6 most recently active people) in some sort of side bar, and perhaps a count of the total members online in a footer element.  Rather than having both these elements poll the server at some interval to update their information, let&#8217;s create a little data model that these areas can use instead.<br />
<span id="more-50"></span></p>
<h2>Step 1 - Create a Data Model</h2>
<p>For the sake of brevity, this will be stubbed out in a lot of places, but we&#8217;ll create enough functionality to get the concepts across.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> WhosOnlineSummary <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #006600;">create</span><span style="color: #009900;">&#40;</span>
<span style="color: #009900;">&#123;</span>
    initialize<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> initialize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">totalOnlineUsers</span>   <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">whosOnline</span>         <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Hash<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span>            <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// do our initial fetch</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">fetchUsers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// set this up to poll for new data every thirty seconds...</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">dataPoller</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> PeriodicalExecuter<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>pe<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">fetchUsers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    fetchUsers<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> fetchUsers<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// this would probably do some other stuff too</span>
&nbsp;
        <span style="color: #003366; font-weight: bold;">new</span> Ajax.<span style="color: #006600;">Request</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'/your/data/service'</span><span style="color: #339933;">,</span> 
        <span style="color: #009900;">&#123;</span>
            onComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>response<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">update</span><span style="color: #009900;">&#40;</span>response.<span style="color: #006600;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    update<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// and you'd have some sort of logic</span>
        <span style="color: #006600; font-style: italic;">// here to update the data... here's a stub..</span>
&nbsp;
&nbsp;
        <span style="color: #006600; font-style: italic;">// I'm assuming the data returned is a JSON object here...</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'totalOnlineUsers'</span> <span style="color: #000066; font-weight: bold;">in</span> data<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">totalOnlineUsers</span> <span style="color: #339933;">=</span> data.<span style="color: #006600;">totalOnlineUsers</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// and update our &quot;who's online&quot; stuff...</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onlineUsers'</span> <span style="color: #000066; font-weight: bold;">in</span> data<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// simple way to refresh, just kill the current list :)</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">whosOnline</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Hash<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// pretend online users is an array of json objects here...</span>
            <span style="color: #006600; font-style: italic;">// [ { id: userId, name: username, etc.}, {...}, ... ]</span>
            data.<span style="color: #006600;">onlineUsers</span>.<span style="color: #006600;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>user<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">whosOnline</span>.<span style="color: #006600;">set</span><span style="color: #009900;">&#40;</span>user.<span style="color: #006600;">id</span><span style="color: #339933;">,</span> user<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// get this globally namespaced... we'll just declare it here for</span>
<span style="color: #006600; font-style: italic;">// the sake of keeping things easy... you probably shouldn't do </span>
<span style="color: #006600; font-style: italic;">// this in real life ;)</span>
<span style="color: #003366; font-weight: bold;">var</span> whosOnline <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
&nbsp;
Event.<span style="color: #006600;">observe</span><span style="color: #009900;">&#40;</span>window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    whosOnline <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> WhosOnlineSummary<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>OK, as you can see, we&#8217;ve got a very simple data model that updates itself every thirty seconds, and that our other &#8220;widgets&#8221; can easily tap into for their information.  I&#8217;m not going to write these widgets out to any great extent, but I will create a small stub for the total online users functionality to help us out here.</p>
<h2>Step 2 - Create Some Widgets</h2>
<p>Now that we have a model, let&#8217;s start leveraging it to do something meaningful.  As I just mentioned, this is only a stub, but it should give you a nice idea of where we&#8217;re going&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> TotalOnlineUsers <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #006600;">create</span><span style="color: #009900;">&#40;</span>
<span style="color: #009900;">&#123;</span>
    initialize<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">domElement</span> <span style="color: #339933;">=</span> element<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// any other useful variables could go here...</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">parseOnlineUsers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    parseOnlineUsers<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> parseOnlineUsers<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// nice and simple ;)</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">domElement</span>.<span style="color: #006600;">update</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Currently '</span> <span style="color: #339933;">+</span> whosOnline.<span style="color: #006600;">totalOnlineUsers</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' users online'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And now we&#8217;re essentially ready to do some fun stuff.  As you can see, all this looks nice, but our TotalOnlineUsers widget has no way of knowing when it needs to update the display, as there&#8217;s no way to know when the data model has changed.  Enter Object.Event&#8230;</p>
<h2>Step 3 - Make Your Data Model Smart</h2>
<p>So, we need to get our data model publishing events that our widgets can listen for.  This is actually pretty darn simple since all the heavy lifting has been done for us.  Let&#8217;s go ahead and leverage the power of Object.Event (I&#8217;ll provide download links at the end of this article).  The first thing we need to do is provide the data model with the &#8220;event&#8221; functionality.  This is a simple one-liner that we can put right after our class declaration.  It looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">...
 <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
Object.<span style="color: #006600;">Event</span>.<span style="color: #006600;">extend</span><span style="color: #009900;">&#40;</span>WhosOnlineSummary<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>That&#8217;s it!  Now, all that remains for us to do is to create events inside this object that can be observed (we&#8217;ll cover the actual observing shortly).  This is done through simple additions of &#8220;notify&#8221; functions.  Since we&#8217;ve extended our data model class, this is also a cinch.  I&#8217;ll modify the update function to include two &#8220;events&#8221;:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript">...
    <span style="color: #006600;">update</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> update<span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// and you'd have some sort of logic</span>
        <span style="color: #006600; font-style: italic;">// here to update the data... here's a stub..</span>
&nbsp;
&nbsp;
        <span style="color: #006600; font-style: italic;">// I'm assuming the data returned is a JSON object here...</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'totalOnlineUsers'</span> <span style="color: #000066; font-weight: bold;">in</span> data<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">totalOnlineUsers</span> <span style="color: #339933;">=</span> data.<span style="color: #006600;">totalOnlineUsers</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// and update our &quot;who's online&quot; stuff...</span>
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'onlineUsers'</span> <span style="color: #000066; font-weight: bold;">in</span> data<span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #006600; font-style: italic;">// simple way to refresh, just kill the current list :)</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">whosOnline</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Hash<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
            <span style="color: #006600; font-style: italic;">// pretend online users is an array of json objects here...</span>
            <span style="color: #006600; font-style: italic;">// [ { id: userId, name: username, etc.}, {...}, ... ]</span>
            data.<span style="color: #006600;">onlineUsers</span>.<span style="color: #006600;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>user<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">whosOnline</span>.<span style="color: #006600;">set</span><span style="color: #009900;">&#40;</span>user.<span style="color: #006600;">id</span><span style="color: #339933;">,</span> user<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">loading</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">notify</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'whosOnlineLoaded'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">notify</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'whosOnlineUpdate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
...</pre></div></div>

<p>As you can see, we can create any custom events that we want, and we can name them whatever we want.  Pretty cool stuff, huh?  So, there&#8217;s only one thing that remains, and that&#8217;s making our widget listen for these events.</p>
<h2>Step 4 - Make our Widgets Listen for Events</h2>
<p>You&#8217;ll notice I created two events in our data model, but we&#8217;re only going to use one for this example.  Let&#8217;s get right to it, as there&#8217;s no real need for explanation here&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="javascript"><span style="color: #003366; font-weight: bold;">var</span> TotalOnlineUsers <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">Class</span>.<span style="color: #006600;">create</span><span style="color: #009900;">&#40;</span>
<span style="color: #009900;">&#123;</span>
    initialize<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>element<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">domElement</span> <span style="color: #339933;">=</span> element<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// any other useful variables could go here...</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// watch for updates from the data model</span>
        whoseOnline.<span style="color: #006600;">observe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'whosOnlineUpdate'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">parseOnlineUsers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#125;</span>.<span style="color: #006600;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">parseOnlineUsers</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
    parseOnlineUsers<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> parseOnlineUsers<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// nice and simple ;)</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">domElement</span>.<span style="color: #006600;">update</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Currently '</span> <span style="color: #339933;">+</span> whosOnline.<span style="color: #006600;">totalOnlineUsers</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">' users online'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Done.  It&#8217;s really that easy!</p>
<h2>Wrapping Up</h2>
<p>Hopefully, you can see the huge benefit of approaching your apps this way, and integrating Object.Event.  If you&#8217;ll remember, our so-called page also has a who&#8217;s online list.  You could create a widget that also observes the &#8220;whosOnlineUpdate&#8221; event, so it will update whenever the model changes as well.  We&#8217;ve effectively made the load on the server smaller, since we&#8217;ve only got one thing calling our data service, instead of 2 (in this case, but I&#8217;m sure there are many practical applications that would have many more somewhat redundant calls).  We also know that our presentation will be in sync across all the different elements on this page, which leads to a much slicker user experience.  The best part of all this? We&#8217;ve made very, very small tweaks to our code, and they were very unobtrusive as well.  Enjoy, and thank Ryan for his bad-ass javascript kung-fu if you&#8217;ve got a moment!</p>
<p>As promised, here are your links to all the required libraries:</p>
<ul>
<li><a href="http://livepipe.net/projects/object_event/" target="_blank">Object.Event - Created by Ryan Johnson</a></li>
<li><a href="http://prototypejs.org" target="_blank">Prototype Framework</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/make-your-data-javascript-data-model-smarter/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Nice Tutorial: CSS Decorative Gallery</title>
		<link>http://www.gen-x-design.com/archives/nice-tutorial-css-decorative-gallery/</link>
		<comments>http://www.gen-x-design.com/archives/nice-tutorial-css-decorative-gallery/#comments</comments>
		<pubDate>Thu, 29 May 2008 21:11:52 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
		
		<category><![CDATA[Asides]]></category>

		<guid isPermaLink="false">http://www.gen-x-design.com/archives/nice-tutorial-css-decorative-gallery/</guid>
		<description><![CDATA[Stumbled across this in my pile &#8216;o feeds&#8230; nice collection of css-based image decorations for galleries (or whatever you want).  Check out the tutorial over at Web Designer Wall:
CSS Decorative Gallery
]]></description>
			<content:encoded><![CDATA[<p>Stumbled across this in my pile &#8216;o feeds&#8230; nice collection of css-based image decorations for galleries (or whatever you want).  Check out the tutorial over at Web Designer Wall:<br />
<a href="http://www.webdesignerwall.com/tutorials/css-decorative-gallery/" target="_blank">CSS Decorative Gallery</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.gen-x-design.com/archives/nice-tutorial-css-decorative-gallery/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
