2013-10-23 01:14:51 +00:00
$ ( document ) . ready ( function ( ) {
$ . getJSON ( "_site/examples.json" )
. done ( function ( data ) {
var i = 0 ;
var node = '' ;
2013-10-24 12:08:57 +00:00
var directories = Object . keys ( data ) ;
directories . splice ( directories . indexOf ( 'basics' ) , 1 ) ;
directories . splice ( directories . indexOf ( 'games' ) , 1 ) ;
2013-10-24 12:12:54 +00:00
directories . sort ( ) ;
2013-10-24 12:08:57 +00:00
directories . unshift ( 'basics' , 'games' ) ;
directories . forEach ( function ( dir )
2013-10-23 01:14:51 +00:00
{
2013-10-24 12:08:57 +00:00
var files = data [ dir ] ;
2013-10-23 01:14:51 +00:00
node = '<h2>' + dir + '</h2>' ;
for ( var e = 0 ; e < files . length ; e ++ )
{
node += '<a href="_site/view_lite.html?d=' + dir + '&f=' + files [ e ] . file + '&t=' + files [ e ] . title + '" target="viewer">' + files [ e ] . title + '</a><br />' ;
}
$ ( "#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' ) ;
2013-11-25 13:12:03 +00:00
// iFrame focus
$ ( 'a' ) . click ( function ( e ) { $ ( '#viewer' ) . focus ( ) ; } ) ;
2013-10-23 01:14:51 +00:00
} )
. fail ( function ( ) {
var node = '<h1>Error!</h1>' ;
node += '<p>Unable to load <u>examples.json</u> data file</p>' ;
node += '<p>Did you open this html file locally?</p>' ;
node += '<p>It needs to be opened via a web server, or due to browser security permissions<br />it will be unable to load local resources such as images and json data.</p>' ;
node += '<p>Please see our <a href="#">Getting Started guide</a> for details.</p>' ;
$ ( "#viewer" ) . contents ( ) . find ( 'body' ) . append ( node ) ;
} ) ;
} ) ;