2013-10-22 13:59:43 +00:00
$ ( document ) . ready ( function ( ) {
$ . getJSON ( "_site/examples.json" )
. done ( function ( data ) {
var i = 0 ;
2013-10-23 03:15:44 +00:00
var t = 0 ;
2013-10-22 13:59:43 +00:00
var len = 0 ;
var node = '' ;
var laser = '' ;
$ . each ( data , function ( dir , files )
{
2013-10-23 03:15:44 +00:00
len = Math . floor ( files . length / 4 ) + 1 ;
if ( ( files . length / 4 ) % 1 == 0 )
{
len -- ;
}
2013-10-22 13:59:43 +00:00
if ( len > 9 )
{
laser = 'laser10' ;
}
else
{
2013-10-23 03:15:44 +00:00
laser = 'laser' + len ;
2013-10-22 13:59:43 +00:00
}
if ( i == 1 )
{
node = '<div class="clear5"></div><div class="line dark-bg">' ;
}
else if ( i == 2 )
{
node = '<div class="clear5"></div><div class="line bright-bg">' ;
}
node += '<div class="box20"><p class="title strong">' + dir + '</p>' ;
node += '<p class="count-examples strong">' + files . length + ' examples</p></div><div class="box80">' ;
node += '<ul class="group-items ' + laser + '">' ;
for ( var e = 0 ; e < files . length ; e ++ )
{
2013-10-22 20:29:58 +00:00
node += '<li><a href="_site/view_full.html?d=' + dir + '&f=' + files [ e ] . file + '&t=' + files [ e ] . title + '">' + files [ e ] . title + '</a></li>' ;
2013-10-23 03:15:44 +00:00
t ++ ;
2013-10-22 13:59:43 +00:00
}
node += '</ul></div>' ;
$ ( "#examples-list" ) . append ( node ) ;
i ++ ;
if ( i == 3 )
{
i = 1 ;
}
} ) ;
2013-10-23 03:15:44 +00:00
$ ( "#total" ) . append ( t ) ;
2013-10-22 13:59:43 +00:00
} )
. fail ( function ( ) {
var node = '<div class="clear5"></div><div class="line dark-bg">' ;
node += '<div class="box20"><p class="title strong">Error!</p>' ;
node += '<p class="count-examples strong">:(</p></div><div class="box80"><div class="error">' ;
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>' ;
node += '</div>' ;
node += '</div>' ;
$ ( "#examples-list" ) . append ( node ) ;
} ) ;
2013-10-23 03:15:44 +00:00
$ . getJSON ( "http://phaser.io/version.json" )
. done ( function ( data ) {
if ( data . version !== '1.1' )
{
$ ( "#upgrade" ) . append ( data . version ) ;
$ ( "#upgrade" ) . css ( 'display' , 'inline-block' ) ;
}
} ) ;
2013-10-22 13:59:43 +00:00
} ) ;