refactor display code, only refresh changed elements

This commit is contained in:
Gwenhael Le Moine 2011-07-13 16:49:47 +02:00
parent aa465179f8
commit ee96e8f271

View file

@ -146,12 +146,8 @@ function format_help( ) {
} }
function display_level( state, elt ) { function display_level( state, elt ) {
var starhtml = '<div class="gstar">'; $( elt + " .gstar #blackboard" ).html( format_level( state, false ) );
starhtml += '<aside id="help">' + format_help( state ) + '</aside>'; $( elt + " .gstar #infos" ).html( format_infos( state ) );
starhtml += '<div id="blackboard">' + format_level( state, false ) + '</div>';
starhtml += '<aside id="infos">' + format_infos( state ) + '</aside>';
starhtml += '</div>';
$( elt ).html( starhtml );
} }
function load_level( levelset, nb ) { function load_level( levelset, nb ) {
@ -312,6 +308,13 @@ function start_loop( state, elt ) {
} }
function initialize_a_star( elt ) { function initialize_a_star( elt ) {
var starhtml = '<div class="gstar">';
starhtml += '<aside id="help">' + format_help( state ) + '</aside>';
starhtml += '<div id="blackboard"></div>';
starhtml += '<aside id="infos"></aside>';
starhtml += '</div>';
$( elt ).html( starhtml );
state = load_level( levels, 0 ); state = load_level( levels, 0 );
start_loop( state, elt ); start_loop( state, elt );
} }