$(document).ready(function(){ $.getJSON("_site/examples.json") .done(function(data) { var i = 0; var node = ''; var directories = Object.keys(data); directories.splice(directories.indexOf('basics'), 1); directories.splice(directories.indexOf('games'), 1); directories.sort(); directories.unshift('basics', 'games'); directories.forEach(function(dir) { var files = data[dir]; node = '

' + dir + '

'; for (var e = 0; e < files.length; e++) { node += '' + files[e].title + '
'; } $("#examples-list").append(node); i += files.length; }); $("#total").append(i); // Re-calc the viewer height var height = $(window).height() - 270; $("#panel").css('height', height + 'px'); // iFrame focus $('a').click(function(e) { $('#viewer').focus(); }); }) .fail(function() { var node = '

Error!

'; node += '

Unable to load examples.json data file

'; node += '

Did you open this html file locally?

'; node += '

It needs to be opened via a web server, or due to browser security permissions
it will be unable to load local resources such as images and json data.

'; node += '

Please see our Getting Started guide for details.

'; $("#viewer").contents().find('body').append(node); }); });