$( document ).ready( function() {
var compiledOutputTemplate = Handlebars.compile($("#query-tabular-output-template").html());
$.getJSON(
"http://sqlfiddle.com/index.cfm/fiddles/loadContent",
{ fragment: "!2/40ff9/1" },
function( data ) {
$("#outputWrapper").html(
compiledOutputTemplate( data )
);
});
});
// @see: http://stackoverflow.com/a/12397958/753531
Handlebars.registerHelper("each_with_index", function(array, fn) {
var buffer = "";
k=0;
for (var i = 0, j = array.length; i < j; i++) {
if (array[i])
{
var item = array[i];
// stick an index property onto the item, starting with 0
item.index = k;
item.first = (k == 0);
item.last = (k == array.length);
// show the inside of the block
buffer += fn(item);
k++;
}
}
// return the finished buffer
return buffer;
});
Handlebars.registerHelper("result_display", function(value) {
// thanks to John Gruber for this regexp http://daringfireball.net/2010/07/improved_regex_for_matching_urls
// also to "Searls" for his port to JS https://gist.github.com/1033143
var urlRegexp = /\b((?:https?:\/\/|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?ÇÈÒÓÔÕ]))/ig;
if ($.isPlainObject(value))
return JSON.stringify(value);
else if (value == null)
return "(null)";
else if (value === false)
return "false";
else if (typeof value === "string" && value.match(urlRegexp) && Handlebars.Utils.escapeExpression(value) == value)
return new...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.