How to fiddle on any web page

Once you have a nice jQuery plugin for accessing any URL, it’s only natural that you start fiddling around with some web page here and there.

Lately I wanted to dominate the http://disco-tools.eu/disco2_portal/terms.php beast.. ehm.. page, which is home to the official European thesaurus of skills and competences. It’s a good starting point for projects related with education in Europe, but also worldwide. Even if it is far from perfect, it’s translated to many European languages (English, German, French, Czech, Hungarian, Italian, Lithuanian, Polish, Slovak, Spanish, Swedish) and it organizes around 9000 terms in each language.

Screen Shot 2014-06-05 at 11.13.33

My target is to be able to browse the thesaurus from the Result frame of jsFiddle.

First Attempt

I already showed that YQL is not the best choice for getting this URL, due to its inability to let stuff come through without correcting it before. So, I will still use my own proxy.

My first attempt (open in jsFiddle):

{[ .disco-attempt1 | 1.hilite(=javascript=) ]}

produced this result:

Screen Shot 2014-06-05 at 10.19.50

How to include a jsFiddle into another jsFiddle

jsFiddle is an online editor that allows you to work on “proof of concepts” in HTML + CSS + JavaScript. You can import many different JavaScript libraries, like jQuery, and also any other unsupported ones, if they are reachable on the internet, for example through cdnjs.

One thing jsFiddle lacks is the ability to import stuff from another fiddle. It’s king of frustrating not to be able to do it, moreover when it’s coupled with the inability to upload stuff.

Here is a possible solution that will work at least for your own fiddles. The idea is to somehow mark the pieces of code you want to export. Something like this:

{[ .jsfiddle-export | 1.hilite(=javascript=) ]}

Then, in the fiddle you want to import to, you can use my $.proxyGet jQuery plugin to download your fiddle, extract those pieces, join them again and globally eval them. Something like this:

{[ .jsfiddle-import | 1.hilite(=javascript=) ]}

Which will dutifully show the following message in its console:

Just imported and executed some code.