<?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>Barklund.org &#187; HTML 5</title>
	<atom:link href="http://www.barklund.org/blog/category/programming/html/html-5/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.barklund.org/blog</link>
	<description>work smarter when building current web trends</description>
	<lastBuildDate>Wed, 26 May 2010 09:49:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Datasets in HTML 5 and what they&#8217;re good for</title>
		<link>http://www.barklund.org/blog/2009/08/28/html-5-datasets/</link>
		<comments>http://www.barklund.org/blog/2009/08/28/html-5-datasets/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 10:55:12 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Trends]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/?p=317</guid>
		<description><![CDATA[Datasets are quite an un-impressive part of the HTML 5 specification. It is only accompanied by two examples, of which the first is relevant but small and the latter is (in my view) completely besides the potential of this new functionality. Datasets are in short a way to store custom values on nodes in the [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/' rel='bookmark' title='Permanent Link: Web Sockets in HTML 5 might solve the http pull problem once and for all'>Web Sockets in HTML 5 might solve the http pull problem once and for all</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>Datasets are quite an <a href="http://dev.w3.org/html5/spec/Overview.html#embedding-custom-non-visible-data">un-impressive part of the HTML 5 specification</a>. It is only accompanied by two examples, of which the first is relevant but small and the latter is (in my view) completely besides the potential of this new functionality. Datasets are in short a way to store custom values on nodes in the DOM tree. This has always been possible when working client-side through JavaScript by keeping a mapping between the nodes and the values stored, which meant that the values weren&#8217;t actually stored <em>on</em> the nodes, but just related to the nodes elsewhere (e.g. using <a href="http://docs.jquery.com/Internals/jQuery.data" title="Documentation for the jQuery.data plugin">jQuery.data</a>).</p>
<p>With HTML 5 and the introduction of datasets, we can do something new. The main advantage and the really huge application area for datasets are, that you can include custom attributes in the serverside-rendered HTML, that the client-side script will use to enhance the browsing experience.</p>
<p><span id="more-317"></span></p>
<p>A common example: You have a gallery page, which has an area for displaying a large image and one for a list of thumbnails. In the serverside-rendered HTML you render the first picture in the large image and a list of thumbnails below. In javaScript you hook a function for each thumbnail to change the large image. But where do you supply the path for the large image? It could be done via several methods:
<ul>
<li>from the server render a JavaScript-array that do the mapping,</li>
<li>have a strict naming-convention, and e.g. always remove &#8220;-thumb&#8221; from the thumbnail path to obtain the large image path,</li>
<li>hide it on the node by abusing some existing legal property &#8211; e.g. hide it in the title-field of the thumbnail, or</li>
<li>add it is a new property on the node, that will make your document non-compliant with the standard.</li>
</ul>
<p>But with datasets, the server simply includes the large image path on the thumbnail image node (or the surrounding link node) via a custom data-attribute here named <code>data-fullpath</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span></span>
<span style="color: #009900;">  <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;large-image&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/large/picture1.png&quot;</span></span>
<span style="color: #009900;">  <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Large Picture 1&quot;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ul</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;thumbnails&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;gallery_with_picture1_enlarged.html&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;View Picture 1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span></span>
<span style="color: #009900;">        <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/thumbs/picture1.png&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">data-fullpath</span>=<span style="color: #ff0000;">&quot;images/large/picture1.png&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Picture 1&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;gallery_with_picture2_enlarged.html&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;View Picture 2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span></span>
<span style="color: #009900;">        <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/thumbs/picture2.png&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">data-fullpath</span>=<span style="color: #ff0000;">&quot;images/large/picture2.png&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Picture 2&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;gallery_with_picture3_enlarged.html&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;View Picture 3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span></span>
<span style="color: #009900;">        <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;images/thumbs/picture3.png&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">data-fullpath</span>=<span style="color: #ff0000;">&quot;images/large/picture147_no_conventions.png&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;Picture 3&quot;</span></span>
<span style="color: #009900;">      <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/li<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/ul<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p><s>Of course, in live implementation the links above would link to pages, where the other thumbnails where shown in the large area to allow for graceful degradation, but this is just to show the idea.</s> The above example have now been updated to provide actually interesting links in the surrounding <code>&lt;a></code>-tags and not just link to the image as several have suggested.</p>
<p>The JavaScript that went with this would be something along the lines of (asuming jQuery.dataset functionality):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ul#thumbnails a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">click</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#large-image&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;src&quot;</span><span style="color: #339933;">,</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: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;img&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dataset</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'fullpath'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">return</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;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>See <a href="http://barklund.org/examples/html5/datasets/" title="Example page at barklund.org">full example here</a> &#8211; it works in all browsers, and is <a href="http://validator.w3.org/check?uri=http%3A%2F%2Fbarklund.org%2Fexamples%2Fhtml5%2Fdatasets%2F" title="Validation result for example page">valid HTML 5</a>. The JavaScript works in non-HTML5 browsers, as it includes a <a href="http://plugins.jquery.com/project/datasets" title="Description of my plugin for datasets for jQuery">little jQuery plugin I wrote</a> adding the method <code>dataset</code>, which includes a fallback if the DOM attribute &#8220;dataset&#8221; is not available.</p>
<p>I personally find this to be a very clean way of implementing this feature over the many hacks, that we need to use today. And this is of course not limited to galleries, but can be used for anything, where the script needs to know extra information about the objects in the document in order to add additional functionality through scripts on the page &#8211; this could include having a reference to &#8220;previous&#8221; or &#8220;next&#8221; image in the above gallery, meta-information about rows in a table to use for client-side searching, filtering or sorting, meta data for link previews and many other possibilities.</p>
<p>NB: This is <strong>not</strong> to be used as meta-data for external entities &#8211; only for scripts on the page enhancing the browsing experience. For providing meta-data for external entities, use <a href="http://dev.w3.org/html5/spec/Overview.html#microdata" title="The microdata section in the HTML 5 specification">microdata</a>, which is completely different from datasets &#8211; but the two could be used to convey the same meta information, just with different recipients in mind.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/' rel='bookmark' title='Permanent Link: Web Sockets in HTML 5 might solve the http pull problem once and for all'>Web Sockets in HTML 5 might solve the http pull problem once and for all</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2009/08/28/html-5-datasets/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Web Sockets in HTML 5 might solve the http pull problem once and for all</title>
		<link>http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/</link>
		<comments>http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/#comments</comments>
		<pubDate>Thu, 20 Aug 2009 10:28:22 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[Flash Platform]]></category>
		<category><![CDATA[HTML 5]]></category>
		<category><![CDATA[Trends]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/?p=283</guid>
		<description><![CDATA[The truth be told, us ActionScript programmers have always had it easy when it came to creating real-time, multi-user applications. We might not have had much processing power back then, but as early as Flash 5 introduced back in 2000, we got the XMLSocket object, which enabled a whole series of multi-user-applications like isometric chat [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/08/28/html-5-datasets/' rel='bookmark' title='Permanent Link: Datasets in HTML 5 and what they&#8217;re good for'>Datasets in HTML 5 and what they&#8217;re good for</a></li>
<li><a href='http://www.barklund.org/blog/2009/07/06/flash-development-scripted-layout/' rel='bookmark' title='Permanent Link: Flash development and the practice of Scripted Layout'>Flash development and the practice of Scripted Layout</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The truth be told, us ActionScript programmers have always had it easy when it came to creating real-time, multi-user applications. We might not have had much processing power back then, but as early as Flash 5 introduced back in 2000, we got the <a href="http://livedocs.adobe.com/flash/9.0/main/00002367.html" title="XMLSocket API reference in Adobe LiveDocs">XMLSocket</a> object, which enabled a whole series of multi-user-applications like isometric chat worlds etc. This leaves us JavaScript programmers a bit stranded. We do have Comet and similar technologies, but true persistent connections, we have never had &#8211; unless we used a Flash object in the document somewhere, but who wants to use Flash anyway?</p>
<p>But with the dawn of <a href="http://en.wikipedia.org/wiki/HTML_5" title="HTML 5 on Wikipedia">HTML 5</a>, this worry is irrelevant, because with HTML 5 and the greatly improved JavaScript API, we also get <a href="http://dev.w3.org/html5/websockets/" title="Web Sockets API from w3.org">a brand new Web Sockets API</a>. This will have the same basic low-level access to bi-directional communication as ActionScript got with the XMLSocket API &#8211; it wasn&#8217;t XML only, it was just the (widely used) default transport method, but it could easily be circumvented.</p>
<p>Quite stunning though, how such a simple mechanism arrives in JavaScript 10 years later than it did in ActionScript!</p>
<p><span id="more-283"></span></p>
<p>When this becomes standard in new browsers across vendors, we will see it implemented in so many popular applications, that currently use all sorts of tricks to achieve the same results &#8211; like <a href="http://www.facebook.com">Facebook</a>, who uses Comet to &#8220;push&#8221; JavaScript notifications. With this API, doing stuff like that becomes much easier and much cleaner. Or <a href="http://docs.google.com">Google Docs</a>, who use Comet as well as HTTP pulling. Or NFL live match view, who use a Flash object in the document to receive events about the match being watched.</p>
<p>And this of course also increase the opportunity for creating new multi-user applications &#8211; and games &#8211; in HTML and JavaScript. And given the extra computational strengths, that most JavaScript engines are being equipped with currently (Chrome started the race and IE8 perform surprisingly well), and given some of the other fun things in HTML 5 like canvas, things will really start to get interesting.</p>
<p>Go HTML 5 &#8211; get yourself final as soon as possible! Give us JavaScript programmers the same tools that we ActionScript programmers have had for a decade.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/08/28/html-5-datasets/' rel='bookmark' title='Permanent Link: Datasets in HTML 5 and what they&#8217;re good for'>Datasets in HTML 5 and what they&#8217;re good for</a></li>
<li><a href='http://www.barklund.org/blog/2009/07/06/flash-development-scripted-layout/' rel='bookmark' title='Permanent Link: Flash development and the practice of Scripted Layout'>Flash development and the practice of Scripted Layout</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>I strongly support HTML 5 adoption by w3</title>
		<link>http://www.barklund.org/blog/2007/04/13/i-strongly-support-html-5-adoption-by-w3/</link>
		<comments>http://www.barklund.org/blog/2007/04/13/i-strongly-support-html-5-adoption-by-w3/#comments</comments>
		<pubDate>Fri, 13 Apr 2007 08:57:18 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[API]]></category>
		<category><![CDATA[HTML 5]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/2007/04/13/i-strongly-support-html-5-adoption-by-w3/</guid>
		<description><![CDATA[Apple, Opera and Mozilla has expressed their support for the new HTML 5 specification as outlined by WHAT Working Group and chief spec-writer Ian Hickson and especially the adoption of this specification by w3 as the new HTML recommendation. Personally, the Web Forms 2 specification really gets me excited, and the overall proposal seems sane [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/08/28/html-5-datasets/' rel='bookmark' title='Permanent Link: Datasets in HTML 5 and what they&#8217;re good for'>Datasets in HTML 5 and what they&#8217;re good for</a></li>
<li><a href='http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/' rel='bookmark' title='Permanent Link: Web Sockets in HTML 5 might solve the http pull problem once and for all'>Web Sockets in HTML 5 might solve the http pull problem once and for all</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p><a href="http://apple.com" title="We love and hate them">Apple</a>, <a href="http://opera.com" title="When the ads left, I liked it again">Opera</a> and <a href="http://mozilla.org" title="I always liked them though!">Mozilla</a> has <a href="http://lists.w3.org/Archives/Public/public-html/2007Apr/0429.html" title="Proposal to Adopt HTML5">expressed their support</a> for the new <a href="http://www.whatwg.org/specs/web-apps/current-work/" title="Current draft">HTML 5 specification</a> as outlined by <a href="http://www.whatwg.org" title="The what WHAT?">WHAT Working Group</a> and chief <em>spec-writer</em> <a href="mailto:ian@hixie.ch" title="Mail only">Ian Hickson</a> and especially the adoption of this specification by <a href="http://w3.org" title="Conformance is buzz, but what a buzz!">w3</a> as the new HTML recommendation.</p>
<p><span id="more-24"></span></p>
<p>Personally, the <a href="http://www.w3.org/TR/web-forms-2/" title="select.data for the win">Web Forms 2 specification</a> really gets me excited, and the overall proposal seems sane and the most interesting and logical way to go. The <a href="http://www.w3.org/TR/html401" title="So many tags, but so few of them are structural">HTML 4.01</a> and <a href="http://www.w3.org/TR/xhtml11" title="Does anything conform?">XHTML 1.1</a> recommendations are getting old and certainly does not reflect modern web content.</p>
<p>Thus I strongly support the adoption as do so many others. And it will come &ndash; just hang in there.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2009/08/28/html-5-datasets/' rel='bookmark' title='Permanent Link: Datasets in HTML 5 and what they&#8217;re good for'>Datasets in HTML 5 and what they&#8217;re good for</a></li>
<li><a href='http://www.barklund.org/blog/2009/08/20/web-sockets-html-5-solve-http-pull/' rel='bookmark' title='Permanent Link: Web Sockets in HTML 5 might solve the http pull problem once and for all'>Web Sockets in HTML 5 might solve the http pull problem once and for all</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2007/04/13/i-strongly-support-html-5-adoption-by-w3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
