<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><atom:link rel="hub" href="http://tumblr.superfeedr.com/" xmlns:atom="http://www.w3.org/2005/Atom"/><description>The thoughts and opinions of a JavaScript Programmer.</description><title>Robert Hurst</title><generator>Tumblr (3.0; @roberthurst)</generator><link>http://roberthurst.ca/</link><item><title>OriginJS - Every Route Begins at the Origin</title><description>&lt;h1&gt;Get it&lt;/h1&gt;

&lt;p&gt;You can get a copy of OriginJS from my &lt;a href="https://github.com/RobertWHurst/OriginJS" target="_blank"&gt;Github repository&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;Getting Started&lt;/h1&gt;

&lt;p&gt;First include origin.js in your page. You can do this with a script tag in the head of your page, or you can 
load it with &lt;a href="http://requirejs.org/" target="_blank"&gt;require.js&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Using Origin is very easy. Here’s a very basic example.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Origin.bind('/', function() {

    //home page logic goes here
    //loaded on /#/ or /

});

Origin.bind('/about', function() {

    //about page logic goes here
    //loaded on /#/about

});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Your links would look like this.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&lt;nav&gt;
    &lt;a href="#/"&gt;Home&lt;/a&gt;
    &lt;a href="#/about"&gt;About&lt;/a&gt;
&lt;/nav&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is far to simple an example for serious applications though so here is an example with a bit more complexity.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Origin.bind(['/:user/:profilePage', '/:user/:profilePage/+'], function(uris, data) {

    //will match hash urls such as
    // /#/RobertWHurst/Wall/
    // or even
    // /#/John_01/About/Data/1/0/1

    //get the dynamic data
    var user = data.user,
        profilePage = data.profilePage,
        profilePageSubUris = uris.splice(2);

    // load profile code here

}, function(uris, data) {

    //cleanup code for profile here

});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see there is an optional callback for cleaning up when a different route is loaded. Also both callbacks get two
arguments. The first is an array with each uri from the current url in the location hash. Even more interesting is the
&lt;code&gt;:user&lt;/code&gt; and &lt;code&gt;:profilePage&lt;/code&gt; uris in the bind rules. These are id uris and capture any uri in the corresponding position
in the hash url. The uri value gets added to the data object passed to the callback under a key by the same name as the
rule uri. Here’s an example of what I mean.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Rule Uri = :user
            so           data.user === 'RobertWHurst'
Hash Uri = RobertWHurst
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;There there are two other operators you can use in your routes. The catchall, &lt;code&gt;+&lt;/code&gt;, and the wild card uri, &lt;code&gt;*&lt;/code&gt;. Catchalls
are self explanatory they will match any uri and all that follow it. Good for things like 404 or black hole pages.
Wildcards match like id Uris except the do not save the hash uri value to the data array.&lt;/p&gt;

&lt;h1&gt;Don’t use location.hash to change routes!&lt;/h1&gt;

&lt;p&gt;You don’t always want to use anchor tags to navigate your app. Sometimes you want to do this programatically. You can use
location.hash if you really want to, it will work but you shouldn’t. Origin has a method for redirecting to other places.
Its called &lt;code&gt;Origin.go&lt;/code&gt; and can be uses as follows.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;//If a route has been set for /home this will redirect to /#/home/. if no route exists it will redirect /home/
Origin.go('/home');

//Opens a new tab (or window) containing &lt;a href="http://google.com/" target="_blank"&gt;http://google.com/&lt;/a&gt;
Origin.go('http://google.com/');

//holding control while ether of these fire will yield a new tab (or window) regardless of the passed url.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As you can see above &lt;code&gt;Origin.go(url)&lt;/code&gt; Allows to to load any page you like, not just hash routes. You don’t even have to think
about it. Its predictable and yet feels magical. The choice is yours but I would highly recommend &lt;code&gt;Origin.go(url)&lt;/code&gt; over
&lt;code&gt;location.hash&lt;/code&gt;.&lt;/p&gt;

&lt;h1&gt;Documentation&lt;/h1&gt;

&lt;h2&gt;Bind&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;Origin.bind(route, entryCallback[, exitCallback]);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This method is the corner stone of this library. It binds your route logic to the routes of your application.&lt;/p&gt;

&lt;h3&gt;Arguments&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;route&lt;/code&gt;: The route you wish to bind. The route can contain dynamic uris such as &lt;code&gt;*&lt;/code&gt;, &lt;code&gt;+&lt;/code&gt;, or &lt;code&gt;:someIdHere&lt;/code&gt;.
&lt;code&gt;entryCallback&lt;/code&gt;: The callback that will be executed when you route has been followed.
&lt;code&gt;exitCallback&lt;/code&gt;: The callback that will be executed when a different route is loaded.&lt;/p&gt;

&lt;p&gt;Both the entry callback and the exit callback are passed two arguments; the uris from the hash url, and an object with
data from any &lt;code&gt;:someIdHere&lt;/code&gt;s you may have in your route.&lt;/p&gt;

&lt;h2&gt;Go&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;Origin.go(url);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;At some point you may want to trigger routes or open other pages programatically. This is what &lt;code&gt;Origin.go(url)&lt;/code&gt; is for.
If &lt;code&gt;Origin.bind&lt;/code&gt; is ying, &lt;code&gt;Origin.go&lt;/code&gt; is yang.&lt;/p&gt;

&lt;h3&gt;Arguments&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;url&lt;/code&gt;: Any url you wish to follow. If the url is pointing to a binded route the router will load that route. No need to
prefix with &lt;code&gt;/#&lt;/code&gt;. If the url is not pointing to a binded route it will redirect to the url. If the url contains a domain
it will open the url in a new tab (or window).&lt;/p&gt;

&lt;h2&gt;Update&lt;/h2&gt;

&lt;pre&gt;&lt;code&gt;Origin.update();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;code&gt;Origin.update&lt;/code&gt; method should never need to be called, however in the event that something weird happens, for example
your application looses focus on a hash change event, calling this function will force Origin to re check the hash and
execute matching routes.&lt;/p&gt;

&lt;h1&gt;Credits&lt;/h1&gt;

&lt;p&gt;I (Robert Hurst) made this to enable me to build more robust applications without wasting time creating a half baked 
router. I’d like to share it with fellow devs. Feel free to fork this project and make your own changes.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://coderwall.com/robertwhurst" target="_blank"&gt;&lt;img src="http://api.coderwall.com/robertwhurst/endorsecount.png" alt="endorse"/&gt;&lt;/a&gt;&lt;/p&gt;</description><link>http://roberthurst.ca/post/16805365987</link><guid>http://roberthurst.ca/post/16805365987</guid><pubDate>Mon, 30 Jan 2012 20:54:00 -0800</pubDate><category>JavaScript</category><category>Client-Side</category></item><item><title>Normalize your CSS without the "black-box" reset</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lx73wlieSn1qcr35u.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;I recently discovered &lt;a href="http://necolas.github.com/normalize.css/" target="_blank"&gt;normalize.css&lt;/a&gt; and I’m really quite enjoying it. I know, CSS resets aren’t the most exciting thing in the universe but they can have a serious effect on the impact of your design across various browsers.&lt;/p&gt;

&lt;p&gt;Most CSS resets take the approach that the designer will want to start from scratch without any defaults. This solves the problem with designing across browsers in theory but it leaves a lot of boilerplate type work for the designer which is really why browsers have defaults to begin with.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://necolas.github.com/normalize.css/" target="_blank"&gt;normalize.css&lt;/a&gt; solves this problem, It isn’t simply a reset, its a cross browser default, and unlike most CSS resets which don’t really cover everything, &lt;a href="http://necolas.github.com/normalize.css/" target="_blank"&gt;normalize.css&lt;/a&gt; takes itself seriously and covers most if not all elements (even those introduced in HTML5). Check out the [demo] (&lt;a href="http://necolas.github.com/normalize.css/demo.html" target="_blank"&gt;http://necolas.github.com/normalize.css/demo.html&lt;/a&gt;) and give it a try. If your intrigued then grab a copy from &lt;a href="https://github.com/necolas/normalize.css" target="_blank"&gt;Nicolas Gallagher’s repository&lt;/a&gt;.&lt;/p&gt;</description><link>http://roberthurst.ca/post/15210262665</link><guid>http://roberthurst.ca/post/15210262665</guid><pubDate>Mon, 02 Jan 2012 16:06:15 -0800</pubDate></item><item><title>The Business Value of Open Web Technology</title><description>&lt;a href="http://mtresidence.net/the-business-value-of-open-web-technology"&gt;The Business Value of Open Web Technology&lt;/a&gt;</description><link>http://roberthurst.ca/post/15050589237</link><guid>http://roberthurst.ca/post/15050589237</guid><pubDate>Fri, 30 Dec 2011 15:35:36 -0800</pubDate></item><item><title>Updated to iOS 5.1 and it seems to have fixed memory issues. Feels a lot smoother.</title><description>&lt;p&gt;Updated to iOS 5.1 and it seems to have fixed memory issues. Feels a lot smoother.&lt;/p&gt;</description><link>http://roberthurst.ca/post/14607584302</link><guid>http://roberthurst.ca/post/14607584302</guid><pubDate>Wed, 21 Dec 2011 23:17:30 -0800</pubDate></item><item><title>Incase you haven’t seen my key binding library KeyboardJS...</title><description>&lt;iframe width="400" height="300" src="http://www.youtube.com/embed/mOtUXRrB350?wmode=transparent&amp;autohide=1&amp;egm=0&amp;hd=1&amp;iv_load_policy=3&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;showsearch=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Incase you haven’t seen my key binding library KeyboardJS heres a preview.&lt;/p&gt;</description><link>http://roberthurst.ca/post/14604138686</link><guid>http://roberthurst.ca/post/14604138686</guid><pubDate>Wed, 21 Dec 2011 21:37:52 -0800</pubDate></item><item><title>Home finally! I wrote a whole router module for UnityJS today. Only took me six hours and it’s...</title><description>&lt;p&gt;Home finally! I wrote a whole router module for UnityJS today. Only took me six hours and it’s surprisingly elegant. Time for some wine and reddit.&lt;/p&gt;</description><link>http://roberthurst.ca/post/14603108643</link><guid>http://roberthurst.ca/post/14603108643</guid><pubDate>Wed, 21 Dec 2011 21:12:42 -0800</pubDate></item><item><title>Minecraft is a pretty awesome toy.</title><description>&lt;iframe width="400" height="225" src="http://www.youtube.com/embed/vlu2yNdjpq8?wmode=transparent&amp;autohide=1&amp;egm=0&amp;hd=1&amp;iv_load_policy=3&amp;modestbranding=1&amp;rel=0&amp;showinfo=0&amp;showsearch=0" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;&lt;br/&gt;&lt;br/&gt;&lt;p&gt;Minecraft is a pretty awesome toy.&lt;/p&gt;</description><link>http://roberthurst.ca/post/14598052125</link><guid>http://roberthurst.ca/post/14598052125</guid><pubDate>Wed, 21 Dec 2011 19:22:17 -0800</pubDate></item><item><title>Unity now has a router! It supports route cascading, wildcards, and variable URIs.</title><description>&lt;p&gt;Unity now has a router! It supports route cascading, wildcards, and variable URIs.&lt;/p&gt;</description><link>http://roberthurst.ca/post/14583757709</link><guid>http://roberthurst.ca/post/14583757709</guid><pubDate>Wed, 21 Dec 2011 14:49:12 -0800</pubDate></item><item><title>Path is excellent</title><description>&lt;p&gt;&lt;img src="http://media.tumblr.com/tumblr_lwkicnQ5WF1qcr35u.png" alt=""/&gt;&lt;/p&gt;

&lt;p&gt;Path is a great iPhone and android app for micro blogging. I’ve been using it for two days now and I’ve found it to be really effortless. The truth is I’m lazy and would rather program then write posts all day. Path allows me to quickly update my “path” with simple tweet sized posts. Anything can be cc’d to twitter, tumblr, facebook, foursquare. On top of all that the interface is stunning!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://path.com/" target="_blank"&gt;Check it out&lt;/a&gt;&lt;/p&gt;</description><link>http://roberthurst.ca/post/14572669795</link><guid>http://roberthurst.ca/post/14572669795</guid><pubDate>Wed, 21 Dec 2011 11:05:34 -0800</pubDate><category>Path</category><category>Microblogging</category><category>Socal Networking</category></item><item><title>Photo</title><description>&lt;img src="http://25.media.tumblr.com/tumblr_lwkdl3w5Ps1qcgfyao1_500.jpg"/&gt;&lt;br/&gt;&lt;br/&gt;</description><link>http://roberthurst.ca/post/14568595775</link><guid>http://roberthurst.ca/post/14568595775</guid><pubDate>Wed, 21 Dec 2011 09:22:12 -0800</pubDate></item><item><title>Good morning everyone!</title><description>&lt;p&gt;Good morning everyone!&lt;/p&gt;</description><link>http://roberthurst.ca/post/14566004269</link><guid>http://roberthurst.ca/post/14566004269</guid><pubDate>Wed, 21 Dec 2011 08:09:00 -0800</pubDate></item><item><title>Working on UnityJS. I can’t wait to show off the API.</title><description>&lt;p&gt;Working on UnityJS. I can’t wait to show off the API.&lt;/p&gt;</description><link>http://roberthurst.ca/post/14552190664</link><guid>http://roberthurst.ca/post/14552190664</guid><pubDate>Tue, 20 Dec 2011 22:12:17 -0800</pubDate></item></channel></rss>

