gLoadVsavHandler = null ; // -------------------------------------------------------------------- function on_update_vsav() { // check if we should ask the user to confirm the settings if ( gUserSettings[ "confirm-update-vsav-settings" ] ) { // yup - make it so user_settings( function() { _load_and_process_vsav( _do_update_vsav ) ; }, "Confirm user settings" ) ; } else { // nope - just do it _load_and_process_vsav( _do_update_vsav ) ; } } function _do_update_vsav( vsav_data, fname ) { // generate all the snippets var $pleaseWait = showPleaseWaitDialog( "Updating your VASL scenario..." ) ; var snippets = _generate_snippets() ; // send a request to update the VSAV var data = { filename: fname, vsav_data: vsav_data, players: [ get_player_nat(1), get_player_nat(2) ], testMode: !! getUrlParam( "store_msgs" ), snippets: snippets } ; $.ajax( { url: gUpdateVsavUrl, type: "POST", data: JSON.stringify( data ), contentType: "application/json", } ).done( function( resp ) { $pleaseWait.dialog( "close" ) ; data = _check_vassal_shim_response( resp, "Can't update the VASL scenario." ) ; if ( ! data ) return ; // check if anything was changed if ( ! data.report.was_modified ) { showInfoMsg( "No changes were made to the VASL scenario." ) ; if ( getUrlParam( "vsav_persistence" ) ) $("#_vsav-persistence_").val( btoa( "No changes." ) ) ; return ; } // save the updated VSAV file _show_label_report_msg( data.report ) ; if ( gWebChannelHandler ) { setTimeout( function() { // nb: give the label report time to appear :-/ gWebChannelHandler.save_updated_vsav( data.filename, data.vsav_data ) ; }, 1*1000 ) ; return ; } if ( getUrlParam( "vsav_persistence" ) ) { // FOR TESTING PORPOISES! We can't control a file download from Selenium (since // the browser will use native controls), so we store the result in a