refactor display code, only refresh changed elements

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

View file

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