<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/rss-style.xsl" type="text/xsl"?>
<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>jquery &#8211; Terence Eden’s Blog</title>
	<atom:link href="https://shkspr.mobi/blog/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>https://shkspr.mobi/blog</link>
	<description>Regular nonsense about tech and its effects 🙃</description>
	<lastBuildDate>Thu, 16 Apr 2026 07:12:38 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://shkspr.mobi/blog/wp-content/uploads/2023/07/cropped-avatar-32x32.jpeg</url>
	<title>jquery &#8211; Terence Eden’s Blog</title>
	<link>https://shkspr.mobi/blog</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title><![CDATA[YQL and The Pirate Bay]]></title>
		<link>https://shkspr.mobi/blog/2012/05/yql-and-the-pirate-bay/</link>
					<comments>https://shkspr.mobi/blog/2012/05/yql-and-the-pirate-bay/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Wed, 02 May 2012 07:17:55 +0000</pubDate>
				<category><![CDATA[/etc/]]></category>
		<category><![CDATA[politics]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[legal]]></category>
		<category><![CDATA[piracy]]></category>
		<category><![CDATA[Star Wars]]></category>
		<category><![CDATA[the phantom menace]]></category>
		<category><![CDATA[the pirate bay]]></category>
		<category><![CDATA[yql]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=5649</guid>

					<description><![CDATA[For reasons best known to themselves, certain sections of the entertainment industries seem to believe that bolting the stable door shutting down The Pirate Bay will stop all piracy.  It&#039;s as though they think that people won&#039;t be able to use a proxy, circumvent the Cleanfeed block, or simply use a search engine to find another torrent site.  Build Your Own Pirate Bay?  Proxying is a very simple…]]></description>
										<content:encoded><![CDATA[<p>For reasons best known to themselves, certain sections of the entertainment industries seem to believe that <del datetime="2012-05-01T08:34:33+00:00">bolting the stable door</del> <a href="http://www.guardian.co.uk/technology/2012/apr/30/british-isps-block-pirate-bay">shutting down The Pirate Bay will stop all piracy</a>.</p>

<p>It's as though they think that people won't be able to use a proxy, circumvent the <a href="http://en.wikipedia.org/wiki/Cleanfeed_%28content_blocking_system%29">Cleanfeed</a> block, or simply use a search engine to find another torrent site.</p>

<h2 id="build-your-own-pirate-bay"><a href="https://shkspr.mobi/blog/2012/05/yql-and-the-pirate-bay/#build-your-own-pirate-bay">Build Your Own Pirate Bay?</a></h2>

<p>Proxying is a very simple concept.</p>

<ul>
    <li>Alice is forbidden from speaking to Bob.</li>
    <li>Alice can speak to Eve.</li>
    <li>Eve can speak to Bob.</li>
    <li>Alice, therefore, can use Eve to communicate with Bob.</li>
</ul>

<p>So, a user who wishes to access The Pirate Bay would have to do something quite complex to use a proxy?  No, this is all there is to it:</p>

<pre>SELECT * FROM html
WHERE url="https://thepiratebay.se/search/ubuntu/0/7/0"
AND xpath='//tr'</pre>

<p>This uses YQL and xpath to extract all the information from a Pirate Bay search (in this case, for Ubuntu - which is legally distributed through Bit Torrent).</p>

<p>Simply, this asks Yahoo (an American site) to contact The Pirate Bay (a Swedish site) to deliver information to a user in Britain.</p>

<p>You can play with the results yourself <a href="https://web.archive.org/web/20120504160649/http://developer.yahoo.com/yql/console/">in the Yahoo Console</a>.</p>

<p>This returns a JSON string which can then be easily parsed (e.g. using jQuery). Simple.</p>

<h2 id="aha-but-what-about-downloading-a-torrent"><a href="https://shkspr.mobi/blog/2012/05/yql-and-the-pirate-bay/#aha-but-what-about-downloading-a-torrent">Aha! But What About Downloading A Torrent?</a></h2>

<p>In the olden days (well, last year) there was a fly in the ointment.  You had to download a .torrent file from the website. That meant that you needed a way to connect to, in this case, The Pirate Bay or find a proxy which was willing to transfer files.</p>

<p>Nowadays, people use the <a href="http://en.wikipedia.org/wiki/Magnet_URI_scheme">magnet protocol</a>.  Here's what a magnet link looks like:</p>

<pre>magnet:?xt=urn:btih:fa692da0488aee23e5eb605a87be934ad7cec106</pre>

<p>Short enough to fit into a text message and, handily, can be embedded in an HTML document with no need to download an extra file.  Paste those 60 characters into your torrent client, and it will connect to the cloud and start downloading the file you requested.</p>

<p>So, a single web request to Yahoo and a line of JavaScript code is all it takes to circumvent this blockade.</p>

<h2 id="next-move"><a href="https://shkspr.mobi/blog/2012/05/yql-and-the-pirate-bay/#next-move">Next Move</a></h2>

<p>So, do the UK courts need to order ISPs to block Yahoo as well?  Or play whack-a-mole with all the new torrent sites springing up?  Let's not forget, in 2004 the huge Bit Torrent search engine <a href="http://en.wikipedia.org/wiki/Suprnova">Suprnova</a> was sued out of existence. Just like with the Hyrda, a decapitation lead to multiple sites springing up.</p>

<p>Piracy is a problem of convenience.  A pirated copy is</p>

<ul>
    <li>Faster to download.</li>
    <li>Quicker to watch (no unskipable trailers).</li>
    <li>More convenient to transfer to different devices.</li>
    <li>Global availability (no artificial regional restrictions).</li>
    <li>Immense back-catalogue (Star Wars, for example).</li>
    <li>Cheaper.</li>
</ul>

<p>The only downsides are that they are often of dubious legality, and occasionally of poor quality.</p>

<p>The entertainment industries have to compete on <strong>all these points</strong>.  I'll admit, that they will almost certainly not be able to compete with "free" - although monthly unlimited subscriptions come close.</p>

<p>The rest are problems of their own making.  I described how <a href="https://shkspr.mobi/blog/2009/05/the-10th-aniversary-of-the-death-of-the-modern-film-industry/">I downloaded The Phantom Menace back in 1999</a>.  13 long years later and the movie industry still isn't even close to where it needs to be.</p>

<p>Amazon have done pretty well from selling raw MP3s - a simple web interface, pay a small bit of money, instant high-quality download which is DRM free.  Where's the equivalent for films? Or for TV? Or radio?</p>

<p>The pernicious restrictions around geography also must end.  I want to watch Veep just as much as the Americans do. Why do I have to wait even an hour, let alone a week?</p>

<p>Finally, Star Wars <em>still</em> isn't available to (legally) download.  If I have a hankering for Jar Jar Binks at 3AM, I have to order a DVD and wait while it is physically transported from a warehouse. That's such a 19th Century way of thinking that it hurts my brain.</p>

<p>Get all that right and maybe - just maybe - the "piracy problem" will solve itself.</p>

<p>Of course, alternatively, it may be too late.  For 13 years people have been used to downloading without paying.  That's a long period of learned behaviour.  How content providers can convince people to change the habit of a lifetime is beyond my knowledge.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=5649&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2012/05/yql-and-the-pirate-bay/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Context Specific Content Surfacing]]></title>
		<link>https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/</link>
					<comments>https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Mon, 16 Apr 2012 09:42:51 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[usability]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lootu.be]]></category>
		<category><![CDATA[lootube]]></category>
		<category><![CDATA[whatleydude]]></category>
		<category><![CDATA[YouTube]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=5538</guid>

					<description><![CDATA[In a mixed paradigm environment, how do you ensure content is surfaced which is context specific?  By which I mean - how do you make your content serve the user&#039;s time-bound constraints?  What I&#039;m trying to say is - serendipitous discovery must be restricted based on temporal imperatives.  Or, to break it down further, a user may only have a specific amount of time to dedicate to your app; how do …]]></description>
										<content:encoded><![CDATA[<p>In a mixed paradigm environment, how do you ensure content is surfaced which is context specific?</p>

<p>By which I mean - how do you make your content serve the user's time-bound constraints?</p>

<p>What I'm trying to say is - serendipitous discovery must be restricted based on temporal imperatives.</p>

<p>Or, to break it down further, a user may only have a specific amount of time to dedicate to your app; how do you deal with that?</p>

<p>In a mobile game, the interface may present the user a choice of "Quick Play" for when the user is waiting for a bus, "Medium Play" for when the user is on the bus, "Long Play" for when the user is stuck in a traffic jam.</p>

<p><a href="http://whatleydude.com/2012/04/an-idea-for-iplayer-mobile/">James Whatley blogged about this subject recently</a>. In a mobile video app - such as the BBC iPlayer - the length of time the user can spend on the app is (probably) more important than <em>any other</em> discovery method.</p>

<p><a href="http://www.flickr.com/photos/whatleydude/6908483060/" title="Thoughts by whatleydude, on Flickr"><img src="https://farm8.staticflickr.com/7242/6908483060_ed90face1b.jpg" width="500" height="323" alt="Thoughts"></a></p>

<h2 id="demo"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#demo">Demo</a></h2>

<p>So, I spent the weekend building a demonstration mobile service which starts with the amount of time a user is expecting to use the app.</p>

<h3 id="lootube"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#lootube">LooTube!</a></h3>

<p>As far as I could see, iPlayer doesn't have any public APIs, the videos don't work on all phones, and the content isn't available outside the UK.  So I have used YouTube as the basis.</p>

<p>The "User Story"?</p>

<blockquote><p>As a user, when I am sat on the toilet, I want to be able to view a range of interesting videos suitable to the length of my visit.</p></blockquote>

<p>Point your phone at <a href="https://web.archive.org/web/20130225163453/http://lootu.be/">http://LooTu.be</a> and this is what you'll see:</p>

<img src="https://shkspr.mobi/blog/wp-content/uploads/2012/04/LooTube-Screenshot-1.jpg" alt="LooTube Screenshot 1" title="LooTube Screenshot 1" width="320" height="533" class="aligncenter size-full wp-image-5540">

<p>YouTube's API only gives us three lengths of video - short, medium, and long - so there's not quite as much granularity as I would have liked.</p>

<p>Clicking one of the buttons, retrieves a list of videos based on time.  The "Quick" button will show the users videos which are less than 4 minutes long.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2012/04/LooTube-Screenshot-2.jpg" alt="LooTube Screenshot 2" title="LooTube Screenshot 2" width="320" height="533" class="aligncenter size-full wp-image-5541"></p>

<p>At the moment, <a href="https://web.archive.org/web/20130225163453/http://lootu.be/">http://LooTu.be</a> doesn't allow the user to search for anything. It <strong>only</strong> takes <em>time</em> as a search query.  It does, however, randomly select between YouTubes standard "top" feeds - most viewed, top rated, most shared, top favourites, etc.</p>

<h2 id="technical-details"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#technical-details">Technical Details</a></h2>

<p>You can <a href="https://web.archive.org/web/20130225163453/http://lootu.be/">view the source of LooTu.be</a> - it's fairly basic HTML5 and <a href="http://jquerymobile.com/">jQuery Mobile</a>.  Feel free to laugh at my code and offer suggestions.</p>

<h2 id="thanks"><a href="https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/#thanks">Thanks</a></h2>

<p>Big thanks to Whatley for the inspiration, <a href="https://web.archive.org/web/20130522093955/https://robbi.es/">Robbie Dale</a> for the logo, and <a href="https://web.archive.org/web/20250000000000*/https://mymisanthropicmusings.org.uk/">my wife</a> for her patience this weekend!</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=5538&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2012/04/context-specific-content-surfacing/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
		<item>
		<title><![CDATA[Mobile Bit Torrent]]></title>
		<link>https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/</link>
					<comments>https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#comments</comments>
				<dc:creator><![CDATA[@edent]]></dc:creator>
		<pubDate>Sun, 13 Nov 2011 17:15:40 +0000</pubDate>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[bit torrent]]></category>
		<category><![CDATA[bittorrent]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery mobile]]></category>
		<category><![CDATA[NaBloPoMo]]></category>
		<category><![CDATA[torrent]]></category>
		<guid isPermaLink="false">http://shkspr.mobi/blog/?p=4579</guid>

					<description><![CDATA[This is a project I developed for OTA11 - but didn&#039;t feel confident showing it off.  Not least because I was one of the competition judges!  Preamble       Many people download BitTorrent files.     There are no BitTorrent search engines which are mobile friendly.     Users have to try to navigate non-mobile-optimised websites.     This is slow, inefficient, and may cost the user money in…]]></description>
										<content:encoded><![CDATA[<p>This is a project I developed for <a href="https://web.archive.org/web/20111012045423/http://overtheair.org/blog/2011/09/29/ota11-hackday-categories-prizes/">OTA11</a> - but didn't feel confident showing it off.  Not least because I was one of the competition judges!</p>

<h2 id="preamble"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#preamble">Preamble</a></h2>

<ul>
    <li>Many people download BitTorrent files.</li>
    <li>There are no BitTorrent search engines which are mobile friendly.</li>
    <li>Users have to try to navigate non-mobile-optimised websites.</li>
    <li>This is slow, inefficient, and may cost the user money in bandwidth charges.</li>
    <li>People who run Bit Torrent sites are often sued.</li>
</ul>

<h2 id="the-problem"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#the-problem">The Problem</a></h2>

<p>BitTorrent search engines have a nasty habit of being sued (not something I want to happen to me!)</p>

<p>Lawsuits arrive based, usually, on one of the following factors:</p>

<ul>
    <li>The site is hosting material which infringes a complainant's copyright.</li>
    <li>The site operates a tracker which tells users how to access copyrighted material without permission.</li>
    <li>The site distributes .torrent files which tell users how to access trackers.</li>
    <li>The site operates a search engine for Bit Torrent files.</li>
</ul>

<h2 id="the-challenge"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#the-challenge">The Challenge</a></h2>

<p>Is it possible to create a mobile friendly torrent search engine which neither hosts, distributes, nor searches for .torrent files?</p>

<p>This is how the usual client / server relationship works</p>

<pre>     +------------+           +------------+          +------------+
     |Browser     |           |Site        |          |Server      |
     +-----+------+           +------+-----+          +------------+
           |                         |                      +
           | Request for HTML page   |                      |
           +------------------------&gt;|                      |
           |                         |Search Request        |
           |                         +---------------------&gt;|
           |                         |                      |
           |                         |                      |
           |                         |  Search Response     |
           | Generated page sent     |&lt;--------------------+|
           |&lt;-----------------------+|                      |
</pre>

<p>The browser asks the torrent site, the torrent site asks a search engine, the search engine responds to the site, and the site returns a page to the user's browser.</p>

<p>This opens the site owner up to all sorts of risks.  She knows what her users are searching for and she knows what response the torrent provider is sending.</p>

<p>Is there a way around this?  Well, using <a href="http://jquerymobile.com/">jQuery Mobile</a>, I believe there is.</p>

<pre>     +------------+           +------------+          +------------+
     |Browser     |           |Site        |          |Server      |
     +-----+------+           +------+-----+          +-----+------+
           |                         |                      |
           | Request for HTML page   |                      |
           +------------------------&gt;|                      |
           |                         |                      |
           |                         |                      |
           | Generated page sent     |                      |
           |&lt;------------------------+                      |
           |                                                |
           |                                                |
           | Search request direct to search engine         |
           +-----------------------------------------------&gt;|
           |                                                |
           |                                                |
           |      Response sent directly to phone browser   |
           |&lt;-----------------------------------------------+</pre>

<p>Here's what happens:</p>

<ol>
    <li>The user's mobile browser requests the search page.</li>
    <li>The site delivers the search page to the browser.</li>
    <li>User types "Ubuntu" into the search box and hits "search".</li>
    <li>The text "Ubuntu" is <strong>not sent to the site</strong>!</li>
    <li>jQuery Mobile "intercepts" the request.</li>
    <li>The browser sends the search query directly to the search server.</li>
    <li>The browser downloads the search results directly. (JSONP)</li>
    <li>The JavaScript on the browser renders the results on the screen.</li>
    <li>The user downloads the torrent directly from the source.</li>
</ol>

<p>So, in this way, all the service does is send some HTML and JavaScript to the user's phone.</p>

<p>The majority of the logic is <a href="http://jquerymobile.com/download/">stored on the jQuery CDN</a>.</p>

<p>It is the user's phone which then communicates with the search engine. The user's phone which receives the results. And the user's phone which renders them.</p>

<p>In this case, the server doesn't see any content - legal or otherwise - nor does it see any search requests.</p>

<h2 id="technical"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#technical">Technical</a></h2>

<p>The code itself is fairly simple.</p>

<p>There are no reliable Bit Torrent search APIs which respond via JSONP.  However, <a href="https://web.archive.org/web/20111103004550/http://pipes.yahoo.com/pipes/search?r=tag%3Atorrent">Yahoo Pipes provides several "recipes"</a> which query APIs and return correctly formatted data.</p>

<p>Here's the skeleton code:</p>

<pre lang="javascript">var pipeURL = "http://pipes.yahoo.com/pipes/pipe.run?u="+
    searchTerm+
    "%26rows=10"+
    "%26sort="+
    sortBy+
    "&amp;_render=json&amp;_callback=?";

//  Get the JSONP and parse it
$.getJSON(pipeURL,
function(data)
{
    // An Array of list items to be added to the ul
    var listItems = [];
    //  Loop through the results
    $.each(data.value.items[0].items.list, function(i,item)
    {
        //  Get all the properties of each result
        var enclosure_url = item.enclosure_url;
        var title = item.title.replace(/(&lt; ([^&gt;]+)&gt;)/ig,""); // Strip tags

        //  Create a set of <li></li> which can be added to the <ul></ul>
        listItems.push('<li>'+title+'</li>');
    });
});
</pre>

<p>To reiterate, all of this runs on the mobile phone.  There is nothing happening on my server.</p>

<p>Now, I'm not sure that this is a cast iron legal defence - hence <strong>I am not making the site public</strong> - but it moves the action squarely on to the user.</p>

<p>In this case, the phone contacts Yahoo, Yahoo then contacts a Torrent search engine, the phone does all the sending, receiving, rendering, and downloading.  The server doesn't even see the search request.</p>

<h2 id="what-does-it-look-like"><a href="https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/#what-does-it-look-like">What Does It Look Like?</a></h2>

<p>The initial page.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2011/11/xmts-start.png" alt="" title="xmts start" width="320" height="285" class="aligncenter size-full wp-image-4656"></p>

<p>Searching
<img src="https://shkspr.mobi/blog/wp-content/uploads/2011/11/xmts-search.png" alt="" title="xmts search" width="320" height="284" class="aligncenter size-full wp-image-4657"></p>

<p>The results.
<img src="https://shkspr.mobi/blog/wp-content/uploads/2011/11/xmts-results.png" alt="" title="xmts results" width="320" height="497" class="aligncenter size-full wp-image-4658"></p>

<p>The user is then free to download the torrent.  Of course, the only torrent client I know for mobile phones is <a href="https://web.archive.org/web/20111118030451/http://amorg.aut.bme.hu/projects/symtorrent">SymTorrent</a> - and that only runs on older Symbian phones.  So this project is of no practical purpose.</p>
<img src="https://shkspr.mobi/blog/wp-content/themes/edent-wordpress-theme/info/okgo.php?ID=4579&HTTP_REFERER=RSS" alt="" width="1" height="1" loading="eager">]]></content:encoded>
					
					<wfw:commentRss>https://shkspr.mobi/blog/2011/11/mobile-bit-torrent/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
			</item>
	</channel>
</rss>
