<?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; jQuery</title>
	<atom:link href="http://www.barklund.org/blog/category/programming/javascript/jquery/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>Copy-Paste Injection &#8211; January 2010 Ideas</title>
		<link>http://www.barklund.org/blog/2010/01/16/copy-paste-injection-january-2010-idea/</link>
		<comments>http://www.barklund.org/blog/2010/01/16/copy-paste-injection-january-2010-idea/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 08:00:50 +0000</pubDate>
		<dc:creator>Barklund</dc:creator>
				<category><![CDATA[DOM 2 Traversal and Range]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[January 2010 Ideas]]></category>
		<category><![CDATA[Online Rights]]></category>
		<category><![CDATA[Trends]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.barklund.org/blog/?p=614</guid>
		<description><![CDATA[The sixteenth idea for my 365 social ideas is an idea for a technical tool to assist everyone in getting the credit they deserve and the loyalty they can expect: a copy-paste injection script. It is the very same idea that tynt.com has &#8220;created&#8221;, but they keep the technology (how simple it may be) to [...]


Related posts:<ol><li><a href='http://www.barklund.org/blog/2010/01/22/social-traffic-analyzer-january-2010-idea/' rel='bookmark' title='Permanent Link: Social Traffic Analyzer &#8211; January 2010 Ideas'>Social Traffic Analyzer &#8211; January 2010 Ideas</a></li>
<li><a href='http://www.barklund.org/blog/2010/01/09/comment-on-everything-january-2010-idea/' rel='bookmark' title='Permanent Link: Comment On Everything &#8211; January 2010 Ideas'>Comment On Everything &#8211; January 2010 Ideas</a></li>
<li><a href='http://www.barklund.org/blog/2010/01/07/app-idea-store-january-2010-idea/' rel='bookmark' title='Permanent Link: App Idea Store &#8211; January 2010 Ideas'>App Idea Store &#8211; January 2010 Ideas</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<p>The sixteenth idea for my <a href="/blog/365ideas/" title="365 Social Ideas from Barklund.org">365 social ideas</a> is an idea for a technical tool to assist everyone in getting the credit they deserve and the loyalty they can expect: a copy-paste injection script. It is the very same idea that <a href="http://www.tynt.com/" title="Tynt.com">tynt.com</a> has &#8220;created&#8221;, but they keep the technology (how simple it may be) to themselves and have <a href="http://www1.tynt.com/patents" title="Tynt.com about patents">even filed for a patent</a>.</p>
<p><span id="more-614"></span></p>
<p>Well, I have implemented a <a href="/examples/copypaste">very simple demo</a> of the first steps. So far, <a href="/examples/copypaste/jquery.copypaste.js">the script</a> only makes sure to add some extra text to the current selection when ever the mouse button is released (which is how most users select most text) and it only works in Firefox (tested in 3.6). Next steps include making the link direct to the actually selected content, record text copying in Google Analytics, add cross-browser checks etc.</p>
<p>The script is published under the same license as these ideas, CC-BY 3.0.</p>
<h4 id="toc-why">Why?</h4>
<p>Copy-paste is another quite common way of interacting with websites and allowing people to easily spread the word about your website in a new way ensures you credit where such is due. Creating a full-featured jQuery-plugin from this should be fairly easy and then making sure it integrates with Google Analytics if present &#8211; and then we&#8217;re actually done.</p>
<h4 id="toc-whats-next">What&#8217;s next?</h4>
<p>Do with this idea whatever you like &#8211; expand, implement, trash or forget. Just remember, that if you use it in anyway make sure to attribute me according to the Creative Commons Attribution 3.0 License, that all these <a href="/blog/365ideas" title="365 Social Ideas from Barklund.org">365 Social Ideas</a> are published under.</p>


<p>Related posts:<ol><li><a href='http://www.barklund.org/blog/2010/01/22/social-traffic-analyzer-january-2010-idea/' rel='bookmark' title='Permanent Link: Social Traffic Analyzer &#8211; January 2010 Ideas'>Social Traffic Analyzer &#8211; January 2010 Ideas</a></li>
<li><a href='http://www.barklund.org/blog/2010/01/09/comment-on-everything-january-2010-idea/' rel='bookmark' title='Permanent Link: Comment On Everything &#8211; January 2010 Ideas'>Comment On Everything &#8211; January 2010 Ideas</a></li>
<li><a href='http://www.barklund.org/blog/2010/01/07/app-idea-store-january-2010-idea/' rel='bookmark' title='Permanent Link: App Idea Store &#8211; January 2010 Ideas'>App Idea Store &#8211; January 2010 Ideas</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.barklund.org/blog/2010/01/16/copy-paste-injection-january-2010-idea/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<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>
	</channel>
</rss>
